diff options
Diffstat (limited to 'seriestreemodel.h')
-rw-r--r-- | seriestreemodel.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/seriestreemodel.h b/seriestreemodel.h new file mode 100644 index 0000000..a61a4a9 --- /dev/null +++ b/seriestreemodel.h @@ -0,0 +1,43 @@ +/* + 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 SERIESTREEMODEL_H +#define SERIESTREEMODEL_H + +#include <QSqlDatabase> + +#include "smtreemodel.h" + +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 }; + enum Fields { Name = 0, SeriesId = 1, SeriesPartId = 2, SeriesPart = 3, Type = 4 }; + enum Types { Series, Part }; + explicit SeriesTreeModel(QStringList &headers, QObject *parent = 0); + ~SeriesTreeModel(); + + //data + flags + Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant data(const QModelIndex &index, int role) const; + bool setData(const QModelIndex &index, const QVariant &value, int role); + + //find + QModelIndex findValue(const QVariant &value, const QModelIndex &parent = QModelIndex(), int column = 0) const; + + private: + void populate(); + QSqlDatabase mDb; + QSqlQuery *mSeriesPartsQuery; + QSqlQuery *mUpdateSeriesIdQuery; + QSqlQuery *mUpdateSeriesNameQuery; + QSqlQuery *mDeleteSeriesQuery; +}; + +#endif // SERIESTREEMODEL_H |