summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archivemodel.cpp21
-rw-r--r--archivemodel.h6
-rw-r--r--helper.cpp15
-rw-r--r--helper.h1
4 files changed, 38 insertions, 5 deletions
diff --git a/archivemodel.cpp b/archivemodel.cpp
index 483eb9f..4b0c720 100644
--- a/archivemodel.cpp
+++ b/archivemodel.cpp
@@ -823,6 +823,15 @@ QVariant ArchiveFilesModel::data(const QModelIndex &index, int role) const {
if(role == FullPathRole){
return item->data(FullPath);
}
+ if(role == SeriesNameRole){
+ return item->data(SeriesName);
+ }
+ if(role == SeriesPartRole){
+ return item->data(SeriesPart);
+ }
+ if(role == SubtitleRole){
+ return item->data(Subtitle);
+ }
if(role == Qt::ForegroundRole){
if(col == DvdNo){
if(item->data(DvdNo).toInt() < 0){
@@ -945,7 +954,7 @@ void ArchiveFilesModel::populate(const QSet<int> &seriesPartIds){
foreach(int i, seriesPartIds){
ids << QString::number(i);
}
- QString queryString = QString("SELECT iseriespart_id, tfilename, cmd5sum, bisize, idvd, sifiletype, sifileno, siquality, ifiles_id, cpicsize, iduration FROM files WHERE iseriespart_id IN (%1) ORDER BY tfilename ASC").arg(ids.join(","));
+ QString queryString = QString("SELECT iseriespart_id, tfilename, cmd5sum, bisize, idvd, sifiletype, sifileno, siquality, ifiles_id, cpicsize, iduration, series.tseries_name, seriesparts.iseriespart, seriesparts.tsubtitle FROM files, seriesparts, series WHERE iseriespart_id IN (%1) and files.iseriespart_id = seriesparts.iseriesparts_id and seriesparts.iseries_id = series.iseries_id ORDER BY tfilename ASC;").arg(ids.join(","));
QSqlQuery q(queryString, mDb);
while(q.next()){
QList<QVariant> data;
@@ -959,7 +968,15 @@ void ArchiveFilesModel::populate(const QSet<int> &seriesPartIds){
data << 0x0;
}
QString fullPath = Helper::createArchivePath(data.at(Filename).toString(), data.at(Md5Sum).toString());
- data << fullPath;
+ QFileInfo fullPathFi(fullPath);
+ if(!fullPathFi.exists()){
+ QString usbPath = Helper::createUSBPath(q.value(1).toString(), q.value(11).toString(), q.value(13).toString(), q.value(4).toInt(), q.value(12).toInt());
+ QFileInfo usbPathFi(usbPath);
+ if(usbPathFi.exists()){
+ fullPath = usbPath;
+ }
+ }
+ data << fullPath << q.value(11) << q.value(12) << q.value(13);
if(data.at(FileType).toInt() == FT_MOVIE){
SmTreeItem *newItem = new SmTreeItem(data, movies);
movies->appendChild(newItem);
diff --git a/archivemodel.h b/archivemodel.h
index 6e02855..da673c7 100644
--- a/archivemodel.h
+++ b/archivemodel.h
@@ -94,9 +94,9 @@ class ArchiveModel : public SmTreeModel {
class ArchiveFilesModel : public SmTreeModel {
Q_OBJECT
public:
- enum CustomRoles { ExpansionRole = Qt::UserRole + 1, SeriesPartIdRole = Qt::UserRole + 2, FilenameRole = Qt::UserRole + 3, Md5SumRole = Qt::UserRole + 4, SizeRole = Qt::UserRole + 5, DvdNoRole = Qt::UserRole + 6, FileTypeRole = Qt::UserRole + 7, FileNumberRole = Qt::UserRole + 8, QualityRole = Qt::UserRole + 9, FileIdRole = Qt::UserRole + 10, SizeDurRole = Qt::UserRole + 11, FullPathRole = Qt::UserRole + 12 };
- enum Fields { Expansion = 0, SeriesPartId = 1, Filename = 2, Md5Sum = 3, Size = 4, DvdNo = 5, FileType = 6, FileNumber = 7, Quality = 8, FileId = 9, SizeDur = 10, FullPath = 11 };
- enum { NumFields = 12 };
+ enum CustomRoles { ExpansionRole = Qt::UserRole + 1, SeriesPartIdRole = Qt::UserRole + 2, FilenameRole = Qt::UserRole + 3, Md5SumRole = Qt::UserRole + 4, SizeRole = Qt::UserRole + 5, DvdNoRole = Qt::UserRole + 6, FileTypeRole = Qt::UserRole + 7, FileNumberRole = Qt::UserRole + 8, QualityRole = Qt::UserRole + 9, FileIdRole = Qt::UserRole + 10, SizeDurRole = Qt::UserRole + 11, FullPathRole = Qt::UserRole + 12, SeriesNameRole = Qt::UserRole + 13, SeriesPartRole = Qt::UserRole + 14, SubtitleRole = Qt::UserRole + 15 };
+ enum Fields { Expansion = 0, SeriesPartId = 1, Filename = 2, Md5Sum = 3, Size = 4, DvdNo = 5, FileType = 6, FileNumber = 7, Quality = 8, FileId = 9, SizeDur = 10, FullPath = 11, SeriesName = 12, SeriesPart = 13, Subtitle = 14 };
+ enum { NumFields = 15 };
explicit ArchiveFilesModel(const QStringList &headers, QObject *parent = 0);
virtual QVariant data(const QModelIndex &index, int role) const;
virtual bool setData(const QModelIndex &idx, const QVariant &value, int role);
diff --git a/helper.cpp b/helper.cpp
index 76f637a..b02c71d 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -152,6 +152,21 @@ namespace Helper {
return retval;
}
+ const QString createUSBPath(const QString &filename, const QString &seriesName, const QString &subtitle, int dvdNo, int seriesNo){
+ QSettings s;
+ QString usbPath = s.value("paths/usb").toString();
+ QString seriesDir = seriesName;
+
+ if(seriesNo > 0){
+ seriesDir.append(QString(" %1").arg(QString::number(seriesNo)));
+ }else{
+ seriesDir.append(QString(" - %1").arg(subtitle));
+ }
+ seriesDir.replace(' ', '.');
+ QString retval = QString("%1/DVD_%2/%3/%4").arg(usbPath).arg(QString::number(dvdNo)).arg(seriesDir).arg(filename);
+ return retval;
+ }
+
QPair<QString, QStringList> programData(const QString &prefix, const QString &preferred){
QSettings s;
QString section = QString("programs_%1").arg(prefix);
diff --git a/helper.h b/helper.h
index 434ba0d..747f57e 100644
--- a/helper.h
+++ b/helper.h
@@ -38,6 +38,7 @@ namespace Helper {
const QString moveToArchive(const QString &path, const QString &md5, bool copy = false);
bool removeFromArchive(const QString &filename, const QString &md5);
const QString createArchivePath(const QString &path, const QString &md5, bool withMd5 = false);
+ const QString createUSBPath(const QString &filename, const QString &seriesName, const QString &subtitle, int dvdNo, int seriesNo);
QPair<QString, QStringList> programData(const QString &prefix, const QString &preferred = QString());
const QString durationFromSecs(qint64 secs);
QVariant bytesFromUnit(QVariant number, const QString unit);