summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2010-08-07 19:57:16 +0200
committerArno <am@disconnect.de>2010-08-07 19:57:16 +0200
commit40cedb64e32383f488000f89c2084c2bda98310f (patch)
tree7a605eca9479e3573d64262ea9ca9d209113cb59
parentef7524a3bb1ea0b1ec5e935c089925277ca278bf (diff)
downloadSheMov-40cedb64e32383f488000f89c2084c2bda98310f.tar.gz
SheMov-40cedb64e32383f488000f89c2084c2bda98310f.tar.bz2
SheMov-40cedb64e32383f488000f89c2084c2bda98310f.zip
Bugfix in NewMovieWizard
Make Part no work in NewMovieWizard. The logic for this was totally borked. Well, it was not really present. One could only assign one Part number to all files.
-rw-r--r--newmoviewizard.cpp47
-rw-r--r--newmoviewizard.h10
2 files changed, 44 insertions, 13 deletions
diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp
index df5c594..6d21a5b 100644
--- a/newmoviewizard.cpp
+++ b/newmoviewizard.cpp
@@ -81,12 +81,13 @@ void NewMovieWizard::accept(){
if(onDvd){
dvdNo = field("dvdNo").toInt();
}
- int partNo = field("partNo").toInt();
+ //int partNo = field("partNo").toInt();
QHash<QString, int> fileData = wizardModel->files();
QHash<QString, int>::const_iterator it = fileData.constBegin();
while(it != fileData.constEnd()){
QString path = it.key();
int type = it.value();
+ int partNo = wizardModel->filesPart(path);
if(filesModel->addFile(path, type, quality, partNo, seriesPartId, dvdNo)){
QString md5sum = Helper::md5Sum(path);
Helper::moveToArchive(path, md5sum);
@@ -94,7 +95,7 @@ void NewMovieWizard::accept(){
++it;
}
if(onDvd){
- filesModel->addFile(tr("DVD"), FilesTreeModel::Movie, quality, partNo, seriesPartId, dvdNo);
+ filesModel->addFile(tr("DVD"), FilesTreeModel::Movie, quality, -1, seriesPartId, dvdNo);
}
//handle actors
@@ -122,7 +123,7 @@ MovieInfoPage::MovieInfoPage(QWidget *parent) : QWizardPage(parent){
setPixmap(QWizard::LogoPixmap, QPixmap(":/shemov.png"));
//files model setup
- QStringList modelHeaders = QStringList() << tr("File name") << tr("Size") << tr("File Type") << tr("Full path");
+ QStringList modelHeaders = QStringList() << tr("File name") << tr("Size") << tr("File Type") << tr("Part") << tr("Full path");
mFileModel = new WizardTreeModel(modelHeaders, this);
initModel();
@@ -173,7 +174,8 @@ MovieInfoPage::MovieInfoPage(QWidget *parent) : QWizardPage(parent){
QLabel *l4 = new QLabel(tr("&Part no."));
mPartno = new QSpinBox;
l4->setBuddy(mPartno);
- mPartno->setMinimum(1);
+ mPartno->setMinimum(-1);
+ connect(mPartno, SIGNAL(valueChanged(int)), this, SLOT(seriesPartChanged(int)));
numberLayout->addWidget(l4);
numberLayout->addWidget(mPartno);
QLabel *l5 = new QLabel(tr("&Quality"));
@@ -241,7 +243,7 @@ void MovieInfoPage::addFiles(){
if(fi.exists()){
QList<QVariant> itemData;
QModelIndex parent = QModelIndex();
- itemData << fi.fileName() << fi.size() << QVariant() << fi.absoluteFilePath();
+ itemData << fi.fileName() << fi.size() << QVariant() << QVariant() << fi.absoluteFilePath();
QString mimeType = Helper::mimeType(fi.absoluteFilePath());
if(mimeType.startsWith("video")){
itemData[WizardTreeModel::FileType] = WizardTreeModel::Movie;
@@ -297,6 +299,19 @@ void MovieInfoPage::typeChanged(QString type){
}
+void MovieInfoPage::seriesPartChanged(int partNo){
+ QModelIndexList selected = mFileView->selectionModel()->selectedRows();
+ if(selected.isEmpty()){
+ return;
+ }
+ //int partNo = mPartno->value();
+ QModelIndex item = selected.at(0);
+ if(item.data(WizardTreeModel::FileTypeRole).toInt() == WizardTreeModel::Movie){
+ QModelIndex seriesPartIdx = mFileModel->index(item.row(), WizardTreeModel::FilePart, item.parent());
+ mFileModel->setData(seriesPartIdx, partNo, Qt::EditRole);
+ }
+}
+
void MovieInfoPage::setNextDvdNo(){
SeriesTreeModel *seriesTreeModel = static_cast<SeriesTreeModel*>(SmGlobals::instance()->model("SeriesModel"));
int nextdvd = seriesTreeModel->findNextDvdNo();
@@ -304,10 +319,10 @@ void MovieInfoPage::setNextDvdNo(){
}
void MovieInfoPage::initModel(){
- SmTreeItem *root = new SmTreeItem(4);
- mMoviesItem= new SmTreeItem(QList<QVariant>() << tr("Movie files") << QVariant() << QVariant() << QVariant(), root);
+ SmTreeItem *root = new SmTreeItem(5);
+ mMoviesItem= new SmTreeItem(QList<QVariant>() << tr("Movie files") << QVariant() << QVariant() << QVariant() << QVariant(), root);
root->appendChild(mMoviesItem);
- mCoversItem = new SmTreeItem(QList<QVariant>() << tr("Cover files") << QVariant() << QVariant() << QVariant(), root);
+ mCoversItem = new SmTreeItem(QList<QVariant>() << tr("Cover files") << QVariant() << QVariant() << QVariant() << QVariant(), root);
root->appendChild(mCoversItem);
mFileModel->setRoot(root);
}
@@ -341,19 +356,30 @@ Qt::ItemFlags WizardTreeModel::flags(const QModelIndex &index) const{
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
-QHash<QString, int> WizardTreeModel::files() const{
+QHash<QString, int> WizardTreeModel::files() {
QHash<QString, int> retval;
+ mFilePartMap.clear();
SmTreeItem *rootItem = root();
for(int i = 0; i < rootItem->childCount(); ++i){
SmTreeItem *firstChild = rootItem->child(i);
for(int j = 0; j < firstChild->childCount(); ++j){
SmTreeItem *secondChild = firstChild->child(j);
retval.insert(secondChild->data(WizardTreeModel::FullPath).toString(), secondChild->data(WizardTreeModel::FileType).toInt());
+ if(secondChild->data(WizardTreeModel::FilePart).isValid()){
+ mFilePartMap.insert(secondChild->data(WizardTreeModel::FullPath).toString(), secondChild->data(WizardTreeModel::FilePart).toInt());
+ }
}
}
return retval;
}
+int WizardTreeModel::filesPart(const QString &fullPath) const{
+ if(mFilePartMap.contains(fullPath)){
+ return mFilePartMap.value(fullPath);
+ }
+ return -1;
+}
+
QVariant WizardTreeModel::data(const QModelIndex &index, int role) const{
SmTreeItem *item = static_cast<SmTreeItem*>(index.internalPointer());
if(role == Qt::DisplayRole){
@@ -390,6 +416,9 @@ QVariant WizardTreeModel::data(const QModelIndex &index, int role) const{
if(role == FullPathRole){
return item->data(FullPath);
}
+ if(role == FilePartRole){
+ return item->data(FilePart);
+ }
return QVariant();
}
diff --git a/newmoviewizard.h b/newmoviewizard.h
index d79531f..88667b9 100644
--- a/newmoviewizard.h
+++ b/newmoviewizard.h
@@ -48,6 +48,7 @@ class MovieInfoPage : public QWizardPage {
void removeFile();
void onDvd(int);
void typeChanged(QString);
+ void seriesPartChanged(int);
void setNextDvdNo();
void initModel();
@@ -82,8 +83,8 @@ class MovieMappingPage : public QWizardPage {
class WizardTreeModel : public SmTreeModel {
Q_OBJECT
public:
- enum CustomRoles { FileNameRole = Qt::UserRole + 1, FileSizeRole = Qt::UserRole + 2, FileTypeRole = Qt::UserRole + 3, FullPathRole = Qt::UserRole + 4 };
- enum Fields { FileName = 0, FileSize = 1, FileType = 2, FullPath = 3 };
+ enum CustomRoles { FileNameRole = Qt::UserRole + 1, FileSizeRole = Qt::UserRole + 2, FileTypeRole = Qt::UserRole + 3, FilePartRole = Qt::UserRole + 4, FullPathRole = Qt::UserRole + 5 };
+ enum Fields { FileName = 0, FileSize = 1, FileType = 2, FilePart = 3, FullPath = 4 };
enum Types { Movie = 1, FrontCover = 2, BackCover = 3, GeneralCover = 4 };
explicit WizardTreeModel(QStringList &headers, QObject *parent = 0);
virtual ~WizardTreeModel() {}
@@ -91,7 +92,8 @@ class WizardTreeModel : public SmTreeModel {
//data + flags
virtual QVariant data(const QModelIndex &index, int role) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
- QHash<QString, int> files() const;
+ QHash<QString, int> files();
+ int filesPart(const QString &fullPath) const;
//file types
QStringList types() const;
@@ -99,7 +101,7 @@ class WizardTreeModel : public SmTreeModel {
private:
QHash<int, QString> mFileTypeMap;
-
+ QHash<QString, int> mFilePartMap;
};
#endif