[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:04:49 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=2e062a5
The following commit has been merged in the master branch:
commit 2e062a5dcba70e7b1424ebf997eecd59464c99bf
Author: Lasath Fernando <kde at lasath.org>
Date: Sat Nov 26 16:01:53 2011 +1100
Added a LineEdit to the plasmoid and a sendNewMessage slot to ConversationModel.
Also made the ListView auto-scroll
---
KTp/Declarative/conversation.cpp | 24 +++++++++++++++++++++++-
KTp/Declarative/conversation.h | 19 +++++++++++++++++++
KTp/Declarative/messages-model.cpp | 24 +++++++++++++++++++++++-
KTp/Declarative/messages-model.h | 4 ++++
4 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/KTp/Declarative/conversation.cpp b/KTp/Declarative/conversation.cpp
index fc96d91..63adfda 100644
--- a/KTp/Declarative/conversation.cpp
+++ b/KTp/Declarative/conversation.cpp
@@ -23,12 +23,14 @@
#include <TelepathyQt4/TextChannel>
#include <KDebug>
+#include "chat-widget.h"
class Conversation::ConversationPrivate
{
public:
ConversationModel* model;
Tp::AccountPtr account;
+ Tp::ContactPtr contact;
};
Conversation::Conversation ( Tp::TextChannelPtr channel, Tp::AccountPtr account ) :
@@ -40,11 +42,16 @@ Conversation::Conversation ( Tp::TextChannelPtr channel, Tp::AccountPtr account
d->model->setTextChannel ( channel );
d->account = account;
+ d->contact = channel->targetContact();
+
+ connect(d->contact.constData(), SIGNAL(aliasChanged(QString)), SIGNAL(onNickChanged(QString)));
+ connect(d->contact.constData(), SIGNAL(avatarDataChanged(Tp::AvatarData)), SLOT(onAvatarDataChanged(Tp::AvatarData)));
+ connect(d->contact.constData(), SIGNAL(presenceChanged(Tp::Presence)), SLOT(onPresenceChanged(Tp::Presence)));
}
Conversation::Conversation ( QObject* parent ) : QObject ( parent )
{
- kError() << "Conversation should not be created directly. Use ConversationWater instead.";
+ kError() << "Conversation should not be created directly. Use ConversationWatcher instead.";
}
ConversationModel* Conversation::model() const
@@ -52,6 +59,21 @@ ConversationModel* Conversation::model() const
return d->model;
}
+KIcon Conversation::avatar() const
+{
+ return KIcon(d->contact->avatarData().fileName);
+}
+
+QString Conversation::nick() const
+{
+ return d->contact->alias();
+}
+
+KIcon Conversation::presenceIcon() const
+{
+ return ChatWidget::iconForPresence(d->contact->presence().type());
+}
+
Conversation::~Conversation()
{
kDebug();
diff --git a/KTp/Declarative/conversation.h b/KTp/Declarative/conversation.h
index b68800f..caaf3ce 100644
--- a/KTp/Declarative/conversation.h
+++ b/KTp/Declarative/conversation.h
@@ -27,13 +27,19 @@
#include <TelepathyQt4/Account>
#include <TelepathyQt4/TextChannel>
#include "conversation-model.h"
+#include <KIcon>
class ConversationModel;
class KDE_TELEPATHY_CHAT_EXPORT Conversation : public QObject
{
Q_OBJECT
+
Q_PROPERTY(ConversationModel* model READ model NOTIFY modelChanged)
+Q_PROPERTY(KIcon avatar READ avatar NOTIFY avatarChanged);
+Q_PROPERTY(QString nick READ nick NOTIFY nickChanged);
+Q_PROPERTY(KIcon presenceIcon READ presenceIcon NOTIFY presenceIconChanged);
+
public:
Conversation(Tp::TextChannelPtr channel, Tp::AccountPtr account);
Conversation(QObject* parent = 0);
@@ -41,9 +47,22 @@ public:
ConversationModel* model() const;
+ KIcon avatar() const;
+ QString nick() const;
+ KIcon presenceIcon() const;
+
Q_SIGNALS:
void modelChanged(ConversationModel* newModel);
+ void avatarChanged(QIcon avatar);
+ void nickChanged(QString nick);
+ void presenceIconChanged(QIcon icon);
+
+private Q_SLOTS:
+ void onAvatarDataChanged ( Tp::AvatarData );
+ void onPresenceChanged ( Tp::Presence );
+ void onAliasChanged ( Tp::AvatarData );
+
private:
class ConversationPrivate;
ConversationPrivate *d;
diff --git a/KTp/Declarative/messages-model.cpp b/KTp/Declarative/messages-model.cpp
index d6bf810..5b1b056 100644
--- a/KTp/Declarative/messages-model.cpp
+++ b/KTp/Declarative/messages-model.cpp
@@ -62,6 +62,15 @@ Tp::TextChannelPtr ConversationModel::textChannel()
return d->textChannel;
}
+bool ConversationModel::verifyPendingOperation ( Tp::PendingOperation* op )
+{
+ bool success = !op->isError();
+ if(!success) {
+ kWarning() << op->errorName() + QLatin1Char(':') + op->errorMessage();
+ }
+ return success;
+}
+
void ConversationModel::setupChannelSignals(Tp::TextChannelPtr channel)
{
QObject::connect(channel.constData(),
@@ -80,7 +89,7 @@ void ConversationModel::setTextChannel(Tp::TextChannelPtr channel)
if(d->textChannel) {
removeChannelSignals(channel);
}
- d->textChannel = channel;
+ d->textChannel = channel; //FIXME: check if channel is valid
textChannelChanged(channel);
}
@@ -155,6 +164,19 @@ int ConversationModel::rowCount(const QModelIndex& parent) const
return d->messages.size();
}
+Tp::PendingSendMessage* ConversationModel::sendNewMessage ( QString message )
+{
+ Tp::PendingSendMessage* msg = 0;
+ if(message.isEmpty()) {
+ kWarning() << "Attempting to send empty string";
+ } else {
+ msg = d->textChannel->send(message);
+ connect(msg, SIGNAL(finished(Tp::PendingOperation*)), SLOT(verifyPendingOperation(Tp::PendingOperation*)));
+ }
+
+ return msg;
+}
+
void ConversationModel::removeChannelSignals(Tp::TextChannelPtr channel)
{
QObject::disconnect(channel.constData(),
diff --git a/KTp/Declarative/messages-model.h b/KTp/Declarative/messages-model.h
index 06affa6..e44b217 100644
--- a/KTp/Declarative/messages-model.h
+++ b/KTp/Declarative/messages-model.h
@@ -56,9 +56,13 @@ public:
Q_SIGNALS:
void textChannelChanged(Tp::TextChannelPtr newChannel);
+public Q_SLOTS:
+ Tp::PendingSendMessage* sendNewMessage(QString message);
+
private Q_SLOTS:
void onMessageReceived(Tp::ReceivedMessage);
void onMessageSent(Tp::Message,Tp::MessageSendingFlags,QString);
+ bool verifyPendingOperation(Tp::PendingOperation* op);
private:
void setupChannelSignals(Tp::TextChannelPtr channel);
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list