Implemented SetupComboBox based on EFComboBox and used it in
authorMikko Keinänen <mikko.keinanen@gmail.com>
Sat, 2 Oct 2010 09:34:03 +0000 (12:34 +0300)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Sat, 2 Oct 2010 09:34:03 +0000 (12:34 +0300)
MediaImagePathDialog.

src/dialogs/dataobjecteditdialog.cpp
src/dialogs/mediaimagepathdialog.cpp
src/dialogs/mediaimagepathdialog.h
src/emufront.pro
src/widgets/setupcombobox.cpp [new file with mode: 0644]
src/widgets/setupcombobox.h [new file with mode: 0644]

index b6da83c..760d866 100644 (file)
@@ -38,7 +38,7 @@ void DataObjectEditDialog::connectSignals()
 }
 
 // TODO: remove this after implementing all the combo boxes using EFComboBox
-void DataObjectEditDialog::setSelected(QComboBox *cbox, const EmuFrontObject *ob, int idIndex)
+/*void DataObjectEditDialog::setSelected(QComboBox *cbox, const EmuFrontObject *ob, int idIndex)
 {
     if (!ob) return;
     QSqlQueryModel *model = dynamic_cast<QSqlQueryModel*>(cbox->model());
@@ -53,7 +53,7 @@ void DataObjectEditDialog::setSelected(QComboBox *cbox, const EmuFrontObject *ob
             break;
         }
     }
-}
+}*/
 
 void DataObjectEditDialog::rejectChanges()
 {
index 28b6f3f..4aaecfb 100644 (file)
@@ -23,6 +23,7 @@
 #include "mediaimagepathdialog.h"
 #include "../db/dbsetup.h"
 #include "../dataobjects/filepathobject.h"
+#include "../widgets/setupcombobox.h"
 
 MediaImagePathDialog::MediaImagePathDialog(QWidget *parent, EmuFrontObject *efObject)
     : DataObjectEditDialog(parent, efObject, Qt::Horizontal)
@@ -30,6 +31,7 @@ MediaImagePathDialog::MediaImagePathDialog(QWidget *parent, EmuFrontObject *efOb
     initWidgets();
     dbPlatform = 0;
     dbMediaType = 0;
+    dbSetup = 0;
     connectSignals();
     layout();
 }
@@ -60,16 +62,17 @@ void MediaImagePathDialog::initWidgets()
     // these widgets will be automatically parented using layout components
     filePathLabel = new QLabel;
     filePathButton = new QPushButton(tr("&Browse filepath"));
-    setupComBox = new QComboBox;
-    populateSetupComBox();
+    dbSetup = new DbSetup(this);
+    setupComBox = new SetupComboBox(dbSetup, this); //QComboBox;
+    //populateSetupComBox();
 }
 
-void MediaImagePathDialog::populateSetupComBox()
+/*void MediaImagePathDialog::populateSetupComBox()
 {
     dbSetup = new DbSetup(this);
     setupComBox->setModel(dbSetup->getDataModel());
     setupComBox->setModelColumn(DbSetup::Setup_Name);
-}
+}*/
 
 void MediaImagePathDialog::layout()
 {
@@ -101,12 +104,17 @@ void MediaImagePathDialog::setDataObject(EmuFrontObject *ob)
 
 void MediaImagePathDialog::setSelectedSetup(const Setup *sup)
 {
-    setSelected(setupComBox, sup, DbSetup::Setup_Id);
+
+    setupComBox->setSelected(sup);
+    // setSelected(setupComBox, sup, DbSetup::Setup_Id);
 }
 
 Setup* MediaImagePathDialog::getSelectedSetup()
 {
-    if (!dbPlatform) dbPlatform = new DbPlatform(this);
+    EmuFrontObject *ob = setupComBox->getSelected();
+    if (!ob) return 0;
+    return dynamic_cast<Setup*>(ob);
+    /*if (!dbPlatform) dbPlatform => new DbPlatform(this);
     if (!dbMediaType) dbMediaType = new DbMediaType(this);
     Setup *sup = 0;
     int index = setupComBox->currentIndex();
@@ -132,7 +140,7 @@ Setup* MediaImagePathDialog::getSelectedSetup()
             exts.split(DbSetup::FILE_TYPE_EXTENSION_SEPARATOR));
     }
     else errorMessage->showMessage("Record missing");
-    return sup;
+    return sup;*/
 }
 
 void MediaImagePathDialog::acceptChanges()
index 4f0a6f1..0526878 100644 (file)
@@ -23,7 +23,6 @@
 #include "dataobjecteditdialog.h"
 
 class QDialogButtonBox;
-class QComboBox;
 class QLabel;
 class QPushButton;
 class QSqlTableModel;
@@ -31,6 +30,7 @@ class DbSetup;
 class Setup;
 class DbMediaType;
 class DbPlatform;
+class SetupComboBox;
 
 class MediaImagePathDialog : public DataObjectEditDialog
 {
@@ -46,7 +46,7 @@ protected slots:
     void browseFilePath();
 
 private:
-    QComboBox *setupComBox;
+    SetupComboBox *setupComBox;
     QLabel *filePathLabel;
     QPushButton *filePathButton;
     DbSetup *dbSetup;
index dc74408..59fb03a 100644 (file)
@@ -55,7 +55,8 @@ HEADERS += mainwindow.h \
     utils/OSDaB-Zip/unzip_p.h \
     emulauncher.h \
     widgets/efcombobox.h \
-    widgets/effileobjectcombobox.h
+    widgets/effileobjectcombobox.h \
+    widgets/setupcombobox.h
 SOURCES += main.cpp \
     mainwindow.cpp \
     db/databasemanager.cpp \
@@ -98,5 +99,6 @@ SOURCES += main.cpp \
     db/dbmediaimage.cpp \
     emulauncher.cpp \
     widgets/efcombobox.cpp \
-    widgets/effileobjectcombobox.cpp
+    widgets/effileobjectcombobox.cpp \
+    widgets/setupcombobox.cpp
 OTHER_FILES += 
diff --git a/src/widgets/setupcombobox.cpp b/src/widgets/setupcombobox.cpp
new file mode 100644 (file)
index 0000000..76130bc
--- /dev/null
@@ -0,0 +1,31 @@
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// 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.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "setupcombobox.h"
+#include "../db/dbsetup.h"
+
+SetupComboBox::SetupComboBox(DatabaseManager *dbMan, QWidget *parent)
+    : EFComboBox(dbMan, parent)
+{
+    dataModelIndex_name = DbSetup::Setup_Name;
+    dataModelIndex_id = DbSetup::Setup_Id;
+    setModelColumn(dataModelIndex_name);
+
+}
+
diff --git a/src/widgets/setupcombobox.h b/src/widgets/setupcombobox.h
new file mode 100644 (file)
index 0000000..cc9b20c
--- /dev/null
@@ -0,0 +1,31 @@
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// 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.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef SETUPCOMBOBOX_H
+#define SETUPCOMBOBOX_H
+
+#include "efcombobox.h"
+
+class SetupComboBox : public EFComboBox
+{
+public:
+    SetupComboBox(DatabaseManager *dbMan, QWidget *parent);
+};
+
+#endif // SETUPCOMBOBOX_H