Changeset View
Changeset View
Standalone View
Standalone View
smsapp/conversationmodel.h
Show All 18 Lines | |||||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #ifndef CONVERSATIONMODEL_H | 22 | #ifndef CONVERSATIONMODEL_H | ||
23 | #define CONVERSATIONMODEL_H | 23 | #define CONVERSATIONMODEL_H | ||
24 | 24 | | |||
25 | #include <QStandardItemModel> | 25 | #include <QStandardItemModel> | ||
26 | #include <QLoggingCategory> | 26 | #include <QLoggingCategory> | ||
27 | #include <QSet> | ||||
27 | 28 | | |||
28 | #include "interfaces/dbusinterfaces.h" | 29 | #include "interfaces/dbusinterfaces.h" | ||
29 | 30 | | |||
30 | Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_SMS_CONVERSATION_MODEL) | 31 | Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_SMS_CONVERSATION_MODEL) | ||
31 | 32 | | |||
33 | #define INVALID_THREAD_ID -1 | ||||
34 | | ||||
32 | class ConversationModel | 35 | class ConversationModel | ||
33 | : public QStandardItemModel | 36 | : public QStandardItemModel | ||
34 | { | 37 | { | ||
35 | Q_OBJECT | 38 | Q_OBJECT | ||
36 | Q_PROPERTY(QString threadId READ threadId WRITE setThreadId) | 39 | Q_PROPERTY(qint32 threadId READ threadId WRITE setThreadId) | ||
37 | Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId) | 40 | Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId) | ||
38 | 41 | | |||
39 | public: | 42 | public: | ||
40 | ConversationModel(QObject* parent = nullptr); | 43 | ConversationModel(QObject* parent = nullptr); | ||
41 | ~ConversationModel(); | 44 | ~ConversationModel(); | ||
42 | 45 | | |||
43 | enum Roles { | 46 | enum Roles { | ||
44 | FromMeRole = Qt::UserRole, | 47 | FromMeRole = Qt::UserRole, | ||
45 | DateRole, | 48 | DateRole, | ||
46 | }; | 49 | }; | ||
47 | 50 | | |||
48 | Q_ENUM(Roles) | 51 | Q_ENUM(Roles) | ||
49 | 52 | | |||
50 | QString threadId() const; | 53 | qint32 threadId() const; | ||
51 | void setThreadId(const QString &threadId); | 54 | void setThreadId(const qint32& threadId); | ||
52 | 55 | | |||
53 | QString deviceId() const { return m_deviceId; } | 56 | QString deviceId() const { return m_deviceId; } | ||
54 | void setDeviceId(const QString &/*deviceId*/); | 57 | void setDeviceId(const QString &/*deviceId*/); | ||
55 | 58 | | |||
56 | Q_INVOKABLE void sendReplyToConversation(const QString& message); | 59 | Q_INVOKABLE void sendReplyToConversation(const QString& message); | ||
60 | Q_INVOKABLE void requestMoreMessages(const quint32& howMany = 10); | ||||
57 | 61 | | |||
58 | private Q_SLOTS: | 62 | private Q_SLOTS: | ||
59 | void createRowFromMessage(const QVariantMap &msg, int pos); | 63 | void createRowFromMessage(const QVariantMap &msg, int pos); | ||
60 | void handleConversationUpdate(const QVariantMap &msg); | 64 | void handleConversationUpdate(const QVariantMap &msg); | ||
61 | 65 | | |||
62 | private: | 66 | private: | ||
63 | DeviceConversationsDbusInterface* m_conversationsInterface; | 67 | DeviceConversationsDbusInterface* m_conversationsInterface; | ||
64 | QString m_deviceId; | 68 | QString m_deviceId; | ||
65 | QString m_threadId; | 69 | qint32 m_threadId = INVALID_THREAD_ID; | ||
70 | QSet<qint32> knownMessageIDs; | ||||
66 | }; | 71 | }; | ||
67 | 72 | | |||
68 | #endif // CONVERSATIONMODEL_H | 73 | #endif // CONVERSATIONMODEL_H |