-
Notifications
You must be signed in to change notification settings - Fork 1
/
postmodel.h
45 lines (36 loc) · 1.22 KB
/
postmodel.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
#ifndef POSTMODEL_H
#define POSTMODEL_H
#define END_OF_CONTENT "##eof_content##"
#include "post.h"
#include <QObject>
#include <QAbstractListModel>
#include <iostream>
#include <QFile>
#include <QStandardPaths>
#include <QTextStream>
#include <QUrl>
using namespace std;
class PostModel : public QAbstractListModel
{
Q_OBJECT
private:
int points;
vector<Post> postData;
QString modelFilePath;
public:
enum PostRoles {
TitleRole = Qt::UserRole + 1,
DateRole, ContentRole, ReactionRole, WeightRole, CaloriesRole, RunRole, PhotosRole
};
PostModel(QString path);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QHash<int, QByteArray> roleNames() const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
void insertPost(QString title, QDateTime date, QString content, QString reaction, quint16 weight, quint16 calories, bool run, QList<QUrl> photos);
void editPost(int index, QString title, QDateTime date, QString content, QString reaction, quint16 weight, quint16 calories, bool run, QList<QUrl> photos);
void deletePost(int index);
void addPoints(int points);
void loadModel();
void saveModel();
};
#endif // POSTMODEL_H