diff options
-rw-r--r-- | archiveviewwidget.cpp | 35 | ||||
-rw-r--r-- | archiveviewwidget.h | 1 | ||||
-rw-r--r-- | moviemodel.cpp | 14 | ||||
-rw-r--r-- | moviemodel.h | 3 | ||||
-rw-r--r-- | pictureviewer.cpp | 2 | ||||
-rw-r--r-- | shemov.cpp | 4 | ||||
-rw-r--r-- | shemov.h | 1 |
7 files changed, 59 insertions, 1 deletions
diff --git a/archiveviewwidget.cpp b/archiveviewwidget.cpp index 9aa1164..062d090 100644 --- a/archiveviewwidget.cpp +++ b/archiveviewwidget.cpp @@ -32,6 +32,7 @@ #include "moviepropertiesdialog.h" #include "addmoviewizard.h" #include "archiveitemeditdialog.h" +#include "coveritem.h" ArchiveViewWidget::ArchiveViewWidget(MovieModel *model, ListModel *genre, ListModel *actors, QWidget *parent) : QWidget(parent), mMovieModel(model), mGenreModel(genre), mActorsModel(actors), mSize(0){ //filter bar @@ -262,6 +263,40 @@ void ArchiveViewWidget::playSelected(const QString &player){ QProcess::startDetached(prog, args); } +void ArchiveViewWidget::copyToParts(){ + QModelIndex idx = getSourceColumnZero(); + QVariant quality = idx.data(MovieModel::QualityRole); + QVariant dvdno = idx.data(MovieModel::DvdRole); + QVariant genre = idx.data(MovieModel::GenreRole); + QHash<QString, QVariant> actorMap = idx.data(MovieModel::ActorsMap).toHash(); + QList<QVariant> actorIds; + foreach(QVariant id, actorMap.values()){ + actorIds << id.toInt(); + } + QList<CoverItem> covers; + foreach(QVariant cover, idx.data(MovieModel::CoverRole).toList()){ + covers << cover.value<CoverItem>(); + } + QList<QVariant> otherParts = idx.data(MovieModel::OtherPartsRole).toList(); + if(otherParts.isEmpty()){ + statusbarMessage(tr("No other parts found.")); + return; + } + foreach(QVariant part, otherParts){ + int id = part.toInt(); + QModelIndex movieModelIndex = mMovieModel->index(id, MovieItem::Genre); + mMovieModel->setDataAt(movieModelIndex, genre); + movieModelIndex = mMovieModel->index(id, MovieItem::Quality); + mMovieModel->setDataAt(movieModelIndex, quality); + movieModelIndex = mMovieModel->index(id, MovieItem::Dvd); + mMovieModel->setDataAt(movieModelIndex, dvdno); + mMovieModel->setActors(id, actorIds); + mMovieModel->setCovers(id, covers); + } + QString message = QString(tr("Copied data to %1 movie(s)")).arg(otherParts.count()); + statusbarMessage(message); +} + void ArchiveViewWidget::rowChanged(const QModelIndex &/*current*/, const QModelIndex & /*prev*/){ QModelIndex idx = getSourceColumnZero(); mWindowTitle = QString(tr("%1 - %2")).arg(qApp->applicationName()).arg(idx.data().toString()); diff --git a/archiveviewwidget.h b/archiveviewwidget.h index 6a4d572..c171707 100644 --- a/archiveviewwidget.h +++ b/archiveviewwidget.h @@ -45,6 +45,7 @@ class ArchiveViewWidget : public QWidget { void setDvdNo(); void deleteFromArchive(); void playSelected(const QString &player = QString()); + void copyToParts(); signals: void statusbarMessage(const QString &message); diff --git a/moviemodel.cpp b/moviemodel.cpp index d92692d..d9b0c22 100644 --- a/moviemodel.cpp +++ b/moviemodel.cpp @@ -27,6 +27,8 @@ MovieModel::MovieModel(QObject *parent) : QAbstractItemModel(parent) { mDeleteCovers->prepare("DELETE FROM covers WHERE imovid = :id"); mInsertCovers = new QSqlQuery; mInsertCovers->prepare("INSERT INTO covers VALUES(:filename, :movid, :covertype, :md5sum)"); + mOtherPartsQuery = new QSqlQuery; + mOtherPartsQuery->prepare("SELECT imovid FROM movies WHERE ttitle = :title AND iseriesno = :seriesno AND imovid != :id"); QSqlQuery *c1 = new QSqlQuery; c1->prepare("UPDATE movies SET ttitle = :value WHERE imovid = :id"); mColumnQueries << c1; @@ -66,6 +68,7 @@ MovieModel::~MovieModel(){ delete mInsertActorsForMovie; delete mDeleteCovers; delete mInsertCovers; + delete mOtherPartsQuery; } QModelIndex MovieModel::index(int row, int column, const QModelIndex &parent) const{ @@ -188,6 +191,17 @@ QVariant MovieModel::data(const QModelIndex &index, int role) const{ } return retval; } + if(role == OtherPartsRole){ + QList<QVariant> retval; + mOtherPartsQuery->bindValue(":title", item->dataAt(MovieItem::Title)); + mOtherPartsQuery->bindValue(":seriesno", item->dataAt(MovieItem::SeriesNo)); + mOtherPartsQuery->bindValue(":id", item->id()); + mOtherPartsQuery->exec(); + while(mOtherPartsQuery->next()){ + retval << mOtherPartsQuery->value(0); + } + return retval; + } if((role == Qt::DecorationRole) && (index.column() == 0)){ return QIcon(":/dildo.png"); } diff --git a/moviemodel.h b/moviemodel.h index d757ac1..d9950b4 100644 --- a/moviemodel.h +++ b/moviemodel.h @@ -20,7 +20,7 @@ class MovieModel : public QAbstractItemModel { Q_OBJECT Q_ENUMS(CustomRoles) public: - enum CustomRoles { Md5Role = Qt::UserRole + 1, ActorsRole = Qt::UserRole + 2, ActorsMap = Qt::UserRole + 3, CoverRole = Qt::UserRole + 4, IdRole = Qt::UserRole + 5, TitleBaseRole = Qt::UserRole + 6, SeriesNoRole = Qt::UserRole + 7, PartNoRole = Qt::UserRole + 8, FilenameRole = Qt::UserRole + 9, SizeRole = Qt::UserRole + 10, GenreRole = Qt::UserRole + 11, QualityRole = Qt::UserRole + 12, DvdRole = Qt::UserRole + 13, FullPathRole = Qt::UserRole + 14, CoverPathRole = Qt::UserRole + 15 }; + enum CustomRoles { Md5Role = Qt::UserRole + 1, ActorsRole = Qt::UserRole + 2, ActorsMap = Qt::UserRole + 3, CoverRole = Qt::UserRole + 4, IdRole = Qt::UserRole + 5, TitleBaseRole = Qt::UserRole + 6, SeriesNoRole = Qt::UserRole + 7, PartNoRole = Qt::UserRole + 8, FilenameRole = Qt::UserRole + 9, SizeRole = Qt::UserRole + 10, GenreRole = Qt::UserRole + 11, QualityRole = Qt::UserRole + 12, DvdRole = Qt::UserRole + 13, FullPathRole = Qt::UserRole + 14, CoverPathRole = Qt::UserRole + 15, OtherPartsRole = Qt::UserRole + 16 }; MovieModel(QObject *parent = 0); ~MovieModel(); QModelIndex index(int row, int column, const QModelIndex &parent) const; @@ -56,6 +56,7 @@ class MovieModel : public QAbstractItemModel { QSqlQuery *mInsertActorsForMovie; QSqlQuery *mDeleteCovers; QSqlQuery *mInsertCovers; + QSqlQuery *mOtherPartsQuery; }; #endif diff --git a/pictureviewer.cpp b/pictureviewer.cpp index a59b62d..915a280 100644 --- a/pictureviewer.cpp +++ b/pictureviewer.cpp @@ -83,6 +83,8 @@ void PictureViewer::showPic(const QString &path, bool enableDirEntries){ QPoint infoPoint = QPoint(center, 10); infoItem->setPos(infoPoint); mScene->addItem(infoItem); + + setWindowTitle(fi.fileName()); } void PictureViewer::next(){ @@ -327,6 +327,8 @@ void SheMov::createActions(){ mEditArchiveFileA = new QAction(tr("Edit file..."), this); mEditArchiveFileA->setShortcut(tr("CTRL+e")); connect(mEditArchiveFileA, SIGNAL(triggered()), mAVWidget, SLOT(editFile())); + mCopyToPartsA = new QAction(tr("Copy data to other parts"), this); + connect(mCopyToPartsA, SIGNAL(triggered()), mAVWidget, SLOT(copyToParts())); mAddMovieManuallyA = new QAction(tr("Add movie manually..."), this); connect(mAddMovieManuallyA, SIGNAL(triggered()), mAVWidget, SLOT(addMovie())); mPropertiesA = new QAction(tr("Properties..."), this); @@ -386,6 +388,7 @@ void SheMov::createMenus(){ mEditArchiveMenu = new QMenu(tr("&Edit archive"), this); mEditArchiveMenu->addAction(mEditArchiveFileA); + mEditArchiveMenu->addAction(mCopyToPartsA); mEditArchiveMenu->addSeparator(); mEditArchiveMenu->addAction(mPropertiesA); mEditArchiveMenu->addSeparator(); @@ -447,6 +450,7 @@ void SheMov::createMenus(){ sep5->setSeparator(true); mAVWidget->fileView()->addAction(sep5); mAVWidget->fileView()->addAction(mEditArchiveFileA); + mAVWidget->fileView()->addAction(mCopyToPartsA); mAVWidget->fileView()->addAction(mAddMovieManuallyA); mAVWidget->fileView()->addAction(mDeleteFromArchiveA); mAVWidget->fileView()->addAction(mSetDvdA); @@ -93,6 +93,7 @@ class SheMov : public QMainWindow { QAction *mOpenWithMenuFSA; QAction *mOpenWithMenuAVA; QAction *mRenameMenuA; + QAction *mCopyToPartsA; QActionGroup *mOpenWithGroupFS; QActionGroup *mOpenWithGroupAV; //EndActions |