summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-05-22 19:06:43 +0200
committerArno <am@disconnect.de>2010-05-22 19:06:43 +0200
commit8ea5721547c90eee695ed91c31908c31f643eabd (patch)
tree596c0f52c0ba76b26717741580b98914087c555b
parent1ec8aa7048416a3267ee3ff654d078739644296c (diff)
downloadSheMov-8ea5721547c90eee695ed91c31908c31f643eabd.tar.gz
SheMov-8ea5721547c90eee695ed91c31908c31f643eabd.tar.bz2
SheMov-8ea5721547c90eee695ed91c31908c31f643eabd.zip
Wizard for adding movies manually
Created a QWizard for adding movies manually. Works as expected, but cover management has to be added as last page.
-rw-r--r--actorwidget.h1
-rw-r--r--addmoviewizard.cpp182
-rw-r--r--addmoviewizard.h61
3 files changed, 244 insertions, 0 deletions
diff --git a/actorwidget.h b/actorwidget.h
index fec8b25..864d300 100644
--- a/actorwidget.h
+++ b/actorwidget.h
@@ -18,6 +18,7 @@ class ActorModel;
class ActorWidget : public QWidget {
Q_OBJECT
+ Q_PROPERTY(QStringList actors READ actors());
public:
ActorWidget(QWidget *parent = 0);
~ActorWidget() {};
diff --git a/addmoviewizard.cpp b/addmoviewizard.cpp
new file mode 100644
index 0000000..3855b81
--- /dev/null
+++ b/addmoviewizard.cpp
@@ -0,0 +1,182 @@
+/*
+ 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 <QGridLayout>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QSpinBox>
+#include <QComboBox>
+#include <QModelIndex>
+
+#include "addmoviewizard.h"
+#include "listmodelsingleton.h"
+#include "actorwidget.h"
+#include "listeditor.h"
+#include "moviemodelsingleton.h"
+#include "moviemodel.h"
+
+
+AddMovieWizard::AddMovieWizard(QWidget *parent) : QWizard(parent){
+ addPage(new MovieNamePage);
+ addPage(new MovieActorPage);
+ addPage(new MovieGenrePage);
+}
+
+void AddMovieWizard::accept(){
+ QString movieName = field("movieName").toString();
+ int partno = field("partNo").toInt();
+ int seriesno = field("seriesNo").toInt();
+ int quality = field("quality").toInt();
+ QStringList actors = field("actors").toStringList();
+ QString genre = field("genre").toString();
+ int dvdno = field("dvdNo").toInt();
+
+ MovieModel *model = MovieModelSingleton::instance();
+ ListModel *genreModel = ListModelSingleton::instance()->model("genre");
+ ListModel *actorModel = ListModelSingleton::instance()->model("actor");
+
+ QList<QVariant> movieData;
+ movieData << movieName;
+ for(int i = 1; i < MovieItem::NumRows; ++i){
+ movieData << QVariant();
+ }
+ QString md5(32, '0');
+ QModelIndex genreIdx = genreModel->index(genre);
+ int genreId = genreModel->defaultId();
+ if(genreIdx.isValid()){
+ genreId = genreIdx.data(ListModel::IdRole).toInt();
+ }
+
+ QList<QVariant> actorIds;
+ foreach(QVariant a, actors){
+ QModelIndex actorIdx = actorModel->index(a.toString());
+ if(actorIdx.isValid()){
+ actorIds << actorIdx.data(ListModel::IdRole).toInt();
+ }
+ }
+
+ movieData[MovieItem::Md5Sum] = md5;
+ movieData[MovieItem::Genre] = genreId;
+ movieData[MovieItem::Dvd] = dvdno;
+ movieData[MovieItem::Filename] = tr("(DVD)");
+ movieData[MovieItem::Size] = Q_INT64_C(4707319808);
+ movieData[MovieItem::Quality] = quality;
+ movieData[MovieItem::SeriesNo] = seriesno;
+ movieData[MovieItem::PartNo] = partno;
+ model->addMovie(movieData, actorIds, QList<CoverItem>());
+
+ QDialog::accept();
+}
+
+/* MovieNamePage */
+MovieNamePage::MovieNamePage(QWidget *parent) : QWizardPage(parent){
+ setTitle(tr("Basic Movie Information"));
+ setSubTitle(tr("Enter basic Movie information here. The series no. is the series part, e.g. Rogue adventures 14. The part no. only has to be set if the movie is split in several parts. Set -1 for none."));
+ setPixmap(QWizard::LogoPixmap, QPixmap(":/shemov.png"));
+
+ QGridLayout *mainLayout = new QGridLayout;
+ QLabel *l1 = new QLabel(tr("Movie name"));
+ mainLayout->addWidget(l1, 0, 0);
+ mMovieName = new QLineEdit;
+ mainLayout->addWidget(mMovieName, 0, 1);
+ QLabel *l2 = new QLabel(tr("Series no."));
+ mainLayout->addWidget(l2, 1, 0);
+ mSeriesNo = new QSpinBox;
+ mSeriesNo->setMinimum(-1);
+ mSeriesNo->setValue(-1);
+ mainLayout->addWidget(mSeriesNo, 1, 1);
+ QLabel *l3 = new QLabel(tr("Part no."));
+ mainLayout->addWidget(l3, 2, 0);
+ mPartNo = new QSpinBox;
+ mPartNo->setMinimum(-1);
+ mPartNo->setValue(-1);
+ mainLayout->addWidget(mPartNo, 2, 1);
+ QLabel *l4 = new QLabel(tr("Quality"));
+ mainLayout->addWidget(l4, 3, 0);
+ mQuality = new QSpinBox;
+ mQuality->setMaximum(10);
+ mQuality->setMinimum(0);
+ mQuality->setValue(10);
+ mainLayout->addWidget(mQuality, 3, 1);
+ MovieModel *movieModel = MovieModelSingleton::instance();
+ int dvdno = movieModel->maxValue(MovieItem::Dvd).toInt();
+ QLabel *l5 = new QLabel(tr("DVD no."));
+ mainLayout->addWidget(l5, 4, 0);
+ mDvdNo = new QSpinBox;
+ mDvdNo->setMinimum(0);
+ mDvdNo->setValue(++dvdno);
+ mainLayout->addWidget(mDvdNo, 4, 1);
+
+ registerField("movieName*", mMovieName);
+ registerField("seriesNo", mSeriesNo);
+ registerField("partNo", mPartNo);
+ registerField("quality", mQuality);
+ registerField("dvdNo", mDvdNo);
+
+ setLayout(mainLayout);
+}
+
+/* MovieActorPage */
+MovieActorPage::MovieActorPage(QWidget *parent) : QWizardPage(parent){
+ setTitle(tr("Actors"));
+ setSubTitle(tr("Enter actors here"));
+ setPixmap(QWizard::LogoPixmap, QPixmap(":/shemov.png"));
+
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mActorWidget = new ActorWidget;
+ mainLayout->addWidget(mActorWidget);
+ QVBoxLayout *actorEditorLayout = new QVBoxLayout;
+ QLabel *l1 = new QLabel(" ");
+ actorEditorLayout->addWidget(l1);
+ ListEditor *actorsEditor = new ListEditor(ListModelSingleton::instance()->model("actor"));
+ actorEditorLayout->addWidget(actorsEditor);
+ actorEditorLayout->addStretch();
+ mainLayout->addLayout(actorEditorLayout);
+ connect(actorsEditor, SIGNAL(itemAdded(const QString &)), this, SLOT(addActor(const QString &)));
+
+ registerField("actors", mActorWidget, "actors");
+
+ setLayout(mainLayout);
+}
+
+void MovieActorPage::addActor(const QString &actor){
+ mActorWidget->addActor(actor);
+}
+
+/* MovieGenrePage */
+MovieGenrePage::MovieGenrePage(QWidget *parent) : QWizardPage(parent){
+ setTitle(tr("Genre"));
+ setSubTitle(tr("Set the genre of the movie"));
+ setPixmap(QWizard::LogoPixmap, QPixmap(":/shemov.png"));
+
+ QVBoxLayout *selectionLayout = new QVBoxLayout;
+ QLabel *l1 = new QLabel(tr("Select genre"));
+ selectionLayout->addWidget(l1);
+ mGenre = new QComboBox;
+ mGenre->setModel(ListModelSingleton::instance()->model("genre"));
+ int idx = mGenre->findText("shemale");
+ if(idx != -1){
+ mGenre->setCurrentIndex(idx);
+ }
+ selectionLayout->addWidget(mGenre);
+ selectionLayout->addStretch();
+
+ QVBoxLayout *editorLayout = new QVBoxLayout;
+ ListEditor *genreEditor = new ListEditor(ListModelSingleton::instance()->model("genre"));
+ editorLayout->addWidget(genreEditor);
+ editorLayout->addStretch();
+
+ registerField("genre", mGenre, "currentText");
+
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->addLayout(selectionLayout);
+ mainLayout->addStretch();
+ mainLayout->addLayout(editorLayout);
+ setLayout(mainLayout);
+}
diff --git a/addmoviewizard.h b/addmoviewizard.h
new file mode 100644
index 0000000..adc293c
--- /dev/null
+++ b/addmoviewizard.h
@@ -0,0 +1,61 @@
+/*
+ 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 ADDMOVIEWIZARD_H
+#define ADDMOVIEWIZARD_H
+
+#include <QWizard>
+#include <QWizardPage>
+
+class QLineEdit;
+class QSpinBox;
+class QComboBox;
+class ActorWidget;
+
+class AddMovieWizard : public QWizard {
+ Q_OBJECT
+ public:
+ explicit AddMovieWizard(QWidget *parent = 0);
+ void accept();
+};
+
+class MovieNamePage : public QWizardPage {
+ Q_OBJECT
+ public:
+ explicit MovieNamePage(QWidget *parent = 0);
+
+ private:
+ QLineEdit *mMovieName;
+ QSpinBox *mSeriesNo;
+ QSpinBox *mPartNo;
+ QSpinBox *mQuality;
+ QSpinBox *mDvdNo;
+};
+
+class MovieActorPage : public QWizardPage {
+ Q_OBJECT
+ public:
+ explicit MovieActorPage(QWidget *parent = 0);
+
+ private slots:
+ void addActor(const QString &actor);
+
+ private:
+ ActorWidget *mActorWidget;
+
+};
+
+class MovieGenrePage : public QWizardPage {
+ Q_OBJECT
+ public:
+ explicit MovieGenrePage(QWidget *parent = 0);
+
+ private:
+ QComboBox *mGenre;
+};
+
+#endif