Modified the license text comment type.
[emufront] / src / dialogs / mediatypedialog.cpp
1 /*
2 ** EmuFront
3 ** Copyright 2010 Mikko Keinänen
4 **
5 ** This file is part of EmuFront.
6 **
7 **
8 ** EmuFront is free software: you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License version 2 as published by
10 ** the Free Software Foundation and appearing in the file gpl.txt included in the
11 ** packaging of this file.
12 **
13 ** EmuFront is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include <QtGui>
22 #include <QAbstractItemView>
23 #include <QSqlTableModel>
24 #include <QTextStream>
25 #include "dbmediatype.h"
26 #include "mediatype.h"
27 #include "mediatypedialog.h"
28 #include "mediatypenamedialog.h"
29
30 MediaTypeDialog::MediaTypeDialog(QWidget* parent)
31     :EmuFrontFileObjectDialog(parent)
32 {
33     setWindowTitle(tr("Set media types"));
34     dbManager = new DbMediaType(this);
35     initDataTable();
36     initEditDialog();
37     // do not move to parent class:
38     connectSignals();
39     setColumnsHidden();
40     hideColumns();
41 }
42
43 MediaTypeDialog::~MediaTypeDialog()
44 {
45     deleteCurrentObject();
46 }
47
48 void MediaTypeDialog::initEditDialog()
49 {
50     nameDialog = new MediaTypeNameDialog(this, dynamic_cast<MediaType*>(dbObject));
51     connectNameDialogSignals();
52 }
53
54 EmuFrontObject* MediaTypeDialog::createObject()
55 {
56     return new MediaType;
57 }
58
59 void MediaTypeDialog::deleteCurrentObject()
60 {
61     delete dynamic_cast<MediaType*>(dbObject);
62     dbObject = 0;
63 }
64
65 void MediaTypeDialog::cleanUp()
66 {
67     deleteCurrentObject();
68     if (nameDialog) {
69         MediaTypeNameDialog *pnd =
70             dynamic_cast<MediaTypeNameDialog*>(nameDialog);
71         if (pnd) delete pnd;
72         else qDebug() << "Failed to delete MediaTypeNameDialog";
73         nameDialog = 0;
74     }
75 }