Fixed Emulator selection combo box, preserves state after emulator
authorMikko Keinänen <mikko.keinanen@gmail.com>
Thu, 25 Nov 2010 19:51:22 +0000 (21:51 +0200)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Thu, 25 Nov 2010 19:51:22 +0000 (21:51 +0200)
execution has finished.

src/emulauncher.cpp
src/widgets/efcombobox.cpp
src/widgets/efcombobox.h
src/widgets/executablecombobox.cpp
src/widgets/executablecombobox.h

index 3e75ed9..100fcdb 100644 (file)
@@ -88,7 +88,7 @@ void EmuLauncher::layout()
     grid->addWidget(micTable, 1, 0, 1, 4);
     grid->addWidget(execSelectBox, 2, 0);
     grid->addWidget(launchButton, 2, 1);
-    // grid will be implicitily parented to this
+    // grid will be implicitly parented to this
     setLayout(grid);
 }
 
@@ -102,7 +102,6 @@ void EmuLauncher::connectSignals()
 
 void EmuLauncher::updateMediaImageContainers()
 {
-    qDebug() << "updateMediaImageContainers slot";
     int mtid, plfid = -1;
     MediaType *mt = 0;
     Platform *plf = 0;
index 2d0a487..4a27ccc 100644 (file)
@@ -67,12 +67,17 @@ EmuFrontObject* EFComboBox::getSelected()
     }
     int id = rec.value(dataModelIndex_id).toInt();
     EmuFrontObject *o = dbManager->getDataObject(id); /* Throws EmuFrontException */
-    dbManager->resetModel();
+    reset();
     setCurrentIndex(index);
     if (!o) throw EmuFrontException(tr("Failed creating selected data object!"));
     return o;
 }
 
+void EFComboBox::reset()
+{
+    dbManager->resetModel();
+}
+
 void EFComboBox::setSelected(const EmuFrontObject *efo)
 {
     if (!efo)
index c35971e..5542d96 100644 (file)
@@ -37,6 +37,7 @@ protected:
     DatabaseManager *dbManager;
     int dataModelIndex_id;
     int dataModelIndex_name;
+    virtual void reset();
 };
 
 #endif // EFCOMBOBOX_H
index 37b7cb8..6081b5a 100644 (file)
@@ -26,11 +26,20 @@ ExecutableComboBox::ExecutableComboBox(DatabaseManager *dbMan, QWidget *parent)
     dataModelIndex_name = DbExecutable::Executable_Name;
     dataModelIndex_id = DbExecutable::Executable_Id;
     setModelColumn(dataModelIndex_name);
+    currentPlatformId = -1;
+    currentMediaTypeId = -1;
 }
 
 void ExecutableComboBox::updateToSetup(int platformId, int mediaTypeId)
 {
+    currentPlatformId = platformId;
+    currentMediaTypeId = mediaTypeId;
+    reset();
+}
+
+void ExecutableComboBox::reset()
+{
     DbExecutable *dbExe = dynamic_cast<DbExecutable *>(dbManager);
-    dbExe->filterByPlatformMediaType(platformId, mediaTypeId);
+    dbExe->filterByPlatformMediaType(currentPlatformId, currentMediaTypeId);
     EFComboBox::updateDataModel(false);
 }
index 998fed0..071e1b8 100644 (file)
@@ -27,6 +27,11 @@ class ExecutableComboBox : public EFComboBox
 public:
     ExecutableComboBox(DatabaseManager *dbMan, QWidget *parent);
     void updateToSetup(int platformId, int mediaTypeId);
+protected:
+    virtual void reset();
+private:
+    int currentPlatformId;
+    int currentMediaTypeId;
 };
 
 #endif // EXECUTABLECOMBOBOX_H