Refactoring the project, new folders for view and model classes. Added
[emufront] / src / dialogs / executableeditdialog.cpp
index 4be8b01..5314177 100644 (file)
 
 #include <QtGui>
 #include "executableeditdialog.h"
-#include "../db/dbexecutable.h"
-#include "../db/dbsetup.h"
-#include "../dataobjects/executable.h"
-#include "../dataobjects/setup.h"
-#include "../widgets/setupcombobox.h"
-#include "../exceptions/emufrontexception.h"
+#include "dbexecutable.h"
+#include "dbsetup.h"
+#include "executable.h"
+#include "setup.h"
+#include "setupcombobox.h"
+#include "emufrontexception.h"
 
 ExecutableEditDialog::ExecutableEditDialog(QWidget *parent, EmuFrontObject *obj)
     : DataObjectEditDialog(parent, obj)
@@ -138,6 +138,7 @@ void ExecutableEditDialog::setDataObject(EmuFrontObject *ob)
         qDebug("No executable");
         return;
     }
+    clear();
     if (!ex->getSetup()) {
         qDebug() << "No setup";
         return;
@@ -149,14 +150,26 @@ void ExecutableEditDialog::setDataObject(EmuFrontObject *ob)
     optEdit->setText(ex->getOptions());
 }
 
+void ExecutableEditDialog::clear()
+{
+    nameEdit->clear();
+    execEdit->clear();
+    optEdit->clear();
+    setupComBox->setCurrentIndex(-1);
+}
+
 void ExecutableEditDialog::setSelectedSetup(const Setup *su)
 {
     setupComBox->setSelected(su);
 }
 
-Setup* ExecutableEditDialog::getSelectedSetup() const
+/* Returns a pointer to a Setup object which must be deleted by calling code! */
+Setup* ExecutableEditDialog::getSelectedSetup()
 {
-    EmuFrontObject *o = setupComBox->getSelected();
+    EmuFrontObject *o = 0;
+    try { o = setupComBox->getSelected(); }
+    catch(EmuFrontException &e){ errorMessage->showMessage(e.what()); }
+
     if (!o) return 0;
     Setup *ex = dynamic_cast<Setup*>(o);
     return ex;