-
Notifications
You must be signed in to change notification settings - Fork 0
/
qfetionstoresms.h
105 lines (87 loc) · 2.73 KB
/
qfetionstoresms.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef QFETIONSTORESMS_H
#define QFETIONSTORESMS_H
#include <QAbstractListModel>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QMessageManager>
#include <QMessageId>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QDebug>
QTM_USE_NAMESPACE
struct QFetionMessage{
QString message;
QString date;
int status;
int id;
QFetionMessage(int p_id,QString p_message,QString p_date, int p_status){
id = p_id;
message = p_message;
date = p_date;
status = p_status;
}
void setStatus(int p_status)
{
status = p_status;
}
int getID()
{
return id;
}
};
class QFetionStoreSMSThread;
class QFetionStoreSMS : public QAbstractListModel
{
Q_OBJECT
public:
explicit QFetionStoreSMS(QObject *parent = 0);
Q_PROPERTY(QString uid READ getUid WRITE setUid NOTIFY uidChanged)
Q_PROPERTY(int limit READ getLimit WRITE setLimit NOTIFY limitChanged)
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const ;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const ;
QString getUid(){ return uid;}
void setUid(QString p_uid){ uid = p_uid; emit uidChanged();}
int getLimit() { return limit;}
void setLimit(int p_limit){limit = p_limit; emit limitChanged();}
Q_INVOKABLE int insertMessage(QString name,QString uid,QString message);
Q_INVOKABLE void upDateMessage(QString id,QString status);
enum Roles {
DateRole = Qt::DisplayRole,
StatusRole,
MessageRole
};
signals:
void uidChanged();
void initialSignal();
void limitChanged();
public slots:
void queryMessages();
void messageAdded ( const QMessageId & id, const QMessageManager::NotificationFilterIdSet & matchingFilterIds );
private:
QList<QFetionMessage> messageList;
QMessageManager *messageManager;
QSqlQuery query;
QString uid;
int limit;
QFetionStoreSMSThread *smsThread;
};
class QFetionStoreSMSThread:public QThread{
Q_OBJECT
public:
// NumThread(QObject *parent=0):QThread(parent){}
QFetionStoreSMSThread(QFetionStoreSMS *p_storesms):QThread(0){storesms= p_storesms;}
/*
void run(){
qDebug() << "begin messageManager";
messageManager = new QMessageManager(this);
connect(messageManager,SIGNAL(messageAdded(QMessageId,QMessageManager::NotificationFilterIdSet)),storesms,SLOT(messageAdded(QMessageId,QMessageManager::NotificationFilterIdSet)));
messageManager->registerNotificationFilter(QMessageFilter());
qDebug() <<"end messageMangager";
};
*/
private:
QFetionStoreSMS *storesms;
QMessageManager *messageManager;
};
#endif // QFETIONSTORESMS_H