Modified the license text comment type.
[emufront] / src / dialogs / platformdialog.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 "dbplatform.h"
23 #include "platform.h"
24 #include "platformdialog.h"
25 #include "platformnamedialog.h"
26
27 PlatformDialog::PlatformDialog(QWidget *parent)
28     : EmuFrontFileObjectDialog(parent)
29 {
30     setWindowTitle(tr("Set emulated platforms"));
31     dbManager = new DbPlatform(this);
32     initDataTable();
33     initEditDialog();
34     setColumnsHidden();
35     hideColumns();
36
37     // do not move to parent class:
38     connectSignals();
39 }
40
41 PlatformDialog::~PlatformDialog()
42 {
43     qDebug() << "PlatformDialog destructor.";
44     deleteCurrentObject();
45 }
46
47 void PlatformDialog::initEditDialog()
48 {
49     nameDialog = new PlatformNameDialog(this, dynamic_cast<Platform*>(dbObject));
50     connectNameDialogSignals();
51 }
52
53 EmuFrontObject* PlatformDialog::createObject()
54 {
55     qDebug() << "PlatformDialog creating a Platform object.";
56     return new Platform;
57 }
58
59 void PlatformDialog::deleteCurrentObject()
60 {
61     if (dbObject) {
62         qDebug() << "PlatformDialog deleting a Platform object.";
63         Platform *plf = dynamic_cast<Platform*>(dbObject);
64         if (plf) delete plf;
65         else qDebug() << "Failed deleting Platform";
66         dbObject = 0;
67     }
68 }
69
70 void PlatformDialog::cleanUp()
71 {
72     deleteCurrentObject();
73     if (nameDialog) {
74         PlatformNameDialog *pnd =
75             dynamic_cast<PlatformNameDialog*>(nameDialog);
76         if (pnd) delete pnd;
77         else qDebug() << "Failed to delete PlatformNameDialog";
78         nameDialog = 0;
79     }
80 }