[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=b0a21df

The following commit has been merged in the master branch:
commit b0a21df15d8a252f4cf1df33440c94cf79ae40b2
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
---
 lib/chat-widget.h                     |  3 ++
 lib/conversation-model.cpp            | 24 +++++++++++-
 lib/conversation-model.h              |  4 ++
 lib/conversation.cpp                  | 24 +++++++++++-
 lib/conversation.h                    | 19 +++++++++
 plasmoid/contents/ui/TextDelegate.qml | 22 +++++++++++
 plasmoid/contents/ui/main.qml         | 74 +++++++++++++++++++++++------------
 7 files changed, 144 insertions(+), 26 deletions(-)

diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 30afa31..c6015dd 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -85,6 +85,9 @@ public:
     QString spellDictionary() const;
 
     void setSpellDictionary(const QString &dict);
+    //FIXME this should be in the ktelepathy lib
+    static KIcon iconForPresence(Tp::ConnectionPresenceType presence);
+
 
 public Q_SLOTS:
     /** toggle the search bar visibility */
diff --git a/lib/conversation-model.cpp b/lib/conversation-model.cpp
index d6bf810..5b1b056 100644
--- a/lib/conversation-model.cpp
+++ b/lib/conversation-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/lib/conversation-model.h b/lib/conversation-model.h
index 06affa6..e44b217 100644
--- a/lib/conversation-model.h
+++ b/lib/conversation-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);
diff --git a/lib/conversation.cpp b/lib/conversation.cpp
index fc96d91..63adfda 100644
--- a/lib/conversation.cpp
+++ b/lib/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/lib/conversation.h b/lib/conversation.h
index b68800f..caaf3ce 100644
--- a/lib/conversation.h
+++ b/lib/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/plasmoid/contents/ui/TextDelegate.qml b/plasmoid/contents/ui/TextDelegate.qml
new file mode 100644
index 0000000..845eb59
--- /dev/null
+++ b/plasmoid/contents/ui/TextDelegate.qml
@@ -0,0 +1,22 @@
+import Qt 4.7
+
+Item {
+    Text {
+        id: header
+        width: view.width
+        wrapMode: Text.Wrap
+
+        text: "[" + Qt.formatTime(model.time) + "] " + model.user + " :"
+    }
+    Text {
+        id: body
+
+        anchors.top: header.bottom
+        width: view.width
+
+        wrapMode: Text.Wrap
+        text: model.text
+    }
+
+    height: header.height + body.height
+}
\ No newline at end of file
diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml
index 9e388d1..34cf530 100644
--- a/plasmoid/contents/ui/main.qml
+++ b/plasmoid/contents/ui/main.qml
@@ -1,43 +1,67 @@
 import Qt 4.7
 import org.kde.telepathy.declarativeplugins 0.1 as KTelepathy
+import org.kde.plasma.core 0.1 as PlasmaCore
+import org.kde.plasma.graphicswidgets 0.1 as PlasmaWidgets
 
 Item {
     id:main
 
-    Component {
-        id: textDelegate
 
-        Item {
-            Text {
-                id: header
-                width: view.width
-                wrapMode: Text.Wrap
+    function derp() {
+        console.log("deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerp!");
+        return true;
+    }
 
-                text: "[" + Qt.formatTime(model.time) + "] " + model.user + " :"
-            }
-            Text {
-                id: body
+    Item {
+        id:chatArea
+
+        anchors.top: parent.top
+        anchors.left: parent.left; anchors.right: parent.right
+        anchors.bottom: input.top
+        anchors.margins: 5
 
-                anchors.top: header.bottom
-                width: view.width
+        ListView {
+            id: view
 
-                wrapMode: Text.Wrap
-                text: model.text
-            }
+            anchors.fill: parent
+            clip: true
 
-            height: header.height + body.height
+            delegate: TextDelegate {
+            }
+            ListView.onAdd: {
+                derp();
+            }
         }
-    }
 
-    ListView {
-        id: view
+        //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();
+                    }
+                }
+            }
+        ]
+    }
 
-        anchors.fill: parent
-        anchors.margins: 5
+    PlasmaWidgets.LineEdit {
+        id: input
 
-        clip: true
+//         anchors.top: view.bottom
+        anchors.left: parent.left; anchors.right: parent.right
+        anchors.bottom: parent.bottom
 
-        delegate: textDelegate
+        onReturnPressed: {
+            view.model.sendNewMessage(text);
+            text = "";
+        }
     }
 
     KTelepathy.ConversationWatcher {
@@ -45,6 +69,8 @@ Item {
         onNewConversation: {
             console.log("New Convo!");
             view.model = con.model;
+//             view.model.rowsInserted.connect(view.positionViewAtEnd);
+            chatArea.state = "auto-scrolling";
         }
     }
 }
\ No newline at end of file

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list