Changeset View
Changeset View
Standalone View
Standalone View
smsapp/conversationmodel.cpp
Show All 13 Lines | |||||
14 | * Lesser General Public License for more details. | 14 | * Lesser General Public License for more details. | ||
15 | * | 15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | 16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with this library; if not, write to the Free Software | 17 | * License along with this library; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "conversationmodel.h" | 21 | #include "conversationmodel.h" | ||
22 | #include <QLoggingCategory> | ||||
23 | | ||||
24 | Q_LOGGING_CATEGORY(KDECONNECT_SMS_CONVERSATION_MODEL, "kdeconnect.sms.conversation") | ||||
22 | 25 | | |||
23 | ConversationModel::ConversationModel(QObject* parent) | 26 | ConversationModel::ConversationModel(QObject* parent) | ||
24 | : QStandardItemModel(parent) | 27 | : QStandardItemModel(parent) | ||
28 | , m_conversationsInterface(nullptr) | ||||
25 | { | 29 | { | ||
26 | auto roles = roleNames(); | 30 | auto roles = roleNames(); | ||
27 | roles.insert(FromMeRole, "fromMe"); | 31 | roles.insert(FromMeRole, "fromMe"); | ||
28 | setItemRoleNames(roles); | 32 | setItemRoleNames(roles); | ||
29 | } | 33 | } | ||
30 | 34 | | |||
35 | ConversationModel::~ConversationModel() | ||||
36 | { | ||||
37 | if (m_conversationsInterface) delete m_conversationsInterface; | ||||
38 | } | ||||
39 | | ||||
31 | QString ConversationModel::threadId() const | 40 | QString ConversationModel::threadId() const | ||
32 | { | 41 | { | ||
42 | qCCritical(KDECONNECT_SMS_CONVERSATION_MODEL) << "Hi"; | ||||
33 | return {}; | 43 | return {}; | ||
34 | } | 44 | } | ||
35 | 45 | | |||
36 | void ConversationModel::setThreadId(const QString &threadId) | 46 | void ConversationModel::setThreadId(const QString &threadId) | ||
37 | { | 47 | { | ||
48 | qCCritical(KDECONNECT_SMS_CONVERSATION_MODEL) << "Setting threadId of" << this << "to" << threadId; | ||||
49 | m_threadId = threadId; | ||||
38 | clear(); | 50 | clear(); | ||
39 | appendRow(new QStandardItem(threadId + QStringLiteral(" - A"))); | 51 | appendRow(new QStandardItem(threadId + QStringLiteral(" - A"))); | ||
40 | appendRow(new QStandardItem(threadId + QStringLiteral(" - A1"))); | 52 | appendRow(new QStandardItem(threadId + QStringLiteral(" - A1"))); | ||
41 | appendRow(new QStandardItem(threadId + QStringLiteral(" - A2"))); | 53 | appendRow(new QStandardItem(threadId + QStringLiteral(" - A2"))); | ||
42 | appendRow(new QStandardItem(threadId + QStringLiteral(" - A3"))); | 54 | appendRow(new QStandardItem(threadId + QStringLiteral(" - A3"))); | ||
43 | } | 55 | } | ||
56 | | ||||
57 | void ConversationModel::setDeviceId(const QString& deviceId) | ||||
58 | { | ||||
59 | qCCritical(KDECONNECT_SMS_CONVERSATION_MODEL) << "setDeviceId" << "of" << this; | ||||
60 | if (m_conversationsInterface) delete m_conversationsInterface; | ||||
61 | | ||||
62 | m_deviceId = deviceId; | ||||
63 | | ||||
64 | m_conversationsInterface = new DeviceConversationsDbusInterface(deviceId); | ||||
65 | } | ||||
66 | | ||||
67 | void ConversationModel::sendReplyToConversation(const QString& message) | ||||
68 | { | ||||
69 | qCCritical(KDECONNECT_SMS_CONVERSATION_MODEL) << "Should have sent " << message; | ||||
70 | m_conversationsInterface->replyToConversation(m_threadId, message); | ||||
71 | } |