1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
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);
}
|