From a6a1c319ee5a77cc8341eaeccc72da35cbcf17c5 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 14 May 2011 10:32:19 +0200 Subject: Add field isLocal to SeriesTreeModel Indicate if SeriesPart has local files in SeriesTreeModel. The cost for this is an additional Query when populating the model, but fortunately the performance impact isn't noticeable. Also introduced a new enum NumFields to SeriesTreeModel. It represents the number of fields for a SmTreeItem so extending the model isn't that cumbersome any more. --- seriestreemodel.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'seriestreemodel.h') diff --git a/seriestreemodel.h b/seriestreemodel.h index 8488cd7..348ff2c 100644 --- a/seriestreemodel.h +++ b/seriestreemodel.h @@ -20,10 +20,11 @@ class QSqlQuery; class SeriesTreeModel : 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 }; - enum Fields { Name = 0, SeriesId = 1, SeriesPartId = 2, SeriesPart = 3, Type = 4, Favorite = 5, Subtitle = 6 }; + 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, IsLocalRole = Qt::UserRole + 8 }; + enum Fields { Name = 0, SeriesId = 1, SeriesPartId = 2, SeriesPart = 3, Type = 4, Favorite = 5, Subtitle = 6, IsLocal = 7 }; enum Types { Series, Part, NewSeries }; enum QueryType { NumericQuery, TextQuery }; + enum { NumFields = 8 }; explicit SeriesTreeModel(QStringList &headers, QObject *parent = 0); ~SeriesTreeModel(); @@ -38,6 +39,7 @@ class SeriesTreeModel : public SmTreeModel { QFileInfoList findFiles(const QModelIndex &where) const; QFileInfoList findMovies(const QModelIndexList &from) const; QFileInfoList findSortedMovies(const QModelIndex &from) const; + bool hasLocals(int sPartId) const; int seriesIdByPartId(int partId); int findNextDvdNo() const; @@ -86,6 +88,7 @@ class SeriesTreeModel : public SmTreeModel { QSqlQuery *mGenreFilterQuery; QSqlQuery *mFavoriteSeriesIdQuery; QSqlQuery *mFavoriteSeriesPartsQuery; + QSqlQuery *mIsLocalQuery; QHash mSeriesPartSeriesMap; QHash mUpdateGenericMap; QColor mFavoriteColor; -- cgit v1.2.3-70-g09d2