From ba8b78eb0b7b364f6ecc954f8b99b138dfc13981 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 1 Jun 2013 05:06:04 +0200 Subject: 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. --- archivemodel.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 archivemodel.h (limited to 'archivemodel.h') 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 +#include + +#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 mAvailableOrders; + int mOrder; +}; + +#endif // ARCHIVEMODEL_H -- cgit v1.2.3-70-g09d2