Refactoring the project, new folders for view and model classes. Added
[emufront] / src / dialogs / executablemaindialog.cpp
index 877a338..e8c807d 100644 (file)
@@ -5,9 +5,9 @@
 //
 //
 // EmuFront is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
 //
 // EmuFront is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,8 +20,8 @@
 #include <QtGui>
 #include "executablemaindialog.h"
 #include "executableeditdialog.h"
-#include "../db/dbexecutable.h"
-#include "../dataobjects/executable.h"
+#include "dbexecutable.h"
+#include "executable.h"
 
 ExecutableMainDialog::ExecutableMainDialog(QWidget *parent)
     : DbObjectDialog(parent)
@@ -30,9 +30,10 @@ ExecutableMainDialog::ExecutableMainDialog(QWidget *parent)
     dbManager = new DbExecutable(this);
     initDataTable();
     initEditDialog();
-    objectList->hideColumn(DbExecutable::Executable_Id);
-    objectList->hideColumn(DbExecutable::Executable_TypeId);
-    objectList->hideColumn(DbExecutable::Executable_SetupId);
+    hiddenColumns << DbExecutable::Executable_Id;
+    hiddenColumns << DbExecutable::Executable_TypeId;
+    hiddenColumns << DbExecutable::Executable_SetupId;
+    hideColumns();
     connectSignals();
 }
 
@@ -45,15 +46,33 @@ void ExecutableMainDialog::initEditDialog()
 {
     nameDialog = new ExecutableEditDialog(
         this, dynamic_cast<Executable*>(dbObject));
+    connectNameDialogSignals();
 }
 
 void ExecutableMainDialog::deleteCurrentObject()
 {
-   delete dynamic_cast<Executable*>(dbObject);
-   dbObject = 0;
+    if (dbObject) {
+        Executable *exe =  dynamic_cast<Executable*>(dbObject);
+        if (exe) delete exe;
+        else qDebug() << "Failed deleting Executable";
+        dbObject = 0;
+    }
+}
+
+void ExecutableMainDialog::cleanUp()
+{
+    deleteCurrentObject();
+    if (nameDialog) {
+        ExecutableEditDialog *pnd =
+            dynamic_cast<ExecutableEditDialog *>(nameDialog);
+        if (pnd) delete pnd;
+        else qDebug() << "Failed to delete PlatformNameDialog";
+        nameDialog = 0;
+    }
 }
 
 EmuFrontObject* ExecutableMainDialog::createObject()
 {
-    return new Executable;
+    Executable *ex = new Executable;
+    return ex;
 }