Warning, file /network/kdeconnect-kde/smsapp/conversationmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /**
0002  * SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@kde.org>
0003  * SPDX-FileCopyrightText: 2018 Simon Redman <simon@ergotech.com>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006  */
0007 
0008 #ifndef CONVERSATIONMODEL_H
0009 #define CONVERSATIONMODEL_H
0010 
0011 #include <QSet>
0012 #include <QStandardItemModel>
0013 
0014 #include "interfaces/conversationmessage.h"
0015 #include "interfaces/dbusinterfaces.h"
0016 #include "thumbnailsprovider.h"
0017 
0018 #define INVALID_THREAD_ID -1
0019 
0020 class ConversationModel : public QStandardItemModel
0021 {
0022     Q_OBJECT
0023     Q_PROPERTY(qint64 threadId READ threadId WRITE setThreadId)
0024     Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId)
0025     Q_PROPERTY(QList<ConversationAddress> addressList READ addressList WRITE setAddressList)
0026 
0027 public:
0028     ConversationModel(QObject *parent = nullptr);
0029     ~ConversationModel() override;
0030 
0031     enum Roles {
0032         FromMeRole = Qt::UserRole,
0033         SenderRole, // The sender of the message. Undefined if this is an outgoing message
0034         DateRole,
0035         AvatarRole, // URI to the avatar of the sender of the message. Undefined if outgoing.
0036         AttachmentsRole, // The list of attachments. Undefined if there is no attachment in a message
0037     };
0038 
0039     Q_ENUM(Roles)
0040 
0041     qint64 threadId() const;
0042     void setThreadId(const qint64 &threadId);
0043 
0044     QString deviceId() const
0045     {
0046         return m_deviceId;
0047     }
0048     void setDeviceId(const QString & /*deviceId*/);
0049 
0050     QList<ConversationAddress> addressList() const
0051     {
0052         return m_addressList;
0053     }
0054     void setAddressList(const QList<ConversationAddress> &addressList);
0055 
0056     Q_INVOKABLE bool sendReplyToConversation(const QString &textMessage, QList<QUrl> attachmentUrls);
0057     Q_INVOKABLE bool startNewConversation(const QString &textMessage, const QList<ConversationAddress> &addressList, QList<QUrl> attachmentUrls);
0058     Q_INVOKABLE void requestMoreMessages(const quint32 &howMany = 10);
0059 
0060     Q_INVOKABLE QString getCharCountInfo(const QString &message) const;
0061 
0062     Q_INVOKABLE void requestAttachmentPath(const qint64 &partID, const QString &UniqueIdentifier);
0063 
0064 Q_SIGNALS:
0065     void loadingFinished();
0066     void filePathReceived(QString filePath, QString fileName);
0067 
0068 private Q_SLOTS:
0069     void handleConversationUpdate(const QDBusVariant &message);
0070     void handleConversationLoaded(qint64 threadID, quint64 numMessages);
0071     void handleConversationCreated(const QDBusVariant &message);
0072 
0073 private:
0074     void createRowFromMessage(const ConversationMessage &message, int pos);
0075 
0076     DeviceConversationsDbusInterface *m_conversationsInterface;
0077     ThumbnailsProvider *m_thumbnailsProvider;
0078     QString m_deviceId;
0079     qint64 m_threadId = INVALID_THREAD_ID;
0080     QList<ConversationAddress> m_addressList;
0081     QSet<qint32> knownMessageIDs; // Set of known Message uIDs
0082 };
0083 
0084 #endif // CONVERSATIONMODEL_H