[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:23:59 UTC 2016


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

The following commit has been merged in the master branch:
commit 62bb42b610fc4d9228ed77a61dbef143658d8340
Author: Dan Vrátil <dvratil at redhat.com>
Date:   Tue May 21 14:48:31 2013 +0200

    Apply theme changes immediately
    
    (text-ui now depends on TelepathyLoggerQt4 0.7.95/0.8.0)
    
    BUG: 270350
    REVIEW: 110545
    FIXED-IN: 0.7.0
---
 CMakeLists.txt               |  2 +-
 app/chat-window.cpp          | 17 ++++++++++-
 app/chat-window.h            |  1 +
 config/appearance-config.cpp |  2 ++
 config/appearance-config.h   |  3 ++
 lib/chat-widget.cpp          | 28 ++++++++++++++---
 lib/chat-widget.h            |  2 ++
 lib/logmanager.cpp           | 73 +++++++++++++++++---------------------------
 lib/logmanager.h             | 22 ++++++++++---
 9 files changed, 95 insertions(+), 55 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a53e575..1d16dc7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,7 @@ set(KDE_MIN_VERSION "4.4.75")
 find_package (KDE4 ${KDE_MIN_VERSION} REQUIRED)
 find_package (TelepathyQt4 0.9.1 REQUIRED)
 find_package (KTp REQUIRED)
-find_package (TelepathyLoggerQt4 0.5.60 REQUIRED)
+find_package (TelepathyLoggerQt4 0.7.95 REQUIRED)
 
 
 # FUTURE: When we can depend on KDE 4.10, use emoticoncontexteditaction from here
diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 3a9b6e9..2834a0f 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -46,6 +46,7 @@
 #include <KMenu>
 #include <KToolBar>
 #include <KToolInvocation>
+#include <KCModuleProxy>
 
 #include <QEvent>
 #include <QWidgetAction>
@@ -591,7 +592,13 @@ void ChatWindow::showSettingsDialog()
 
     KSettings::Dialog *dialog = new KSettings::Dialog(this);
 
-    dialog->addModule(QLatin1String("kcm_ktp_chat_appearance"));
+    KPageWidgetItem *configPage = dialog->addModule(QLatin1String("kcm_ktp_chat_appearance"));
+    KCModuleProxy *proxy = qobject_cast<KCModuleProxy*>(configPage->widget());
+    Q_ASSERT(proxy);
+
+    connect(proxy->realModule(), SIGNAL(reloadTheme()),
+            this, SLOT(onReloadTheme()));
+
     dialog->addModule(QLatin1String("kcm_ktp_chat_behavior"));
     dialog->addModule(QLatin1String("kcm_ktp_chat_messages"));
 
@@ -959,4 +966,12 @@ void ChatWindow::updateSendMessageShortcuts()
     }
 }
 
+void ChatWindow::onReloadTheme()
+{
+    for (int i = 0; i < m_tabWidget->count(); i++) {
+        ChatTab *tab = qobject_cast<ChatTab*>(m_tabWidget->widget(i));
+        tab->reloadTheme();
+    }
+}
+
 #include "chat-window.moc"
diff --git a/app/chat-window.h b/app/chat-window.h
index 47316a4..3a5b6ba 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -109,6 +109,7 @@ private Q_SLOTS:
     void onZoomOut();
     void onZoomFactorChanged(qreal zoom);
     void updateSendMessageShortcuts();
+    void onReloadTheme();
 
 protected Q_SLOTS:
     void showSettingsDialog();
diff --git a/config/appearance-config.cpp b/config/appearance-config.cpp
index f7ebd40..cca4d06 100644
--- a/config/appearance-config.cpp
+++ b/config/appearance-config.cpp
@@ -85,4 +85,6 @@ void AppearanceConfig::save()
     config->sync();
 
     KCModule::save();
+
+    Q_EMIT reloadTheme();
 }
diff --git a/config/appearance-config.h b/config/appearance-config.h
index c0a1e69..f0e1168 100644
--- a/config/appearance-config.h
+++ b/config/appearance-config.h
@@ -39,6 +39,9 @@ public Q_SLOTS:
     virtual void load();
     virtual void defaults();
 
+Q_SIGNALS:
+    void reloadTheme();
+
 protected:
     AppearanceConfigTab *m_singleTab;
     AppearanceConfigTab *m_groupTab;
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 178abf8..a57fe10 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -52,6 +52,8 @@
 #include <TelepathyQt/PendingChannelRequest>
 #include <TelepathyQt/OutgoingFileTransferChannel>
 #include <TelepathyLoggerQt4/TextEvent>
+#include <TelepathyLoggerQt4/LogWalker>
+#include <TelepathyLoggerQt4/PendingEvents>
 
 #include <KTp/presence.h>
 #include <KTp/actions.h>
@@ -65,7 +67,8 @@ public:
     ChatWidgetPrivate() :
         remoteContactChatState(Tp::ChannelChatStateInactive),
         isGroupChat(false),
-        logsLoaded(false)
+        logsLoaded(false),
+        exchangedMessagesCount(0)
     {
     }
     /** Stores whether the channel is ready with all contacts upgraded*/
@@ -82,6 +85,7 @@ public:
     LogManager *logManager;
     QTimer *pausedStateTimer;
     bool logsLoaded;
+    uint exchangedMessagesCount;
 
     QList< Tp::OutgoingFileTransferChannelPtr > tmpFileTransfers;
 
@@ -173,7 +177,7 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
     if (!d->isGroupChat) {
         KConfig config(QLatin1String("ktelepathyrc"));
         KConfigGroup tabConfig = config.group("Behavior");
-        d->logManager->setFetchAmount(tabConfig.readEntry<int>("scrollbackLength", 4));
+        d->logManager->setScrollbackLength(tabConfig.readEntry<int>("scrollbackLength", 4));
         d->logManager->setTextChannel(d->account, d->channel);
         m_previousConversationAvailable = d->logManager->exists();
     } else {
@@ -521,6 +525,8 @@ void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message, bool
 
     if (d->chatViewInitialized) {
 
+        d->exchangedMessagesCount++;
+
         //debug the message parts (looking for HTML etc)
 //        Q_FOREACH(Tp::MessagePart part, message.parts())
 //        {
@@ -637,12 +643,17 @@ void ChatWidget::handleMessageSent(const Tp::Message &message, Tp::MessageSendin
     d->notifyFilter->filterMessage(processedMessage,
                                    KTp::MessageContext(d->account, d->channel));
     d->ui.chatArea->addMessage(processedMessage);
+    d->exchangedMessagesCount++;
 }
 
 void ChatWidget::chatViewReady()
 {
-    if (!d->logsLoaded) {
-        d->logManager->fetchLast();
+    if (!d->logsLoaded || d->exchangedMessagesCount > 0) {
+        if (d->exchangedMessagesCount == 0) {
+            d->logManager->fetchScrollback();
+        } else {
+            d->logManager->fetchHistory(d->exchangedMessagesCount + d->logManager->scrollbackLength());
+        }
     }
 
     d->logsLoaded = true;
@@ -991,4 +1002,13 @@ void ChatWidget::addEmoticonToChat(const QString &emoticon)
     d->ui.sendMessageBox->insertPlainText(QLatin1String(" ") + emoticon);
     d->ui.sendMessageBox->setFocus();
 }
+
+void ChatWidget::reloadTheme()
+{
+    d->logsLoaded = false;
+    d->chatViewInitialized = false;
+
+    initChatArea();
+}
+
 #include "chat-widget.moc"
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index 366d88b..c1dbd41 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -113,6 +113,8 @@ public Q_SLOTS:
 
     void updateSendMessageShortcuts(const KShortcut &shortcuts);
 
+    void reloadTheme();
+
 protected:
     void changeEvent(QEvent *e);
     void resizeEvent(QResizeEvent *);
diff --git a/lib/logmanager.cpp b/lib/logmanager.cpp
index 213b5aa..b0f94d6 100644
--- a/lib/logmanager.cpp
+++ b/lib/logmanager.cpp
@@ -26,12 +26,11 @@
 #include <KDebug>
 
 #include <TelepathyLoggerQt4/Init>
+#include <TelepathyLoggerQt4/LogWalker>
 #include <TelepathyLoggerQt4/Entity>
-#include <TelepathyLoggerQt4/PendingDates>
 #include <TelepathyLoggerQt4/PendingEvents>
 #include <TelepathyLoggerQt4/Event>
 #include <TelepathyLoggerQt4/TextEvent>
-#include <TelepathyLoggerQt4/CallEvent>
 #include <TelepathyLoggerQt4/LogManager>
 
 #include <TelepathyQt/Types>
@@ -41,7 +40,7 @@
 
 LogManager::LogManager(QObject *parent)
     : QObject(parent),
-    m_fetchAmount(10)
+    m_scrolbackLength(10)
 {
     Tpl::init();
 
@@ -77,22 +76,36 @@ void LogManager::setTextChannel(const Tp::AccountPtr &account, const Tp::TextCha
     m_account = account;
 }
 
-void LogManager::setFetchAmount(int n)
+void LogManager::setScrollbackLength(int n)
 {
-    m_fetchAmount = n;
+    m_scrolbackLength = n;
 }
 
-void LogManager::fetchLast()
+int LogManager::scrollbackLength() const
 {
-    kDebug();
-    if (m_fetchAmount > 0 && !m_account.isNull() && !m_textChannel.isNull() && m_textChannel->targetHandleType() == Tp::HandleTypeContact) {
+    return m_scrolbackLength;
+}
+
+void LogManager::fetchScrollback()
+{
+    fetchHistory(m_scrolbackLength);
+}
+
+void LogManager::fetchHistory(int n)
+{
+    // Skip if no messages are requested
+    if (n > 0 && !m_account.isNull() && !m_textChannel.isNull()
+        && m_textChannel->targetHandleType() == Tp::HandleTypeContact) {
         Tpl::EntityPtr contactEntity = Tpl::Entity::create(m_textChannel->targetContact()->id().toLatin1().data(),
                                                 Tpl::EntityTypeContact,
                                                 NULL,
                                                 NULL);
 
-        Tpl::PendingDates* dates = m_logManager->queryDates(m_account, contactEntity, Tpl::EventTypeMaskText);
-        connect(dates, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onDatesFinished(Tpl::PendingOperation*)));
+        Tpl::LogWalkerPtr walker = m_logManager->queryWalkFilteredEvents(
+            m_account, contactEntity, Tpl::EventTypeMaskText, 0, 0);
+        Tpl::PendingEvents *events = walker->queryEvents(n);
+        connect(events, SIGNAL(finished(Tpl::PendingOperation*)),
+                this, SLOT(onEventsFinished(Tpl::PendingOperation*)));
         return;
     }
 
@@ -101,30 +114,6 @@ void LogManager::fetchLast()
     Q_EMIT fetched(messages);
 }
 
-void LogManager::onDatesFinished(Tpl::PendingOperation *po)
-{
-    Tpl::PendingDates *pd = (Tpl::PendingDates*) po;
-
-    if (pd->isError()) {
-        qWarning() << "error in PendingDates:" << pd->errorMessage();
-        return;
-    }
-
-    QList<QDate> dates = pd->dates();
-
-    if (!dates.isEmpty()) {
-        QDate date = dates.last();
-
-        kDebug() << pd->account()->uniqueIdentifier() << pd->entity()->identifier() << dates;
-
-        Tpl::PendingEvents *events = m_logManager->queryEvents( pd->account(), pd->entity(), Tpl::EventTypeMaskAny, date);
-        connect(events, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onEventsFinished(Tpl::PendingOperation*)));
-    } else {
-        QList<KTp::Message> messages;
-        Q_EMIT fetched(messages);
-    }
-}
-
 bool operator<(const Tpl::EventPtr &e1, const Tpl::EventPtr &e2)
 {
     return e1->timestamp() < e2->timestamp();
@@ -155,23 +144,17 @@ void LogManager::onEventsFinished(Tpl::PendingOperation *po)
     // Uses the operator< overload above
     qSort(allEvents);
 
-    QList<Tpl::TextEventPtr> events;
-    QList<Tpl::EventPtr>::iterator i = allEvents.end();
-    while (i-- != allEvents.begin() && (events.count() < m_fetchAmount)) {
-        Tpl::TextEventPtr textEvent = (*i).dynamicCast<Tpl::TextEvent>();
+    QList<KTp::Message> messages;
+    Q_FOREACH (const Tpl::EventPtr &event, allEvents) {
+        const Tpl::TextEventPtr textEvent = event.dynamicCast<Tpl::TextEvent>();
         if (!textEvent.isNull()) {
             if (!queuedMessageTokens.contains(textEvent->messageToken())) {
-                events.prepend(textEvent);
+                const KTp::Message message = KTp::MessageProcessor::instance()->processIncomingMessage(textEvent, m_account, m_textChannel);
+                messages.append(message);
             }
         }
     }
 
-    QList<KTp::Message> messages;
-    Q_FOREACH(const Tpl::TextEventPtr &event, events) {
-        KTp::Message message = KTp::MessageProcessor::instance()->processIncomingMessage(event, m_account, m_textChannel);
-        messages.append(message);
-    }
-
     kDebug() << "emit all messages" << messages.count();
     Q_EMIT fetched(messages);
 }
diff --git a/lib/logmanager.h b/lib/logmanager.h
index e5e97bc..3f4a2f1 100644
--- a/lib/logmanager.h
+++ b/lib/logmanager.h
@@ -47,14 +47,28 @@ public:
     bool exists() const;
 
     void setTextChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &textChannel);
-    void setFetchAmount(int n);
-    void fetchLast();
+
+    /**
+     * Sets amount of messages to be fetched via @p fetchScrollback()
+     */
+    void setScrollbackLength(int n);
+
+    int scrollbackLength() const;
+
+    /**
+     * Fetches last N message,s as set via setFetchAmount()
+     */
+    void fetchScrollback();
+
+    /**
+     * Fetches last @p n messages
+     */
+    void fetchHistory(int n);
 
 Q_SIGNALS:
     void fetched(const QList<KTp::Message> &messages);
 
 private Q_SLOTS:
-    void onDatesFinished(Tpl::PendingOperation *po);
     void onEventsFinished(Tpl::PendingOperation *po);
 
 private:
@@ -63,7 +77,7 @@ private:
     Tpl::EntityPtr m_contactEntity;
     Tpl::LogManagerPtr m_logManager;
 
-    int m_fetchAmount;
+    int m_scrolbackLength;
 };
 
 #endif // LOGMANAGER_H

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list