summaryrefslogtreecommitdiffstats
path: root/archivemodel.h
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-06-01 05:06:04 +0200
committerArno <am@disconnect.de>2013-06-01 05:06:04 +0200
commitba8b78eb0b7b364f6ecc954f8b99b138dfc13981 (patch)
tree5f73814fb157515bfe4d56047c685c6d955b3027 /archivemodel.h
parenta5316f7081b7d2142fda3a8391567bdabb0cc11c (diff)
downloadSheMov-ba8b78eb0b7b364f6ecc954f8b99b138dfc13981.tar.gz
SheMov-ba8b78eb0b7b364f6ecc954f8b99b138dfc13981.tar.bz2
SheMov-ba8b78eb0b7b364f6ecc954f8b99b138dfc13981.zip
First draft of new ArchiveModel
The new ArchiveModel allows sorting and display by the series name, actors and genres. Hopefully it's generic enough to easily add other sort orders like file location or file type. For now, it's just there. Not included anywhere. No view, no nothing.
Diffstat (limited to 'archivemodel.h')
-rw-r--r--archivemodel.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/archivemodel.h b/archivemodel.h
new file mode 100644
index 0000000..8e71a46
--- /dev/null
+++ b/archivemodel.h
@@ -0,0 +1,44 @@
+/*
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version
+ 2 of the License, or (at your option) any later version.
+*/
+
+#ifndef ARCHIVEMODEL_H
+#define ARCHIVEMODEL_H
+
+#include <QSqlDatabase>
+#include <QHash>
+
+#include "smtreemodel.h"
+
+class ArchiveModel : public SmTreeModel {
+ Q_OBJECT
+ public:
+ enum CustomRoles { NameRole = Qt::UserRole + 1, SeriesIdRole = Qt::UserRole + 2, SeriesPartIdRole = Qt::UserRole + 3, SeriesPartRole = Qt::UserRole + 4, TypeRole = Qt::UserRole + 5, FavoriteRole = Qt::UserRole + 6, SubtitleRole = Qt::UserRole + 7, CountRole = Qt::UserRole + 8 };
+ enum Fields { Name = 0, SeriesId = 1, SeriesPartId = 2, SeriesPart = 3, Type = 4, Favorite = 5, Subtitle = 6, Count = 7 };
+ enum Order { SeriesName, Actor, Genre };
+ enum { NumFields = 8 };
+ enum NodeType { SeriesNode, SeriesPartNode, GenreNode, ActorNode };
+ explicit ArchiveModel(const QStringList &headers, QObject *parent = 0);
+ const QStringList availableOrders() const;
+
+ signals:
+
+ public slots:
+ void setOrder(int order);
+
+ private:
+ void populateBySeriesName();
+ void populateByGenre();
+ void populateByActor();
+ void fetchChildren(SmTreeItem *parent);
+ void fetchSeries(const QVariant &id, SmTreeItem *parent);
+ void fetchParts(SmTreeItem *parent);
+ QSqlDatabase mDb;
+ QHash<int, QString> mAvailableOrders;
+ int mOrder;
+};
+
+#endif // ARCHIVEMODEL_H