[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:20:47 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=4649308
The following commit has been merged in the master branch:
commit 4649308d10568930ad4c5c2de930be552bd363e0
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.
---
lib/CMakeLists.txt | 2 +
lib/conversation.cpp | 17 +++--
lib/conversation.h | 10 +--
lib/conversations-model.cpp | 68 ++++++++++++++++++
...onversation-watcher.h => conversations-model.h} | 31 +++++----
lib/qml-plugins.cpp | 2 +
plasmoid/contents/ui/{main.qml => ChatWidget.qml} | 33 +++++++--
plasmoid/contents/ui/main.qml | 81 +++++-----------------
8 files changed, 152 insertions(+), 92 deletions(-)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c723f81..6405151 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -5,6 +5,7 @@ set(ktpchat_SRCS
conversation.cpp
conversation-model.cpp
conversation-watcher.cpp
+ conversations-model.cpp
adium-theme-view.cpp
adium-theme-header-info.cpp
adium-theme-message-info.cpp
@@ -30,6 +31,7 @@ set(ktpchat_HDRS
conversation.h
conversation-model.h
conversation-watcher.h
+ conversations-model.h
)
set(ktpchat_PRETTY_HDRS
diff --git a/lib/conversation.cpp b/lib/conversation.cpp
index 63adfda..470c568 100644
--- a/lib/conversation.cpp
+++ b/lib/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/lib/conversation.h b/lib/conversation.h
index caaf3ce..61ea7da 100644
--- a/lib/conversation.h
+++ b/lib/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/lib/conversations-model.cpp b/lib/conversations-model.cpp
new file mode 100644
index 0000000..677f53c
--- /dev/null
+++ b/lib/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/lib/conversation-watcher.h b/lib/conversations-model.h
similarity index 60%
copy from lib/conversation-watcher.h
copy to lib/conversations-model.h
index 3ea80c0..26d9e2d 100644
--- a/lib/conversation-watcher.h
+++ b/lib/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
diff --git a/lib/qml-plugins.cpp b/lib/qml-plugins.cpp
index cd19578..6889074 100644
--- a/lib/qml-plugins.cpp
+++ b/lib/qml-plugins.cpp
@@ -23,12 +23,14 @@
#include <QtDeclarative/QDeclarativeItem>
#include "conversation.h"
#include "conversation-watcher.h"
+#include "conversations-model.h"
void QmlPlugins::registerTypes ( const char* uri )
{
qmlRegisterType<ConversationWatcher> ( uri, 0, 1, "ConversationWatcher" );
qmlRegisterType<Conversation>(uri, 0, 1, "Conversation");
qmlRegisterType<ConversationModel> ( uri, 0, 1, "ConversationModel" );
+ qmlRegisterType<ConversationsModel>(uri, 0, 1, "ConversationsModel");
}
Q_EXPORT_PLUGIN2 ( conversation, QmlPlugins );
diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/ChatWidget.qml
similarity index 72%
copy from plasmoid/contents/ui/main.qml
copy to plasmoid/contents/ui/ChatWidget.qml
index 34cf530..71b0bfd 100644
--- a/plasmoid/contents/ui/main.qml
+++ b/plasmoid/contents/ui/ChatWidget.qml
@@ -1,33 +1,50 @@
import Qt 4.7
-import org.kde.telepathy.declarativeplugins 0.1 as KTelepathy
+import org.kde.telepathy.declarativeplugins 0.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
Item {
id:main
-
function derp() {
console.log("deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerp!");
return true;
}
+ property Conversation conv
+
+ PlasmaWidgets.IconWidget {
+ id: title
+ text: conv.nick
+ icon: conv.avatar
+ anchors.top: parent.top
+ anchors.left: parent.left; anchors.right: parent.right
+// anchors.bottom: chatArea.top
+ height: 12
+ orientation: Qt.Horizontal
+ }
+
Item {
id:chatArea
- anchors.top: parent.top
+// anchors.top: parent.top
+ anchors.top: title.bottom
anchors.left: parent.left; anchors.right: parent.right
anchors.bottom: input.top
anchors.margins: 5
+ Rectangle {
+ anchors.fill: chatArea
+ }
+
ListView {
id: view
anchors.fill: parent
clip: true
- delegate: TextDelegate {
- }
+ delegate: TextDelegate {}
+ model: conv.model
ListView.onAdd: {
derp();
}
@@ -49,6 +66,7 @@ Item {
}
}
]
+
}
PlasmaWidgets.LineEdit {
@@ -64,11 +82,12 @@ Item {
}
}
- KTelepathy.ConversationWatcher {
+ ConversationWatcher {
id:watcher
onNewConversation: {
console.log("New Convo!");
- view.model = con.model;
+ conv = con;
+// conv.model = con.model;
// view.model.rowsInserted.connect(view.positionViewAtEnd);
chatArea.state = "auto-scrolling";
}
diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml
index 34cf530..788a62e 100644
--- a/plasmoid/contents/ui/main.qml
+++ b/plasmoid/contents/ui/main.qml
@@ -1,76 +1,29 @@
import Qt 4.7
-import org.kde.telepathy.declarativeplugins 0.1 as KTelepathy
+import org.kde.telepathy.declarativeplugins 0.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
Item {
- id:main
-
-
- function derp() {
- console.log("deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerp!");
- return true;
- }
-
- Item {
- id:chatArea
-
- anchors.top: parent.top
- anchors.left: parent.left; anchors.right: parent.right
- anchors.bottom: input.top
- anchors.margins: 5
-
- ListView {
- id: view
-
- anchors.fill: parent
- clip: true
-
- delegate: TextDelegate {
- }
- ListView.onAdd: {
- derp();
+ ListView {
+ id: base
+ anchors.fill: parent
+ orientation: Qt.Horizontal
+
+ model: convos
+ delegate : Item {
+ PlasmaWidgets.SvgWidget {
+ elementID: "widgets/frame.svg"
+ anchors.fill: parent
}
- }
-
- //used states here because it'll make a scrollbar (dis)appear later on
- states: [
- State {
- name: "static"
- },
- State {
- name: "auto-scrolling"
- PropertyChanges {
- target: view.model
- restoreEntryValues: true
- onRowsInserted: {
- view.positionViewAtEnd();
- }
+ PlasmaWidgets.IconWidget {
+ text: model.conversation.nick
+ icon: model.conversation.presenceIcon
+ anchors.fill: parent
}
- }
- ]
- }
-
- PlasmaWidgets.LineEdit {
- id: input
-
-// anchors.top: view.bottom
- anchors.left: parent.left; anchors.right: parent.right
- anchors.bottom: parent.bottom
-
- onReturnPressed: {
- view.model.sendNewMessage(text);
- text = "";
}
}
- KTelepathy.ConversationWatcher {
- id:watcher
- onNewConversation: {
- console.log("New Convo!");
- view.model = con.model;
-// view.model.rowsInserted.connect(view.positionViewAtEnd);
- chatArea.state = "auto-scrolling";
- }
+ ConversationsModel {
+ id: convos
}
}
\ No newline at end of file
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list