[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=6352f8a
The following commit has been merged in the master branch:
commit 6352f8af2e460fe033d7189e2eee7a65f4b925aa
Author: Lasath Fernando <kde at lasath.org>
Date: Wed Nov 30 23:47:12 2011 +1100
Created a ConversationsModel class that contains a list of Active Conversations.
Changed plasmoid to display said list.
---
KTp/Declarative/conversation.cpp | 17 ++++--
KTp/Declarative/conversation.h | 10 ++--
KTp/Declarative/conversations-model.cpp | 68 ++++++++++++++++++++++
...pathy-text-observer.h => conversations-model.h} | 31 ++++++----
4 files changed, 105 insertions(+), 21 deletions(-)
diff --git a/KTp/Declarative/conversation.cpp b/KTp/Declarative/conversation.cpp
index 63adfda..470c568 100644
--- a/KTp/Declarative/conversation.cpp
+++ b/KTp/Declarative/conversation.cpp
@@ -44,7 +44,7 @@ Conversation::Conversation ( Tp::TextChannelPtr channel, Tp::AccountPtr account
d->account = account;
d->contact = channel->targetContact();
- connect(d->contact.constData(), SIGNAL(aliasChanged(QString)), SIGNAL(onNickChanged(QString)));
+ connect(d->contact.constData(), SIGNAL(aliasChanged(QString)), SIGNAL(nickChanged(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)));
}
@@ -59,9 +59,9 @@ ConversationModel* Conversation::model() const
return d->model;
}
-KIcon Conversation::avatar() const
+QIcon Conversation::avatar() const
{
- return KIcon(d->contact->avatarData().fileName);
+ return QIcon(d->contact->avatarData().fileName);
}
QString Conversation::nick() const
@@ -69,7 +69,7 @@ QString Conversation::nick() const
return d->contact->alias();
}
-KIcon Conversation::presenceIcon() const
+QIcon Conversation::presenceIcon() const
{
return ChatWidget::iconForPresence(d->contact->presence().type());
}
@@ -80,3 +80,12 @@ Conversation::~Conversation()
delete d->model;
}
+void Conversation::onPresenceChanged ( Tp::Presence )
+{
+ Q_EMIT presenceIconChanged(presenceIcon());
+}
+
+void Conversation::onAvatarDataChanged ( Tp::AvatarData )
+{
+ Q_EMIT avatarChanged(avatar());
+}
diff --git a/KTp/Declarative/conversation.h b/KTp/Declarative/conversation.h
index caaf3ce..61ea7da 100644
--- a/KTp/Declarative/conversation.h
+++ b/KTp/Declarative/conversation.h
@@ -36,9 +36,9 @@ Q_OBJECT
Q_PROPERTY(ConversationModel* model READ model NOTIFY modelChanged)
-Q_PROPERTY(KIcon avatar READ avatar NOTIFY avatarChanged);
+Q_PROPERTY(QIcon avatar READ avatar NOTIFY avatarChanged);
Q_PROPERTY(QString nick READ nick NOTIFY nickChanged);
-Q_PROPERTY(KIcon presenceIcon READ presenceIcon NOTIFY presenceIconChanged);
+Q_PROPERTY(QIcon presenceIcon READ presenceIcon NOTIFY presenceIconChanged);
public:
Conversation(Tp::TextChannelPtr channel, Tp::AccountPtr account);
@@ -47,9 +47,9 @@ public:
ConversationModel* model() const;
- KIcon avatar() const;
+ QIcon avatar() const;
QString nick() const;
- KIcon presenceIcon() const;
+ QIcon presenceIcon() const;
Q_SIGNALS:
void modelChanged(ConversationModel* newModel);
@@ -61,7 +61,7 @@ Q_SIGNALS:
private Q_SLOTS:
void onAvatarDataChanged ( Tp::AvatarData );
void onPresenceChanged ( Tp::Presence );
- void onAliasChanged ( Tp::AvatarData );
+// void onAliasChanged ( Tp::AvatarData );
private:
class ConversationPrivate;
diff --git a/KTp/Declarative/conversations-model.cpp b/KTp/Declarative/conversations-model.cpp
new file mode 100644
index 0000000..677f53c
--- /dev/null
+++ b/KTp/Declarative/conversations-model.cpp
@@ -0,0 +1,68 @@
+/*
+ <one line to give the library's name and an idea of what it does.>
+ Copyright (C) 2011 <copyright holder> <email>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#include "conversations-model.h"
+#include "conversation-watcher.h"
+#include "conversation.h"
+
+class ConversationsModel::ConversationsModelPrivate
+{
+public:
+ ConversationWatcher watcher;
+ QList<Conversation*> data;
+};
+
+QVariant ConversationsModel::data ( const QModelIndex& index, int role ) const
+{
+ QVariant result();
+ if(index.row() >= 0 && index.row() < d->data.count()) {
+ Q_ASSERT(role == ConversationRole);
+ return QVariant::fromValue<QObject*>(d->data[index.row()]);
+ }
+ return result;
+}
+
+int ConversationsModel::rowCount ( const QModelIndex& parent ) const
+{
+ return d->data.count();
+}
+
+ConversationsModel::ConversationsModel() :
+ d(new ConversationsModelPrivate)
+{
+ QHash<int, QByteArray> roles;
+ roles[ConversationRole] = "conversation";
+ setRoleNames(roles);
+
+ QObject::connect(&d->watcher, SIGNAL(newConversation(Conversation*)), SLOT(onInconmingConversation(Conversation*)));
+}
+
+void ConversationsModel::onInconmingConversation ( Conversation* convo )
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+
+ d->data.append(convo);
+ endInsertRows();
+}
+
+ConversationsModel::~ConversationsModel()
+{
+ delete d;
+}
diff --git a/KTp/Declarative/telepathy-text-observer.h b/KTp/Declarative/conversations-model.h
similarity index 60%
copy from KTp/Declarative/telepathy-text-observer.h
copy to KTp/Declarative/conversations-model.h
index 3ea80c0..26d9e2d 100644
--- a/KTp/Declarative/telepathy-text-observer.h
+++ b/KTp/Declarative/conversations-model.h
@@ -18,27 +18,34 @@
*/
-#ifndef CONVERSATION_WATCHER_H
-#define CONVERSATION_WATCHER_H
+#ifndef CONVERSATIONS_MODEL_H
+#define CONVERSATIONS_MODEL_H
+#include <QAbstractListModel>
#include "kdetelepathychat_export.h"
-#include <TelepathyQt4/AbstractClient>
class Conversation;
-class KDE_TELEPATHY_CHAT_EXPORT ConversationWatcher : public QObject
+class KDE_TELEPATHY_CHAT_EXPORT ConversationsModel : public QAbstractListModel
{
Q_OBJECT
-
public:
- ConversationWatcher();
- ~ConversationWatcher();
+ ConversationsModel();
+ virtual ~ConversationsModel();
+
+ virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const;
+ virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const;
+
+ enum role {
+ ConversationRole = Qt::UserRole
+ };
-Q_SIGNALS:
- void newConversation(Conversation *con);
private:
- class ConversationClientObserver;
- Tp::SharedPtr<ConversationClientObserver> d;
+ class ConversationsModelPrivate;
+ ConversationsModelPrivate* d;
+
+private Q_SLOTS:
+ void onInconmingConversation(Conversation *convo);
};
-#endif // CONVERSATION_WATCHER_H
+#endif // CONVERSATIONS_MODEL_H
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list