-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscoresmodel.h
More file actions
45 lines (30 loc) · 1.39 KB
/
Copy pathscoresmodel.h
File metadata and controls
45 lines (30 loc) · 1.39 KB
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
44
45
#ifndef SCORESMODEL_H
#define SCORESMODEL_H
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
#include "database.h"
class ScoresModel : public QAbstractItemModel
{
Q_OBJECT
public:
ScoresModel(QObject* parent = NULL);
~ScoresModel() {}
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& index) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
DataBase::SScore* scores() { return &m_scores; }
bool addScore(const QString& name, quint64 flags = DataBase::eNone, const QModelIndex& parent = QModelIndex());
bool removeScore(const QModelIndex& index);
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
signals:
void error(const QString& title, const QString& text);
private:
bool _find(qint64 id, const DataBase::SScore& root, int pos, DataBase::SScore** retScore, int& retRow) const;
DataBase::SScore m_scores;
};
#endif // SCORESMODEL_H