summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archivebrowsermodel.cpp26
-rw-r--r--archivebrowsermodel.h5
-rw-r--r--smglobals.cpp16
3 files changed, 35 insertions, 12 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) {}
diff --git a/archivebrowsermodel.h b/archivebrowsermodel.h
index df91332..9a70d83 100644
--- a/archivebrowsermodel.h
+++ b/archivebrowsermodel.h
@@ -17,8 +17,8 @@
class ArchiveBrowserModel : public SmTreeModel {
Q_OBJECT
public:
- enum CustomRoles { NameRole = Qt::UserRole + 1, GenericIdRole = Qt::UserRole + 2, NodeTypeRole = Qt::UserRole + 3, TotalSizeRole = Qt::UserRole + 4, QualityRole = 5, FileTypeRole = Qt::UserRole + 6, FullPathRole = Qt::UserRole + 7, SelectedRole = Qt::UserRole + 8 };
- enum Fields { Name = 0, GenericId = 1, NodeType = 2, TotalSize = 3, Quality = 4, FileType = 5, FullPath = 6, Selected = 7 };
+ enum CustomRoles { ExpansionRole = Qt::UserRole + 1, NameRole = Qt::UserRole + 2, GenericIdRole = Qt::UserRole + 3, NodeTypeRole = Qt::UserRole + 4, TotalSizeRole = Qt::UserRole + 5, QualityRole = 6, FileTypeRole = Qt::UserRole + 7, FullPathRole = Qt::UserRole + 8, SelectedRole = Qt::UserRole + 9 };
+ enum Fields { Expansion = 0, Name = 1, GenericId = 2, NodeType = 3, TotalSize = 4, Quality = 5, FileType = 6, FullPath = 7, Selected = 8 };
enum NodeTypes { SeriesPartNode = 1, FileNode = 2 };
explicit ArchiveBrowserModel(const QStringList &headers, QObject *parent = 0);
virtual QVariant data(const QModelIndex &index, int role) const;
@@ -36,6 +36,7 @@ class ArchiveBrowserModel : public SmTreeModel {
private:
void populate();
+ void readConfig();
int mNumFields;
QList<int> mAvailableQualities;
QSqlDatabase mDb;
diff --git a/smglobals.cpp b/smglobals.cpp
index 5f50ede..e5c67f4 100644
--- a/smglobals.cpp
+++ b/smglobals.cpp
@@ -93,13 +93,17 @@ QAbstractItemModel *SmGlobals::model(const QString &which){
mModels.insert(which, model);
}
}else if(which == "ArchiveModel"){
- QStringList headers = QStringList() << tr("Series") << tr("Series ID") << tr("Series part ID") << tr("Part") << tr("Type") << tr("Favorite") << tr("Subtitle") << tr("Count");
- ArchiveModel *model = new ArchiveModel(headers);
- mModels.insert(which, model);
+ if(!mModels.contains("ArchiveModel")){
+ QStringList headers = QStringList() << tr("Series") << tr("Series ID") << tr("Series part ID") << tr("Part") << tr("Type") << tr("Favorite") << tr("Subtitle") << tr("Count");
+ ArchiveModel *model = new ArchiveModel(headers);
+ mModels.insert(which, model);
+ }
}else if(which == "BrowserModel"){
- QStringList headers = QStringList() << tr("Name") << tr("Generic Id") << tr("Node Type") << tr("Size") << tr("Quality") << tr("File Type") << tr("Full Path") << tr("Selected");
- ArchiveBrowserModel *model = new ArchiveBrowserModel(headers);
- mModels.insert(which, model);
+ if(!mModels.contains("BrowserModel")){
+ QStringList headers = QStringList() << QChar(0x26A7) << tr("Name") << tr("Generic Id") << tr("Node Type") << tr("Size") << tr("Quality") << tr("File Type") << tr("Full Path") << tr("Selected");
+ ArchiveBrowserModel *model = new ArchiveBrowserModel(headers);
+ mModels.insert(which, model);
+ }
}
return mModels.contains(which) ? mModels.value(which) : 0;
}