From 9a1ec955d9ce339e6b89714488bb866ae43bb397 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 30 May 2010 10:29:47 +0200 Subject: Implemented copying of movie data Added function to copy actors, covers, genre, dvd and quality to other parts of the same movie if movie has multiple files. --- archiveviewwidget.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'archiveviewwidget.cpp') 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 actorMap = idx.data(MovieModel::ActorsMap).toHash(); + QList actorIds; + foreach(QVariant id, actorMap.values()){ + actorIds << id.toInt(); + } + QList covers; + foreach(QVariant cover, idx.data(MovieModel::CoverRole).toList()){ + covers << cover.value(); + } + QList 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()); -- cgit v1.2.3-70-g09d2