From 2553c1783d0e375903ffff23c6cfe6bf63e008a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mikko=20Kein=C3=A4nen?= Date: Fri, 17 Dec 2010 00:36:36 +0200 Subject: [PATCH] Now the SetupModel is in MainWindow class and a pointer is 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 | 10 +++++----- src/emulauncher.h | 2 +- src/mainwindow.cpp | 9 ++++++--- src/mainwindow.h | 2 ++ src/views/emufronteditview.h | 3 ++- src/views/setupeditview.cpp | 7 ++++--- src/views/setupeditview.h | 6 +++++- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/emulauncher.cpp b/src/emulauncher.cpp index 327072a..1529b71 100644 --- a/src/emulauncher.cpp +++ b/src/emulauncher.cpp @@ -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(setupAbsModel); - if (!supModel) return; + //SetupModel *supModel = qobject_cast(setupAbsModel); + //if (!supModel) return; QModelIndex supInd = supModel->index(setupSelectBox->currentIndex(), SetupModel::Setup_Id); diff --git a/src/emulauncher.h b/src/emulauncher.h index 9c529cc..1c6c081 100644 --- a/src/emulauncher.h +++ b/src/emulauncher.h @@ -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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 25da5ad..c06633d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -39,6 +39,7 @@ #include "databasemanager.h" #include "dbcreator.h" #include "dbconfig.h" +#include "setupmodel.h" QString MainWindow::aboutStr = trUtf8( "

EmuFront

" @@ -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); } diff --git a/src/mainwindow.h b/src/mainwindow.h index b0d2bed..3a56a9b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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 diff --git a/src/views/emufronteditview.h b/src/views/emufronteditview.h index 8235a15..e2f7221 100644 --- a/src/views/emufronteditview.h +++ b/src/views/emufronteditview.h @@ -17,7 +17,8 @@ ** ** You should have received a copy of the GNU General Public License ** along with EmuFront. If not, see . -*/#ifndef EMUFRONTDATADIALOG_H +*/ +#ifndef EMUFRONTDATADIALOG_H #define EMUFRONTDATADIALOG_H #include "emufrontdialog.h" diff --git a/src/views/setupeditview.cpp b/src/views/setupeditview.cpp index 07e88cb..397d20c 100644 --- a/src/views/setupeditview.cpp +++ b/src/views/setupeditview.cpp @@ -27,10 +27,11 @@ #include "mediatypemodel.h" #include -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( diff --git a/src/views/setupeditview.h b/src/views/setupeditview.h index aafbfec..7bbac29 100644 --- a/src/views/setupeditview.h +++ b/src/views/setupeditview.h @@ -22,16 +22,20 @@ #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 -- 1.7.9.5