From cac2a8a8941985527f0d8714528ca725d8886e9b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mikko=20Kein=C3=A4nen?= Date: Mon, 20 Dec 2010 00:51:38 +0200 Subject: [PATCH] PlatformModel and MediaTypeModel instances are shared from MainWindow. --- doc/tests.txt | 42 +++++++++++++++++++++++++++++++++++---- src/mainwindow.cpp | 12 ++++++----- src/mainwindow.h | 6 +++++- src/views/mediatypeeditview.cpp | 4 ++-- src/views/mediatypeeditview.h | 4 +++- src/views/platformeditview.cpp | 5 +++-- src/views/platformeditview.h | 8 ++++++-- src/views/setupeditview.cpp | 7 ++----- src/views/setupeditview.h | 7 +++++-- 9 files changed, 71 insertions(+), 24 deletions(-) diff --git a/doc/tests.txt b/doc/tests.txt index 93af1c3..cbee2ca 100644 --- a/doc/tests.txt +++ b/doc/tests.txt @@ -1,5 +1,5 @@ 1. Start EmuFront ------------------ +================= - if database already exists move/remove it: $ mv ~/emufront.db.sqlite ~/emufront.db.sqlite.bak @@ -14,14 +14,14 @@ > empty area for filtered media image containers is shown 2. Set temporary directory --------------------------- +========================== - Select 'Config->Temp dir' > A file selector is opened, only folders can be selected - Select a folder > A messagebox is shown telling that the Temporary directory has been updated to selected folder. 3. Platform ------------ +=========== 3.1 Open platform editor ------------------------ @@ -200,7 +200,41 @@ Add a four platforms according to instructions in part 3.2 > Platform was removed from the table view 4. Media Types --------------- +============== + +5. Setups +========= + +Delete all the platforms and media types first. + +5.1 Open setup editor +--------------------- +- Select 'Config->Configure setups' +> New view is opened with a title describing about setting setups + > 'Add' and 'OK' buttons active + > 'Edit' and 'Delete' buttons disabled + +5.2 Add setup +------------- + +5.2.1 Add setup with no platforms and media types configured +------------------------------------------------------------ +- Click Add button +> + +5.2.2 Add setup with no platforms configured +-------------------------------------------- + +5.2.3 Add setup with no media types configured +---------------------------------------------- + +5.2.3 Add setup with a single media type and a single platform configured +------------------------------------------------------------------------- + +5.2.3 Add setup with multiple media types and platforms configured +------------------------------------------------------------------ + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7f530ac..dda730e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -42,6 +42,8 @@ #include "dbcreator.h" #include "dbconfig.h" #include "setupmodel.h" +#include "platformmodel.h" +#include "mediatypemodel.h" QString MainWindow::aboutStr = trUtf8( "

EmuFront

" @@ -64,6 +66,8 @@ MainWindow::MainWindow(bool reset) tmpDirFilePath = QDir::homePath(); qDebug() << "Temporary dir is " << tmpDirFilePath; supModel = new SetupModel(this); + plfModel = new PlatformModel(this); + mdtModel = new MediaTypeModel(this); emuModel = new ExternalExecutableModel(this); launcher = new EmuLauncher(errorMessage, supModel, emuModel, this, tmpDirFilePath); setCentralWidget(launcher); @@ -179,7 +183,7 @@ void MainWindow::createActions() void MainWindow::configurePlatformss() { if (!plfDialog) { - plfDialog = new PlatformEditView(this); + plfDialog = new PlatformEditView(plfModel, this); connect(plfDialog, SIGNAL(finished(int)), this, SLOT(updateData())); } activateDialog(plfDialog); @@ -200,7 +204,7 @@ void MainWindow::configureMediaTypess() { if (!mdtDialog) { - mdtDialog = new MediaTypeEditView(this); + mdtDialog = new MediaTypeEditView(mdtModel, this); connect(mdtDialog, SIGNAL(finished(int)), this, SLOT(updateData())); } activateDialog(mdtDialog); @@ -239,10 +243,8 @@ 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(supModel, this); - //connect(setupMainView, SIGNAL(finished(int)), this, SLOT(updateData())); + setupMainView = new SetupEditView(plfModel, mdtModel, supModel, this); } activateDialog(setupMainView); } diff --git a/src/mainwindow.h b/src/mainwindow.h index d417693..2b6ff4a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -49,6 +49,8 @@ class DatFileUtil; class QErrorMessage; class SetupModel; class ExternalExecutableModel; +class PlatformModel; +class MediaTypeModel; class MainWindow : public QMainWindow { @@ -142,7 +144,9 @@ private: QString tmpDirFilePath; QErrorMessage *errorMessage; SetupModel *supModel; - ExternalExecutableModel *emuModel; + ExternalExecutableModel *emuModel; + PlatformModel *plfModel; + MediaTypeModel *mdtModel; }; #endif diff --git a/src/views/mediatypeeditview.cpp b/src/views/mediatypeeditview.cpp index 39dc81f..5e4aa7d 100644 --- a/src/views/mediatypeeditview.cpp +++ b/src/views/mediatypeeditview.cpp @@ -22,11 +22,11 @@ #include "mediatypeeditview.h" #include "mediatypemodel.h" -MediaTypeEditView::MediaTypeEditView(QWidget *parent) : +MediaTypeEditView::MediaTypeEditView(MediaTypeModel *mdtModel, QWidget *parent) : EmuFrontFileObjectEditView(parent) { setWindowTitle(tr("Set media types")); - model = new MediaTypeModel(this); + model = mdtModel; objectList->setModel(model); postInit(); } diff --git a/src/views/mediatypeeditview.h b/src/views/mediatypeeditview.h index abdcc7d..03daffd 100644 --- a/src/views/mediatypeeditview.h +++ b/src/views/mediatypeeditview.h @@ -22,11 +22,13 @@ #include "emufrontfileobjecteditview.h" +class MediaTypeModel; + class MediaTypeEditView : public EmuFrontFileObjectEditView { Q_OBJECT public: - MediaTypeEditView(QWidget *parent = 0); + MediaTypeEditView(MediaTypeModel *mdtModel, QWidget *parent = 0); }; #endif // MEDIATYPEMAINDIALOG_H diff --git a/src/views/platformeditview.cpp b/src/views/platformeditview.cpp index efc4fbb..73acc81 100644 --- a/src/views/platformeditview.cpp +++ b/src/views/platformeditview.cpp @@ -18,15 +18,16 @@ ** You should have received a copy of the GNU General Public License ** along with EmuFront. If not, see . */ + #include #include "platformeditview.h" #include "platformmodel.h" -PlatformEditView::PlatformEditView(QWidget *parent) : +PlatformEditView::PlatformEditView(PlatformModel *plfModel, QWidget *parent) : EmuFrontFileObjectEditView(parent) { setWindowTitle(tr("Set emulated platforms")); - model = new PlatformModel(this); + model = plfModel; objectList->setModel(model); postInit(); } diff --git a/src/views/platformeditview.h b/src/views/platformeditview.h index 6636206..6c25d8b 100644 --- a/src/views/platformeditview.h +++ b/src/views/platformeditview.h @@ -17,16 +17,20 @@ ** ** You should have received a copy of the GNU General Public License ** along with EmuFront. If not, see . -*/#ifndef PLATFORMMAINDIALOG_H +*/ + +#ifndef PLATFORMMAINDIALOG_H #define PLATFORMMAINDIALOG_H #include "emufrontfileobjecteditview.h" +class PlatformModel; + class PlatformEditView : public EmuFrontFileObjectEditView { Q_OBJECT public: - PlatformEditView(QWidget *parent = 0); + PlatformEditView(PlatformModel *plfModel, QWidget *parent = 0); }; #endif // PLATFORMMAINDIALOG_H diff --git a/src/views/setupeditview.cpp b/src/views/setupeditview.cpp index 900ee22..fc461ab 100644 --- a/src/views/setupeditview.cpp +++ b/src/views/setupeditview.cpp @@ -27,14 +27,12 @@ #include "mediatypemodel.h" #include -SetupEditView::SetupEditView(SetupModel *supModel, QWidget *parent) : - EmuFrontEditView(parent)//, model(supModel) +SetupEditView::SetupEditView(PlatformModel *plfModel, MediaTypeModel *mdtModel, SetupModel *supModel, QWidget *parent) : + EmuFrontEditView(parent), plfModel(plfModel), mdtModel(mdtModel) { setWindowTitle(tr("Setups")); model = supModel; - //model = new SetupModel(this); objectList->setModel(model); - PlatformModel *plfModel = new PlatformModel(this); ComboBoxDelegate *platformDelegate = new ComboBoxDelegate( plfModel, PlatformModel::EmuFrontFileObject_Id, @@ -42,7 +40,6 @@ SetupEditView::SetupEditView(SetupModel *supModel, QWidget *parent) : this ); objectList->setItemDelegateForColumn(SetupModel::Setup_PlatformId, platformDelegate); - MediaTypeModel *mdtModel = new MediaTypeModel(this); ComboBoxDelegate *mediatypeDelegate = new ComboBoxDelegate( mdtModel, MediaTypeModel::EmuFrontFileObject_Id, diff --git a/src/views/setupeditview.h b/src/views/setupeditview.h index 7bbac29..b12d128 100644 --- a/src/views/setupeditview.h +++ b/src/views/setupeditview.h @@ -22,20 +22,23 @@ #include "emufronteditview.h" +class PlatformModel; +class MediaTypeModel; class SetupModel; class SetupEditView : public EmuFrontEditView { Q_OBJECT public: - SetupEditView(SetupModel *supModel, QWidget *parent = 0); + SetupEditView(PlatformModel *plfModel, MediaTypeModel *mdtModel, SetupModel *supModel, QWidget *parent = 0); signals: public slots: private: - + PlatformModel *plfModel; + MediaTypeModel *mdtModel; }; #endif // SETUPMAINVIEW_H -- 1.7.9.5