-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemberlistmodel.h
65 lines (52 loc) · 1.62 KB
/
memberlistmodel.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
#ifndef MEMBERLISTMODEL_H
#define MEMBERLISTMODEL_H
#include "member.h"
#include <QObject>
#include <QSqlTableModel>
#include <QSqlError>
#include <QDebug>
#include <QBrush>
#include <QMap>
#define DATEFORMAT "yyyy-MM-dd"
enum MemberListRoles{
DataTypeRole = Qt::UserRole
};
enum MemberListDataTypes{
Integer,
String,
Date,
Bool
};
class MemberlistModel : public QSqlTableModel
{
Q_OBJECT
private:
QMap<int, int> checkedStatus;
QString searchString;
bool exMembersVisible;
int maxId;
/**make a brush for drawing the background of a row*/
QBrush makeBackground(int row) const;
/**make a brush for drawing the Foreground of a row*/
QBrush makeForeground(int row) const;
public:
Qt::ItemFlags flags(const QModelIndex &index) const;
explicit MemberlistModel( QSqlDatabase db, QObject *parent = 0);
QVariant data(const QModelIndex &idx, int role) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
//export the selected members as a csv string with only the named fields
QString exportCsv(const QStringList &list);
QString exportEmail();
virtual bool updateRowInTable(int row, const QSqlRecord &values);
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
int getId(const QModelIndex &index) const;
int getId(const int row) const;
signals:
public slots:
void addMember(const Member &member);
void setExMembersVisible(bool visible); void setSearch(QString search);
void onUpdate(int row, QSqlRecord& record);
void selectAll();
void clearSelection();
};
#endif // MEMBERLISTMODEL_H