diff options
Diffstat (limited to 'archivebrowsermodel.cpp')
-rw-r--r-- | archivebrowsermodel.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/archivebrowsermodel.cpp b/archivebrowsermodel.cpp index 5da95f1..ce81d1b 100644 --- a/archivebrowsermodel.cpp +++ b/archivebrowsermodel.cpp @@ -14,17 +14,21 @@ #include "smglobals.h" #include "helper.h" -ArchiveBrowserModel::ArchiveBrowserModel(const QStringList &headers, QObject *parent) : SmTreeModel(headers, parent), mNumFields(8) { +ArchiveBrowserModel::ArchiveBrowserModel(const QStringList &headers, QObject *parent) : SmTreeModel(headers, parent), mNumFields(9) { mDb = QSqlDatabase::database("treedb"); + readConfig(); populate(); } QVariant ArchiveBrowserModel::data(const QModelIndex &index, int role) const { SmTreeItem *item = itemAt(index); int col = index.column(); - if(role == Qt::DisplayRole && index.column() == 0){ + if(role == Qt::DisplayRole && index.column() == 1){ return item->data(Name); } + if(role == ExpansionRole){ + return item->data(Expansion); + } if(role == NameRole){ return item->data(Name); } @@ -76,6 +80,16 @@ QVariant ArchiveBrowserModel::data(const QModelIndex &index, int role) const { return retval; } } + if(role == Qt::DecorationRole){ + if(index.column() == 0){ + if(item->parent() == root()){ + return QVariant(); + }else{ + return decorationIcon(); + } + } + return QVariant(); + } return SmTreeModel::data(index, role); } @@ -148,7 +162,7 @@ void ArchiveBrowserModel::populate(){ }else{ name = QString("%1 - %2").arg(localQ.value(1).toString()).arg(localQ.value(3).toString()); } - serPartData << name << localQ.value(4) << SeriesPartNode << QVariant() << QVariant() << QVariant() << QString() << false; + serPartData << QChar(0x26A4) << name << localQ.value(4) << SeriesPartNode << QVariant() << QVariant() << QVariant() << QString() << false; SmTreeItem *seriesItem = new SmTreeItem(serPartData, rootItem); rootItem->appendChild(seriesItem); localFilesQ.bindValue(":sid", localQ.value(4)); @@ -157,7 +171,7 @@ void ArchiveBrowserModel::populate(){ int quality = -1; while(localFilesQ.next()){ QList<QVariant> fileData; - fileData << localFilesQ.value(0) << localFilesQ.value(4) << FileNode << localFilesQ.value(1) << localFilesQ.value(3) << localFilesQ.value(2) << Helper::createArchivePath(localFilesQ.value(0).toString(), localFilesQ.value(5).toString()) << false; + fileData << QVariant() << localFilesQ.value(0) << localFilesQ.value(4) << FileNode << localFilesQ.value(1) << localFilesQ.value(3) << localFilesQ.value(2) << Helper::createArchivePath(localFilesQ.value(0).toString(), localFilesQ.value(5).toString()) << false; totalSize += localFilesQ.value(1).toDouble(); if(localFilesQ.value(2) == 1){ //this is a movie file, no need for another enum int q = localFilesQ.value(3).toInt(); @@ -176,6 +190,10 @@ void ArchiveBrowserModel::populate(){ emit populated(); } +void ArchiveBrowserModel::readConfig() { + setDecorationIcon(SmGlobals::instance()->iconFor("file")); +} + //ArchiveBrowserModelProxy ArchiveBrowserModelProxy::ArchiveBrowserModelProxy(QObject *parent) : QSortFilterProxyModel(parent), mQuality(-1), mSizeFilter(false) {} |