Modified the license text comment type.
[emufront] / src / dialogs / executablemaindialog.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 "executablemaindialog.h"
23 #include "executableeditdialog.h"
24 #include "dbexecutable.h"
25 #include "executable.h"
26
27 ExecutableMainDialog::ExecutableMainDialog(QWidget *parent)
28     : DbObjectDialog(parent)
29 {
30     setWindowTitle(tr("Emulators"));
31     dbManager = new DbExecutable(this);
32     initDataTable();
33     initEditDialog();
34     hiddenColumns << DbExecutable::Executable_Id;
35     hiddenColumns << DbExecutable::Executable_TypeId;
36     hiddenColumns << DbExecutable::Executable_SetupId;
37     hideColumns();
38     connectSignals();
39 }
40
41 ExecutableMainDialog::~ExecutableMainDialog()
42 {
43     deleteCurrentObject();
44 }
45
46 void ExecutableMainDialog::initEditDialog()
47 {
48     nameDialog = new ExecutableEditDialog(
49         this, dynamic_cast<Executable*>(dbObject));
50     connectNameDialogSignals();
51 }
52
53 void ExecutableMainDialog::deleteCurrentObject()
54 {
55     if (dbObject) {
56         Executable *exe =  dynamic_cast<Executable*>(dbObject);
57         if (exe) delete exe;
58         else qDebug() << "Failed deleting Executable";
59         dbObject = 0;
60     }
61 }
62
63 void ExecutableMainDialog::cleanUp()
64 {
65     deleteCurrentObject();
66     if (nameDialog) {
67         ExecutableEditDialog *pnd =
68             dynamic_cast<ExecutableEditDialog *>(nameDialog);
69         if (pnd) delete pnd;
70         else qDebug() << "Failed to delete PlatformNameDialog";
71         nameDialog = 0;
72     }
73 }
74
75 EmuFrontObject* ExecutableMainDialog::createObject()
76 {
77     Executable *ex = new Executable;
78     return ex;
79 }