diff options
Diffstat (limited to 'archivemodel.h')
-rw-r--r-- | archivemodel.h | 44 |
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 |