diff options
-rw-r--r-- | filestreemodel.cpp | 2 | ||||
-rw-r--r-- | newmoviewizard.cpp | 31 | ||||
-rw-r--r-- | newmoviewizard.h | 4 |
3 files changed, 33 insertions, 4 deletions
diff --git a/filestreemodel.cpp b/filestreemodel.cpp index d015e47..fd6264a 100644 --- a/filestreemodel.cpp +++ b/filestreemodel.cpp @@ -40,7 +40,7 @@ FilesTreeModel::FilesTreeModel(QStringList &headers, QObject *parent) : SmTreeMo mDeleteFileQuery->prepare("DELETE FROM files WHERE ifiles_id = :id"); //file types - mFileTypes.insert(1, "Movie"); + mFileTypes.insert(1, tr("Movie")); mFileTypes.insert(2, tr("Front cover")); mFileTypes.insert(3, tr("Back cover")); mFileTypes.insert(4, tr("General cover")); diff --git a/newmoviewizard.cpp b/newmoviewizard.cpp index 81e0312..5325c1c 100644 --- a/newmoviewizard.cpp +++ b/newmoviewizard.cpp @@ -130,6 +130,7 @@ MovieInfoPage::MovieInfoPage(QWidget *parent) : QWizardPage(parent){ //files view mFileView = new QTreeView; mFileView->setModel(mFileModel); + connect(mFileView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(fileSelectionChanged(QModelIndex,QModelIndex))); //add + remove files QHBoxLayout *fileButtonLayout = new QHBoxLayout; @@ -306,11 +307,11 @@ void MovieInfoPage::seriesPartChanged(int partNo){ 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); + QVariant data = (partNo == 0) ? QVariant() : QVariant(partNo); + mFileModel->setData(seriesPartIdx, data, Qt::EditRole); } } @@ -329,6 +330,28 @@ void MovieInfoPage::initModel(){ mFileModel->setRoot(root); } +void MovieInfoPage::fileSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous){ + Q_UNUSED(previous); + int type = current.data(WizardTreeModel::FileTypeRole).toInt(); + if(type == WizardTreeModel::Movie){ + int part = 1; + QVariant filePart= current.data(WizardTreeModel::FilePartRole); + if(filePart.isValid()){ + part = filePart.toInt(); + } + mPartno->blockSignals(true); + mPartno->setValue(part); + mPartno->blockSignals(false); + } + QString typeString = mFileModel->typeName(type); + int comboIdx = mFileType->findText(typeString); + if(comboIdx != -1){ + mFileType->blockSignals(true); + mFileType->setCurrentIndex(comboIdx); + mFileType->blockSignals(false); + } +} + MovieMappingPage::MovieMappingPage(const QString &table, QWidget *parent) : QWizardPage(parent){ QString title = QString(tr("Edit %1")).arg(table); QString subTitle = QString(tr("Edit %1 by adding them from the text field below")).arg(table); @@ -438,3 +461,7 @@ int WizardTreeModel::typeId(const QString &value) const{ } return -1; } + +QString WizardTreeModel::typeName(int typeId) const{ + return mFileTypeMap.value(typeId); +} diff --git a/newmoviewizard.h b/newmoviewizard.h index 88667b9..9f476ed 100644 --- a/newmoviewizard.h +++ b/newmoviewizard.h @@ -51,6 +51,7 @@ class MovieInfoPage : public QWizardPage { void seriesPartChanged(int); void setNextDvdNo(); void initModel(); + void fileSelectionChanged(const QModelIndex ¤t, const QModelIndex &previous); private: QTreeView *mFileView; @@ -83,7 +84,7 @@ 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, FilePartRole = Qt::UserRole + 4, FullPathRole = Qt::UserRole + 5 }; + 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); @@ -98,6 +99,7 @@ class WizardTreeModel : public SmTreeModel { //file types QStringList types() const; int typeId(const QString &value) const; + QString typeName(int typeId) const; private: QHash<int, QString> mFileTypeMap; |