-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoimodel.h
66 lines (51 loc) · 1.89 KB
/
hoimodel.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef HOIMODEL_H
#define HOIMODEL_H
#include <QQmlEngine>
#include <QAbstractItemModel>
#include <QSqlDatabase>
#include "hoisavenode.h"
class HoiModel: public QAbstractItemModel
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(QString currentFileName READ currentFileName WRITE setCurrentFileName NOTIFY currentFileNameChanged FINAL)
Q_PROPERTY(bool restoring READ restoring WRITE setRestoring NOTIFY restoringChanged FINAL)
Q_PROPERTY(QList<QString> listeningFiles READ listeningFiles WRITE setListeningFiles NOTIFY listeningFilesChanged FINAL)
public:
HoiModel(QObject *parent = nullptr);
private:
void initData();
void createTable();
void initListeningFiles();
public slots:
void addSaveNodeFromPath(const QString &path);
void restore(HoiSaveNode * node);
private:
QSqlDatabase m_db;
QList<QList<HoiSaveNode *> *> m_rows;
// QAbstractItemModel interface
QString m_currentFileName;
bool m_restoring;
bool m_saving;
QList<QString> m_listeningFiles;
public:
QModelIndex index(int row, int column, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QString currentFileName() const;
void setCurrentFileName(const QString &newCurrentFileName);
bool restoring() const;
void setRestoring(bool newRestoring);
QList<QString> listeningFiles() const;
void setListeningFiles(const QList<QString> &newListeningFiles);
bool saving() const;
void setSaving(bool newSaving);
signals:
void currentFileNameChanged();
void restoringChanged();
void notify(const QString & title, const QString & msg);
void listeningFilesChanged();
};
#endif // HOIMODEL_H