diff options
author | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-08-15 13:59:50 +0000 |
---|---|---|
committer | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-08-15 13:59:50 +0000 |
commit | f0eae1094e83a73b9baeebd21e0c77cce3803e19 (patch) | |
tree | 546b8593e95dba76b39a01a4946679f5222472cb /moviemodel.cpp | |
parent | 06233888b033adc6e821331e6d1822e9807371ae (diff) | |
download | SheMov-f0eae1094e83a73b9baeebd21e0c77cce3803e19.tar.gz SheMov-f0eae1094e83a73b9baeebd21e0c77cce3803e19.tar.bz2 SheMov-f0eae1094e83a73b9baeebd21e0c77cce3803e19.zip |
-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
Diffstat (limited to 'moviemodel.cpp')
-rw-r--r-- | moviemodel.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/moviemodel.cpp b/moviemodel.cpp index da921b4..d92692d 100644 --- a/moviemodel.cpp +++ b/moviemodel.cpp @@ -8,6 +8,7 @@ #include <QSqlQuery> #include <QStringList> #include <QIcon> +#include <QSettings> #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<MovieItem*>(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<QVariant> retval; + QList<QVariant> covers = item->covers(); + foreach(QVariant c, covers){ + CoverItem i = c.value<CoverItem>(); + 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()){ |