From f0eae1094e83a73b9baeebd21e0c77cce3803e19 Mon Sep 17 00:00:00 2001 From: am Date: Sat, 15 Aug 2009 13:59:50 +0000 Subject: -Modified MovieModel: ->FullPathRole and CoverPathRole ->maxValue of any column -Implemented move files to directory for burning -Implemented collective DVDNo change -Implemented delete from archive git-svn-id: file:///var/svn/repos2/shemov/trunk@402 f440f766-f032-0410-8965-dc7d17de2ca0 --- moviemodel.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'moviemodel.cpp') diff --git a/moviemodel.cpp b/moviemodel.cpp index da921b4..d92692d 100644 --- a/moviemodel.cpp +++ b/moviemodel.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "moviemodel.h" #include "coveritem.h" @@ -113,6 +114,7 @@ QVariant MovieModel::data(const QModelIndex &index, int role) const{ if(!index.isValid()){ return QVariant(); } + QSettings s; MovieItem *item = static_cast(index.internalPointer()); Q_ASSERT(item != 0); if(role == Qt::DisplayRole){ @@ -170,6 +172,22 @@ QVariant MovieModel::data(const QModelIndex &index, int role) const{ if(role == DvdRole){ return item->dataAt(MovieItem::Dvd); } + if(role == FullPathRole){ + QString archivePath = s.value("paths/archivedir").toString(); + QString md5 = item->dataAt(MovieItem::Md5Sum).toString(); + QString fileName = item->dataAt(MovieItem::Filename).toString(); + QString retval = QString("%1/%2/%3/%4").arg(archivePath).arg(md5.at(0)).arg(md5.at(1)).arg(fileName); + return retval; + } + if(role == CoverPathRole){ + QList retval; + QList covers = item->covers(); + foreach(QVariant c, covers){ + CoverItem i = c.value(); + retval << i.fullPath(); + } + return retval; + } if((role == Qt::DecorationRole) && (index.column() == 0)){ return QIcon(":/dildo.png"); } @@ -326,6 +344,34 @@ void MovieModel::removeMovie(const QModelIndex &idx){ removeRows(idx.row(), 1, QModelIndex()); } +const QVariant MovieModel::maxValue(int column) const{ + if(mItems.isEmpty()){ + return QVariant(); + } + QVariant sample = mItems.at(0)->dataAt(column); + if(sample.canConvert(QVariant::LongLong)){ + qint64 retval(-1); + foreach(MovieItem* i, mItems){ + qint64 value = i->dataAt(column).toLongLong(); + if(value > retval){ + retval = value; + } + } + return retval; + } + if(sample.canConvert(QVariant::String)){ + QString retval; + foreach(MovieItem *i, mItems){ + QString value = i->dataAt(column).toString(); + if(value > retval){ + retval = value; + } + } + return retval; + } + return QVariant(); +} + void MovieModel::populate(){ QSqlQuery movieQuery("SELECT imovid FROM movies"); while(movieQuery.next()){ -- cgit v1.2.3-70-g09d2