diff options
-rw-r--r-- | archiveeditdialog.cpp | 12 | ||||
-rw-r--r-- | archiveeditdialog.h | 3 | ||||
-rw-r--r-- | archivefilewidget.cpp | 23 | ||||
-rw-r--r-- | archivefilewidget.h | 5 | ||||
-rw-r--r-- | archiveviewwidget.cpp | 7 | ||||
-rw-r--r-- | listmodelsingleton.cpp | 27 | ||||
-rw-r--r-- | listmodelsingleton.h | 28 | ||||
-rw-r--r-- | moviemodelsingleton.cpp | 20 | ||||
-rw-r--r-- | moviemodelsingleton.h | 24 | ||||
-rw-r--r-- | shemov.cpp | 11 | ||||
-rw-r--r-- | shemov.pro | 10 |
11 files changed, 136 insertions, 34 deletions
diff --git a/archiveeditdialog.cpp b/archiveeditdialog.cpp index 458bbbf..35f1ef2 100644 --- a/archiveeditdialog.cpp +++ b/archiveeditdialog.cpp @@ -28,8 +28,15 @@ #include "moviemodel.h" #include "helper.h" #include "coveritem.h" +#include "listmodelsingleton.h" +#include "moviemodelsingleton.h" + +ArchiveEditDialog::ArchiveEditDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { + //setup + mGenreModel = ListModelSingleton::instance()->model("genre"); + mActorsModel = ListModelSingleton::instance()->model("actor"); + mMovieModel = MovieModelSingleton::instance(); -ArchiveEditDialog::ArchiveEditDialog(ListModel *genre, ListModel *actors, QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), mGenreModel(genre), mActorsModel(actors){ QSplitter *hSplitter = new QSplitter(Qt::Horizontal); QWidget *editorWidget = new QWidget; QVBoxLayout *editorLayout = new QVBoxLayout; @@ -58,9 +65,6 @@ ArchiveEditDialog::ArchiveEditDialog(ListModel *genre, ListModel *actors, QWidge //archive editor mFileWidget = new ArchiveFileWidget; - mFileWidget->setMovieModel(mMovieModel); - mFileWidget->setGenreModel(mGenreModel); - mFileWidget->setActorsModel(mActorsModel); connect(mActorsEditor, SIGNAL(itemAdded(const QString &)), mFileWidget, SLOT(setActor(const QString &))); //join splitters diff --git a/archiveeditdialog.h b/archiveeditdialog.h index eba4824..39e3dc9 100644 --- a/archiveeditdialog.h +++ b/archiveeditdialog.h @@ -23,10 +23,9 @@ class ListModel; class ArchiveEditDialog : public QDialog { Q_OBJECT public: - ArchiveEditDialog(ListModel *genre, ListModel *actors, QWidget *parent = 0, Qt::WindowFlags f = 0); + ArchiveEditDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); ~ArchiveEditDialog() {}; void setFiles(const QStringList &files); - void setMovieModel(MovieModel *model) { mMovieModel = model; }; private slots: void archive(); diff --git a/archivefilewidget.cpp b/archivefilewidget.cpp index 8ddad26..818ac43 100644 --- a/archivefilewidget.cpp +++ b/archivefilewidget.cpp @@ -24,8 +24,14 @@ #include "helper.h" #include "actorwidget.h" #include "fileinfomodel.h" - -ArchiveFileWidget::ArchiveFileWidget(MovieModel *model, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) , mModel(model){ +#include "listmodelsingleton.h" +#include "moviemodelsingleton.h" + +ArchiveFileWidget::ArchiveFileWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f){ + //setup + mModel = MovieModelSingleton::instance(); + mGenreModel = ListModelSingleton::instance()->model("genre"); + mActorsModel = ListModelSingleton::instance()->model("actor"); QVBoxLayout *mainLayout = new QVBoxLayout; //selected files @@ -89,19 +95,6 @@ ArchiveFileWidget::ArchiveFileWidget(MovieModel *model, QWidget *parent, Qt::Win setMinimumWidth(600); } -void ArchiveFileWidget::setMovieModel(MovieModel *model){ - mModel = model; -} - -void ArchiveFileWidget::setGenreModel(ListModel *model){ - mGenreModel = model; - mGenre->setModel(mGenreModel); -} - -void ArchiveFileWidget::setActorsModel(ListModel *model){ - mActorsModel = model; -} - void ArchiveFileWidget::setFiles(const QStringList &files){ mFileList = files; mInfoModel->clear(); diff --git a/archivefilewidget.h b/archivefilewidget.h index 64feb25..499ac45 100644 --- a/archivefilewidget.h +++ b/archivefilewidget.h @@ -27,11 +27,8 @@ class FileInfoModel; class ArchiveFileWidget : public QWidget { Q_OBJECT public: - ArchiveFileWidget(MovieModel *model = 0, QWidget *parent = 0, Qt::WindowFlags f = 0); + ArchiveFileWidget(QWidget *parent = 0, Qt::WindowFlags f = 0); ~ArchiveFileWidget() {}; - void setMovieModel(MovieModel *model); - void setGenreModel(ListModel *model); - void setActorsModel(ListModel *model); void setFiles(const QStringList &files); const QList<int> actorIds() const; int genreId() const; diff --git a/archiveviewwidget.cpp b/archiveviewwidget.cpp index 42532c5..59ec354 100644 --- a/archiveviewwidget.cpp +++ b/archiveviewwidget.cpp @@ -32,6 +32,7 @@ #include "textenterdialog.h" #include "helper.h" #include "moviepropertiesdialog.h" +#include "addmoviewizard.h" ArchiveViewWidget::ArchiveViewWidget(MovieModel *model, ListModel *genre, ListModel *actors, QWidget *parent) : QWidget(parent), mMovieModel(model), mGenreModel(genre), mActorsModel(actors), mSize(0){ //filter bar @@ -110,7 +111,9 @@ void ArchiveViewWidget::editCovers(){ } void ArchiveViewWidget::addMovie(){ - TextEnterDialog dlg(tr("Enter movie title"), this); + AddMovieWizard wiz(this); + wiz.exec(); + /*TextEnterDialog dlg(tr("Enter movie title"), this); dlg.exec(); QString title; if(dlg.result() == QDialog::Accepted){ @@ -147,7 +150,7 @@ void ArchiveViewWidget::addMovie(){ movieData[MovieItem::Quality] = 0; movieData[MovieItem::SeriesNo] = seriesno; movieData[MovieItem::PartNo] = -1; - mMovieModel->addMovie(movieData, QList<QVariant>(), QList<CoverItem>()); + mMovieModel->addMovie(movieData, QList<QVariant>(), QList<CoverItem>());*/ } void ArchiveViewWidget::showMovie(const QModelIndex &movie){ diff --git a/listmodelsingleton.cpp b/listmodelsingleton.cpp new file mode 100644 index 0000000..69d028d --- /dev/null +++ b/listmodelsingleton.cpp @@ -0,0 +1,27 @@ +/* + This program 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 + 2 of the License, or (at your option) any later version. +*/ + +#include "listmodelsingleton.h" + +ListModelSingleton *ListModelSingleton::mInstance = 0; + +ListModelSingleton::ListModelSingleton() {} + +ListModelSingleton *ListModelSingleton::instance(){ + if(mInstance == 0){ + mInstance = new ListModelSingleton(); + } + return mInstance; +} + +ListModel* ListModelSingleton::model(const QString &which){ + if(!mModels.contains(which)){ + ListModel *newModel = new ListModel(which, 0); + mModels.insert(which, newModel); + } + return mModels.value(which); +} diff --git a/listmodelsingleton.h b/listmodelsingleton.h new file mode 100644 index 0000000..f67bf46 --- /dev/null +++ b/listmodelsingleton.h @@ -0,0 +1,28 @@ +/* + This program 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 + 2 of the License, or (at your option) any later version. +*/ + +#ifndef LISTMODELSINGLETON_H +#define LISTMODELSINGLETON_H + +#include <QHash> + +#include "listmodel.h" + +class ListModelSingleton { + public: + static ListModelSingleton *instance(); + ListModel *model(const QString &which); + + private: + ListModelSingleton(); + ListModelSingleton(const ListModelSingleton &other); + ListModelSingleton & operator=(const ListModelSingleton &other); + QHash<QString, ListModel*> mModels; + static ListModelSingleton *mInstance; +}; + +#endif // LISTMODELSINGLETON_H diff --git a/moviemodelsingleton.cpp b/moviemodelsingleton.cpp new file mode 100644 index 0000000..4300de1 --- /dev/null +++ b/moviemodelsingleton.cpp @@ -0,0 +1,20 @@ +/* + This program 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 + 2 of the License, or (at your option) any later version. +*/ + +#include "moviemodelsingleton.h" +#include "moviemodel.h" + +MovieModel *MovieModelSingleton::mInstance = 0; + +MovieModelSingleton::MovieModelSingleton() {} + +MovieModel *MovieModelSingleton::instance() { + if(!mInstance){ + mInstance = new MovieModel; + } + return mInstance; +} diff --git a/moviemodelsingleton.h b/moviemodelsingleton.h new file mode 100644 index 0000000..a19dc45 --- /dev/null +++ b/moviemodelsingleton.h @@ -0,0 +1,24 @@ +/* + This program 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 + 2 of the License, or (at your option) any later version. +*/ + +#ifndef MOVIEMODELSINGLETON_H +#define MOVIEMODELSINGLETON_H + +class MovieModel; + +class MovieModelSingleton { + public: + static MovieModel *instance(); + + private: + MovieModelSingleton(); + MovieModelSingleton(const MovieModelSingleton &other); + MovieModelSingleton & operator=(const MovieModelSingleton &other); + static MovieModel *mInstance; +}; + +#endif @@ -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); @@ -39,7 +39,10 @@ SOURCES = main.cpp \ fileinfomodel.cpp \ actorcountmodel.cpp \ graphbarwidget.cpp \ - programconfigurator.cpp + programconfigurator.cpp \ + addmoviewizard.cpp \ + listmodelsingleton.cpp \ + moviemodelsingleton.cpp HEADERS = listitem.h \ listmodel.h \ movieitem.h \ @@ -74,6 +77,9 @@ HEADERS = listitem.h \ fileinfomodel.h \ actorcountmodel.h \ graphbarwidget.h \ - programconfigurator.h + programconfigurator.h \ + addmoviewizard.h \ + listmodelsingleton.h \ + moviemodelsingleton.h LIBS += -lmagic RESOURCES = shemov.qrc |