[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:18:02 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=8181143

The following commit has been merged in the master branch:
commit 818114318c603f333f9064d8ae27caaf15d56dd0
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Sat Sep 25 17:35:59 2010 +0000

    Further work on the refactor:
     - added the split methods addContentMessage() and addStatusMessage()
    with the new information structures.
    
    svn path=/trunk/playground/network/telepathy-chat-handler/; revision=1179506
---
 lib/adiumthemecontentinfo.cpp | 10 ++++-
 lib/adiumthemecontentinfo.h   |  2 +-
 lib/adiumthemestatusinfo.h    |  2 +-
 lib/adiumthemeview.cpp        | 97 +++++++++++++++++++++++++++++++++++++++++++
 lib/adiumthemeview.h          | 11 ++++-
 lib/chatwindow.cpp            |  5 ++-
 lib/chatwindow.ui             |  9 ++++
 7 files changed, 128 insertions(+), 8 deletions(-)

diff --git a/lib/adiumthemecontentinfo.cpp b/lib/adiumthemecontentinfo.cpp
index 3eaef75..7c084a9 100644
--- a/lib/adiumthemecontentinfo.cpp
+++ b/lib/adiumthemecontentinfo.cpp
@@ -67,8 +67,14 @@ void AdiumThemeContentInfo::setSenderStatusIcon(const QString &senderStatusIcon)
 
 QString AdiumThemeContentInfo::messageDirection() const
 {
-    //FIXME
-    return "rtl";
+    switch(type())
+    {
+    case AdiumThemeMessageInfo::RemoteToLocal:
+        return "trl";
+        break;
+    default:
+        return "ltr";
+    }
 }
 
 QString AdiumThemeContentInfo::senderDisplayName() const
diff --git a/lib/adiumthemecontentinfo.h b/lib/adiumthemecontentinfo.h
index 2755d1d..4d35393 100644
--- a/lib/adiumthemecontentinfo.h
+++ b/lib/adiumthemecontentinfo.h
@@ -7,7 +7,7 @@ class AdiumThemeContentInfoPrivate;
 
 
 
-class AdiumThemeContentInfo : AdiumThemeMessageInfo
+class AdiumThemeContentInfo : public AdiumThemeMessageInfo
 {
 public:
     explicit AdiumThemeContentInfo(AdiumThemeMessageInfo::MessageType);
diff --git a/lib/adiumthemestatusinfo.h b/lib/adiumthemestatusinfo.h
index 1c7eed7..d48c18a 100644
--- a/lib/adiumthemestatusinfo.h
+++ b/lib/adiumthemestatusinfo.h
@@ -5,7 +5,7 @@
 class QString;
 class AdiumThemeStatusInfoPrivate;
 
-class AdiumThemeStatusInfo : AdiumThemeMessageInfo
+class AdiumThemeStatusInfo : public AdiumThemeMessageInfo
 {
 public:
     explicit AdiumThemeStatusInfo();
diff --git a/lib/adiumthemeview.cpp b/lib/adiumthemeview.cpp
index 7b5244b..c049955 100644
--- a/lib/adiumthemeview.cpp
+++ b/lib/adiumthemeview.cpp
@@ -18,6 +18,12 @@
  ***************************************************************************/
 
 #include "adiumthemeview.h"
+
+#include "adiumthemeheaderinfo.h"
+#include "adiumthemecontentinfo.h"
+#include "adiumthememessageinfo.h"
+#include "adiumthemestatusinfo.h"
+
 #include "chatwindowstylemanager.h"
 
 #include <QDebug>
@@ -191,6 +197,54 @@ void AdiumThemeView::setHeaderDisplayed(bool displayHeader)
     initialise(m_chatInfo);
 }
 
+
+void AdiumThemeView::addContentMessage(const AdiumThemeContentInfo &contentMessage)
+{
+    QString styleHtml;
+    bool consecutiveMessage = false;
+
+    if (m_lastSender == contentMessage.senderScreenName()) {
+        consecutiveMessage = true;
+    } else {
+        m_lastSender = contentMessage.senderScreenName();
+    }
+
+    switch (contentMessage.type()) {
+    case TelepathyChatMessageInfo::RemoteToLocal:
+        if (consecutiveMessage) {
+            styleHtml = m_chatStyle->getNextIncomingHtml();
+        } else {
+            styleHtml = m_chatStyle->getIncomingHtml();
+        }
+        break;
+    case TelepathyChatMessageInfo::LocalToRemote:
+        if (consecutiveMessage) {
+            styleHtml = m_chatStyle->getNextOutgoingHtml();
+        } else {
+            styleHtml = m_chatStyle->getOutgoingHtml();
+        }
+        break;
+    default:
+        qWarning() << "Unexpected message type to addContentMessage";
+    }
+
+    replaceContentKeywords(styleHtml, contentMessage);
+
+    if (consecutiveMessage) {
+        appendNextMessage(styleHtml);
+    } else {
+        appendNewMessage(styleHtml);
+    }
+}
+
+void AdiumThemeView::addStatusMessage(const AdiumThemeStatusInfo& statusMessage)
+{
+    QString styleHtml = m_chatStyle->getStatusHtml();
+    m_lastSender = "";
+    replaceStatusKeywords(styleHtml, statusMessage);
+    appendNewMessage(styleHtml);
+}
+
 void AdiumThemeView::addMessage(const TelepathyChatMessageInfo &message)
 {
     QString styleHtml;
@@ -279,7 +333,50 @@ QString AdiumThemeView::replaceHeaderKeywords(QString htmlTemplate, const AdiumT
     return htmlTemplate;
 }
 
+QString AdiumThemeView::replaceContentKeywords(QString& htmlTemplate, const AdiumThemeContentInfo& info)
+{
+    //userIconPath
+    htmlTemplate.replace("%userIconPath%", info.userIconPath());
+    //senderScreenName
+    htmlTemplate.replace("%senderScreenName%", info.senderScreenName());
+    //sender
+    htmlTemplate.replace("%sender%", info.sender());
+    //senderColor
+    htmlTemplate.replace("%senderColor%", info.senderColor());
+    //senderStatusIcon
+    htmlTemplate.replace("senderStatusIcon", info.senderStatusIcon());
+    //messageDirection
+    htmlTemplate.replace("%messageDirection%", info.messageDirection());
+    //senderDisplayName
+    htmlTemplate.replace("%senderDisplayName%", info.senderDisplayName());
+
+    //FIXME %textbackgroundcolor{X}%
+    return replaceMessageKeywords(htmlTemplate, info);
+}
 
+QString AdiumThemeView::replaceStatusKeywords(QString &htmlTemplate, const AdiumThemeStatusInfo& info)
+{
+    htmlTemplate.replace("%status%", info.status());
+    return replaceMessageKeywords(htmlTemplate, info);
+}
+
+QString AdiumThemeView::replaceMessageKeywords(QString &htmlTemplate, const AdiumThemeMessageInfo& info)
+{
+    //message
+    htmlTemplate.replace("%message%", info.message());
+    //time
+    htmlTemplate.replace("%time%", KGlobal::locale()->formatTime(info.time().time(), true));
+    //shortTime
+    htmlTemplate.replace("%shortTime%", KGlobal::locale()->formatTime(info.time().time(), false));
+    //time{X}
+    QRegExp timeRegExp("%time\{([^}]*)\}%");
+    int pos = 0;
+    while ((pos = timeRegExp.indexIn(htmlTemplate , pos)) != -1) {
+        QString timeKeyword = formatTime(timeRegExp.cap(1), info.time());
+        htmlTemplate.replace(pos , timeRegExp.cap(0).length() , timeKeyword);
+    }
+    return htmlTemplate;
+}
 
 
 void AdiumThemeView::appendNewMessage(QString &html)
diff --git a/lib/adiumthemeview.h b/lib/adiumthemeview.h
index 8d172e8..b86543e 100644
--- a/lib/adiumthemeview.h
+++ b/lib/adiumthemeview.h
@@ -27,6 +27,10 @@
 #include <KEmoticons>
 
 
+class AdiumThemeContentInfo;
+class AdiumThemeHeaderInfo;
+class AdiumThemeMessageInfo;
+class AdiumThemeStatusInfo;
 
 class AdiumThemeView : public QWebView
 {
@@ -49,9 +53,10 @@ public:
     void setHeaderDisplayed(bool);
     /* .. font, backgrounds, everything else.*/
 
-
 public slots:
     void addMessage(const TelepathyChatMessageInfo &message);
+    void addContentMessage(const AdiumThemeContentInfo&);
+    void addStatusMessage(const AdiumThemeStatusInfo&);
 
 private:
     ChatWindowStyle* m_chatStyle;
@@ -59,7 +64,9 @@ private:
     QString m_variantName;
     KEmoticons m_emoticons;
     QString replaceHeaderKeywords(QString htmlTemplate, const AdiumThemeHeaderInfo&);
-    //QString replaceMessageKeywords(QString htmlTemplate, const TelepathyChatMessageInfo&);
+    QString replaceContentKeywords(QString& htmlTemplate, const AdiumThemeContentInfo&);
+    QString replaceStatusKeywords(QString& htmlTemplate, const AdiumThemeStatusInfo&);
+    QString replaceMessageKeywords(QString& htmlTemplate, const AdiumThemeMessageInfo&);
 
     QString formatTime(const QString&, const QDateTime&);
 
diff --git a/lib/chatwindow.cpp b/lib/chatwindow.cpp
index 89c71c7..f4ff262 100644
--- a/lib/chatwindow.cpp
+++ b/lib/chatwindow.cpp
@@ -27,12 +27,12 @@
 #include <QAction>
 #include <QWidget>
 
+//#include <Sonnet/Highlighter>
 
 #include <TelepathyQt4/Message>
 #include <TelepathyQt4/Types>
 
 
-
 //FIXME once TP::Factory stuff is in, remove all of ChatConnection, replace this with
 //ChatWindow::ChatWindow(ConnectionPtr,TextChannelPtr, QWidget* parent) :...
 ChatWindow::ChatWindow(ChatConnection* chat, QWidget *parent) :
@@ -139,8 +139,9 @@ void ChatWindow::handleIncomingMessage(const Tp::ReceivedMessage &message)
         ui->chatArea->addMessage(messageInfo);
         m_chatConnection->channel()->acknowledge(QList<Tp::ReceivedMessage>() << message);
 
-        Q_EMIT(SIGNAL(messageReceived()));
+        emit messageReceived();
     }
+
     //if the window isn't ready, we don't acknowledge the mesage. We process them as soon as we are ready.
 }
 
diff --git a/lib/chatwindow.ui b/lib/chatwindow.ui
index a5bd36e..48263c9 100644
--- a/lib/chatwindow.ui
+++ b/lib/chatwindow.ui
@@ -29,6 +29,15 @@
    <item>
     <widget class="QWidget" name="formatToolbar" native="true">
      <layout class="QHBoxLayout" name="horizontalLayout_2">
+      <property name="sizeConstraint">
+       <enum>QLayout::SetDefaultConstraint</enum>
+      </property>
+      <property name="topMargin">
+       <number>4</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
       <item>
        <widget class="QPushButton" name="formatBold">
         <property name="focusPolicy">

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list