diff options
author | Alvaro Soliverez <alvaro.soliverez@collabora.co.uk> | 2011-08-05 11:23:34 -0700 |
---|---|---|
committer | Alvaro Soliverez <alvaro.soliverez@collabora.co.uk> | 2011-08-05 11:23:34 -0700 |
commit | b643230827c597e0e1dcfd431828d874eaa3f1e1 (patch) | |
tree | 9bf797cebc0a859324171d4894ac5dc565985347 | |
parent | 16b86b402c903555ffe88fedbb2f1bcfe7cffc10 (diff) |
Add id and presence type roles to AbstractConversationModel
Also, It should be possible to send messages with non-default type and flags
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | TelepathyQt4Yell/Models/abstract-conversation-model.cpp | 25 | ||||
-rw-r--r-- | TelepathyQt4Yell/Models/abstract-conversation-model.h | 4 | ||||
-rw-r--r-- | TelepathyQt4Yell/Models/session-conversation-model.cpp | 6 | ||||
-rw-r--r-- | TelepathyQt4Yell/Models/session-conversation-model.h | 2 |
5 files changed, 35 insertions, 4 deletions
@@ -10,6 +10,7 @@ Enhancements: * Add ServiceNameRole to AccountsModel * Add method to remove contact in ContactModelItem * Add method to request or remove subscription in ContactModelItem + * Add id and presence type roles to AbstractConversationModel Fixes: * Report the connection status reason using the Connection object if possible @@ -21,6 +22,7 @@ Fixes: * When setting status and statusMessage on Tpy::AccountsModelItem do not clear the presence type * Do not remove contact when rejecting publication * Do not request subscription automatically when accepting publication of a contact + * It should be possible to send messages with non-default type and flags telepathy-qt4-yell 0.1.6 (2011-06-06) ====================================== diff --git a/TelepathyQt4Yell/Models/abstract-conversation-model.cpp b/TelepathyQt4Yell/Models/abstract-conversation-model.cpp index 35ec4d5..e5a2fce 100644 --- a/TelepathyQt4Yell/Models/abstract-conversation-model.cpp +++ b/TelepathyQt4Yell/Models/abstract-conversation-model.cpp @@ -28,6 +28,7 @@ #include <TelepathyQt4/AvatarData> #include <TelepathyQt4/PendingReady> +#include <TelepathyQt4/Presence> #include <TelepathyQt4/ReceivedMessage> #include <QPixmap> @@ -53,9 +54,13 @@ AbstractConversationModel::AbstractConversationModel(QObject *parent) QHash<int, QByteArray> roles; roles[EventTypeRole] = "eventType"; roles[SenderRole] = "sender"; + roles[SenderIdRole] = "senderId"; roles[SenderAvatarRole] = "senderAvatar"; + roles[SenderPresenceTypeRole] = "senderPresenceType"; roles[ReceiverRole] = "receiver"; + roles[ReceiverIdRole] = "receiverId"; roles[ReceiverAvatarRole] = "receiverAvatar"; + roles[ReceiverPresenceTypeRole] = "receiverPresenceType"; roles[DateTimeRole] = "dateTime"; roles[ItemRole] = "item"; roles[MessageTextRole] = "messageText"; @@ -102,21 +107,41 @@ QVariant AbstractConversationModel::data(const QModelIndex &index, int role) con return item->sender()->alias(); } return QVariant(); + case SenderIdRole: + if (!item->sender().isNull()) { + return item->sender()->id(); + } + return QVariant(); case SenderAvatarRole: if (!item->sender().isNull()) { return item->sender()->avatarData().fileName; } return QVariant(); + case SenderPresenceTypeRole: + if (!item->sender().isNull()) { + return item->sender()->presence().type(); + } + return QVariant(); case ReceiverRole: if (!item->receiver().isNull()) { return item->receiver()->alias(); } return QVariant(); + case ReceiverIdRole: + if (!item->receiver().isNull()) { + return item->receiver()->id(); + } + return QVariant(); case ReceiverAvatarRole: if (!item->receiver().isNull()) { return item->receiver()->avatarData().fileName; } return QVariant(); + case ReceiverPresenceTypeRole: + if (!item->receiver().isNull()) { + return item->receiver()->presence().type(); + } + return QVariant(); case DateTimeRole: return item->dateTime(); case ItemRole: diff --git a/TelepathyQt4Yell/Models/abstract-conversation-model.h b/TelepathyQt4Yell/Models/abstract-conversation-model.h index 7413606..2779a85 100644 --- a/TelepathyQt4Yell/Models/abstract-conversation-model.h +++ b/TelepathyQt4Yell/Models/abstract-conversation-model.h @@ -46,9 +46,13 @@ public: enum Role { EventTypeRole = Qt::UserRole, SenderRole, + SenderIdRole, SenderAvatarRole, + SenderPresenceTypeRole, ReceiverRole, + ReceiverIdRole, ReceiverAvatarRole, + ReceiverPresenceTypeRole, DateTimeRole, ItemRole, MessageTextRole, diff --git a/TelepathyQt4Yell/Models/session-conversation-model.cpp b/TelepathyQt4Yell/Models/session-conversation-model.cpp index 7af29bf..639f6e3 100644 --- a/TelepathyQt4Yell/Models/session-conversation-model.cpp +++ b/TelepathyQt4Yell/Models/session-conversation-model.cpp @@ -70,7 +70,7 @@ SessionConversationModel::~SessionConversationModel() delete mPriv; } -void SessionConversationModel::sendMessage(const QString &text) +void SessionConversationModel::sendMessage(const QString &text, Tp::ChannelTextMessageType type, Tp::MessageSendingFlags flags) { Tp::ContactPtr receiver; if (!mPriv->mChannel.isNull() && @@ -81,10 +81,10 @@ void SessionConversationModel::sendMessage(const QString &text) receiver = mPriv->mChannel->connection()->contactManager()->lookupContactByHandle(handle); } TextEventItem *item = new TextEventItem(mPriv->mSelf, receiver, - QDateTime::currentDateTime(), text, Tp::ChannelTextMessageTypeNormal, this); + QDateTime::currentDateTime(), text, type, this); addItem(item); - mPriv->mChannel->send(item->messageText()); + mPriv->mChannel->send(item->messageText(), type, flags); } Tp::ContactPtr SessionConversationModel::selfContact() const diff --git a/TelepathyQt4Yell/Models/session-conversation-model.h b/TelepathyQt4Yell/Models/session-conversation-model.h index e84a551..705b795 100644 --- a/TelepathyQt4Yell/Models/session-conversation-model.h +++ b/TelepathyQt4Yell/Models/session-conversation-model.h @@ -48,7 +48,7 @@ public: explicit SessionConversationModel(const Tp::ContactPtr &self, const Tp::TextChannelPtr &channel, QObject *parent = 0); virtual ~SessionConversationModel(); - Q_INVOKABLE void sendMessage(const QString &text); + Q_INVOKABLE void sendMessage(const QString &text, Tp::ChannelTextMessageType type=Tp::ChannelTextMessageTypeNormal, Tp::MessageSendingFlags flags=0); Q_INVOKABLE void disconnectChannelQueue(); Q_INVOKABLE void connectChannelQueue(); Q_INVOKABLE bool channelQueueConnected() const; |