1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
|