From 1ec8aa7048416a3267ee3ff654d078739644296c Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 22 May 2010 16:53:14 +0200 Subject: Use singletons for models Created singletons for the ListModel* and MovieModel*. There should only be one of each and they were passed around quite a lot. --- shemov.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'shemov.cpp') diff --git a/shemov.cpp b/shemov.cpp index 2e3ab90..2bfe8c0 100644 --- a/shemov.cpp +++ b/shemov.cpp @@ -42,6 +42,8 @@ #include "coverarchiveeditor.h" #include "statisticsdialog.h" #include "filesystemfileproxy.h" +#include "moviemodelsingleton.h" +#include "listmodelsingleton.h" SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), mOpenWithGroupFS(0), mOpenWithGroupAV(0) { qApp->setWindowIcon(QIcon(":/shemov.png")); @@ -60,9 +62,9 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla QMessageBox::critical(this, tr("Error"), tr("Could not open database. Please configure the database and restart the program")); } - mMovieModel = new MovieModel(this); - mGenreModel = new ListModel("genre", this); - mActorModel = new ListModel("actor", this); + mMovieModel = MovieModelSingleton::instance(); + mGenreModel = ListModelSingleton::instance()->model("genre"); + mActorModel = ListModelSingleton::instance()->model("actor"); mFSWidget = new FilesystemWidget; setWindowTitle(mFSWidget->windowTitle()); @@ -73,8 +75,7 @@ SheMov::SheMov(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, fla mTab->addTab(mAVWidget, tr("Archive")); connect(mAVWidget, SIGNAL(windowTitle(const QString &)), this, SLOT(newWindowTitle(const QString &))); - mAEdit = new ArchiveEditDialog(mGenreModel, mActorModel, this); - mAEdit->setMovieModel(mMovieModel); + mAEdit = new ArchiveEditDialog(this); mFSWidget->setArchiveDialog(mAEdit); mAItemEdit = new EditArchiveItemDialog(mGenreModel, mActorModel, mMovieModel, this); -- cgit v1.2.3-70-g09d2