Now the SetupModel is in MainWindow class and a pointer is
authorMikko Keinänen <mikko.keinanen@gmail.com>
Thu, 16 Dec 2010 22:36:36 +0000 (00:36 +0200)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Thu, 16 Dec 2010 22:36:36 +0000 (00:36 +0200)
passed to SetupEditView and EmuLauncher. The data is in sync
in controls without refresh / updateData. TODO: Implement this
also for other models!

src/emulauncher.cpp
src/emulauncher.h
src/mainwindow.cpp
src/mainwindow.h
src/views/emufronteditview.h
src/views/setupeditview.cpp
src/views/setupeditview.h

index 327072a..1529b71 100644 (file)
@@ -36,8 +36,8 @@
 #include "emuhelper.h"
 #include "emufrontinputdialog.h"
 
-EmuLauncher::EmuLauncher(QErrorMessage *errorMessage, QWidget *parent, QString tmp) :
-    QWidget(parent), tmpDirPath(tmp), errorMessage(errorMessage)
+EmuLauncher::EmuLauncher(QErrorMessage *errorMessage, SetupModel *supModel, QWidget *parent, QString tmp) :
+    QWidget(parent), supModel(supModel), tmpDirPath(tmp), errorMessage(errorMessage)
 {
     emuHelper = new EmuHelper(this);
     initWidgets();
@@ -75,7 +75,7 @@ void EmuLauncher::initWidgets()
     micModel = new MediaImageContainerModel(this);
     micTable->setModel(micModel);
 
-    supModel = new SetupModel(this);
+    //supModel = new SetupModel(this);
     setupSelectBox = new QComboBox(this);
     setupSelectBox->setModel(supModel);
     setupSelectBox->setModelColumn(SetupModel::Setup_Name);
@@ -117,8 +117,8 @@ void EmuLauncher::updateMediaImageContainers()
 
     // 1. get selected platform and media type id
     QAbstractItemModel *setupAbsModel = setupSelectBox->model();
-    SetupModel *supModel = qobject_cast<SetupModel *>(setupAbsModel);
-    if (!supModel) return;
+    //SetupModel *supModel = qobject_cast<SetupModel *>(setupAbsModel);
+    //if (!supModel) return;
 
     QModelIndex supInd =
         supModel->index(setupSelectBox->currentIndex(), SetupModel::Setup_Id);
index 9c529cc..1c6c081 100644 (file)
@@ -41,7 +41,7 @@ class EmuLauncher : public QWidget
 {
 Q_OBJECT
 public:
-    EmuLauncher(QErrorMessage *, QWidget *parent = 0, QString tmp = ".");
+    EmuLauncher(QErrorMessage *, SetupModel *supModel, QWidget *parent = 0, QString tmp = ".");
     ~EmuLauncher();
     void updateData();
     void setTmpDirPath(QString);
index 25da5ad..c06633d 100644 (file)
@@ -39,6 +39,7 @@
 #include "databasemanager.h"
 #include "dbcreator.h"
 #include "dbconfig.h"
+#include "setupmodel.h"
 
 QString MainWindow::aboutStr = trUtf8(
         "<h2>EmuFront</h2>"
@@ -60,7 +61,8 @@ MainWindow::MainWindow(bool reset)
     if (tmpDirFilePath.isEmpty())
         tmpDirFilePath = QDir::homePath();
     qDebug() << "Temporary dir is " << tmpDirFilePath;
-    launcher = new EmuLauncher(errorMessage, this, tmpDirFilePath);
+    supModel = new SetupModel(this);
+    launcher = new EmuLauncher(errorMessage, supModel, this, tmpDirFilePath);
     setCentralWidget(launcher);
     createActions();
     createMenus();
@@ -234,9 +236,10 @@ void MainWindow::configureMediaImagePathss()
 
 void MainWindow::configureSetupss()
 {
+    //TODO: maybe a common setup model in MainWindow, so the data would be in sync without refresh with updateData!
     if (!setupMainView) {
-        setupMainView = new SetupEditView(this);
-        connect(setupMainView, SIGNAL(finished(int)), this, SLOT(updateData()));
+        setupMainView = new SetupEditView(supModel, this);
+        //connect(setupMainView, SIGNAL(finished(int)), this, SLOT(updateData()));
     }
     activateDialog(setupMainView);
 }
index b0d2bed..3a56a9b 100644 (file)
@@ -46,6 +46,7 @@ class EmuFrontDialog;
 class EmuLauncher;
 class DatFileUtil;
 class QErrorMessage;
+class SetupModel;
 
 class MainWindow : public QMainWindow
 {
@@ -138,6 +139,7 @@ private:
     EmuLauncher *launcher;
     QString tmpDirFilePath;
     QErrorMessage *errorMessage;
+    SetupModel *supModel;
 };
 
 #endif
index 8235a15..e2f7221 100644 (file)
@@ -17,7 +17,8 @@
 **
 ** You should have received a copy of the GNU General Public License
 ** along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
-*/#ifndef EMUFRONTDATADIALOG_H
+*/
+#ifndef EMUFRONTDATADIALOG_H
 #define EMUFRONTDATADIALOG_H
 
 #include "emufrontdialog.h"
index 07e88cb..397d20c 100644 (file)
 #include "mediatypemodel.h"
 #include <QSqlTableModel>
 
-SetupEditView::SetupEditView(QWidget *parent) :
-    EmuFrontEditView(parent)
+SetupEditView::SetupEditView(SetupModel *supModel, QWidget *parent) :
+    EmuFrontEditView(parent)//, model(supModel)
 {
-    model = new SetupModel(this);
+    model = supModel;
+    //model = new SetupModel(this);
     objectList->setModel(model);
     PlatformModel *plfModel = new PlatformModel(this);
     ComboBoxDelegate *platformDelegate = new ComboBoxDelegate(
index aafbfec..7bbac29 100644 (file)
 
 #include "emufronteditview.h"
 
+class SetupModel;
+
 class SetupEditView : public EmuFrontEditView
 {
     Q_OBJECT
 public:
-    SetupEditView(QWidget *parent = 0);
+    SetupEditView(SetupModel *supModel, QWidget *parent = 0);
 
 signals:
 
 public slots:
 
+private:
+
 };
 
 #endif // SETUPMAINVIEW_H