[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:21:48 UTC 2016


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

The following commit has been merged in the master branch:
commit 415f86e1140d5c4a39c7af92c17aa7ce387096bf
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Thu May 3 22:53:36 2012 +0100

    Add a button to open log viewer with a specific contact from the text-ui
    
    BUG: 294653
    REVIEW: 104057
    Reviewed-by: Martin Klapetek
---
 app/chat-window.cpp                                | 23 ++++++
 app/chat-window.h                                  |  1 +
 logviewer/CMakeLists.txt                           |  1 +
 logviewer/{entity-model.h => entity-view.cpp}      | 91 ++++++++--------------
 .../{conversation-date-picker.h => entity-view.h}  | 35 +++------
 logviewer/log-viewer.ui                            |  7 +-
 logviewer/main.cpp                                 | 10 ++-
 7 files changed, 84 insertions(+), 84 deletions(-)

diff --git a/app/chat-window.cpp b/app/chat-window.cpp
index 53c547c..7b5449a 100644
--- a/app/chat-window.cpp
+++ b/app/chat-window.cpp
@@ -43,6 +43,7 @@
 #include <KLineEdit>
 #include <KMenu>
 #include <KToolBar>
+#include <KToolInvocation>
 
 #include <QEvent>
 #include <QWidgetAction>
@@ -479,6 +480,24 @@ void ChatWindow::onShareDesktopTriggered()
     startShareDesktop(currChat->account(), currChat->textChannel()->targetContact());
 }
 
+void ChatWindow::onOpenLogTriggered()
+{
+    int index = m_tabWidget->currentIndex();
+    ChatTab* currentChatTab = qobject_cast<ChatTab*>(m_tabWidget->widget(index));
+    Q_ASSERT(currentChatTab);
+
+    Tp::AccountPtr account = currentChatTab->account();
+    Tp::ContactPtr contact = currentChatTab->textChannel()->targetContact();
+
+    if (!contact.isNull()) {
+        KToolInvocation::kdeinitExec(QLatin1String("ktp-log-viewer"),
+                                     QStringList() << account->uniqueIdentifier() << contact->id());
+    } else {
+        KToolInvocation::kdeinitExec(QLatin1String("ktp-log-viewer"),
+                                     QStringList() << account->uniqueIdentifier() << currentChatTab->textChannel()->targetId());
+    }
+}
+
 
 void ChatWindow::showSettingsDialog()
 {
@@ -574,6 +593,9 @@ void ChatWindow::setupCustomActions()
     spellDictComboAction->setIcon(KIcon(QLatin1String("tools-check-spelling")));
     spellDictComboAction->setIconText(i18n("Choose Spelling Language"));
 
+    KAction *openLogAction = new KAction(KIcon(QLatin1String("view-pim-journal")), i18nc("Action to open the log viwer with a specified contact","&Previous conversations"), this);
+    connect(openLogAction, SIGNAL(triggered()), SLOT(onOpenLogTriggered()));
+
     KAction *accountIconAction = new KAction(KIcon(QLatin1String("telepathy-kde")), i18n("Account Icon"), this);
     m_accountIconLabel = new QLabel(this);
     accountIconAction->setDefaultWidget(m_accountIconLabel);
@@ -589,6 +611,7 @@ void ChatWindow::setupCustomActions()
     actionCollection()->addAction(QLatin1String("language"), spellDictComboAction);
     actionCollection()->addAction(QLatin1String("account-icon"), accountIconAction);
     actionCollection()->addAction(QLatin1String("block-contact"), blockContactAction);
+    actionCollection()->addAction(QLatin1String("open-log"), openLogAction);
 }
 
 void ChatWindow::setAudioCallEnabled(bool enable)
diff --git a/app/chat-window.h b/app/chat-window.h
index 3a1e8d4..690f286 100644
--- a/app/chat-window.h
+++ b/app/chat-window.h
@@ -97,6 +97,7 @@ private Q_SLOTS:
     void onUserTypingChanged(Tp::ChannelChatState state);
     void onUnblockContactTriggered();                           /** Unblocks contact when already blocked */
     void onShareDesktopTriggered();                             /** start a desktop share */
+    void onOpenLogTriggered();                                  /** Starts ktp-log-viewer accountId contactId */
     void setTabSpellDictionary(const QString &dict);            /** set the spelling language for the current chat tab*/
     void toggleBlockButton(bool contactIsBlocked);              /** Toggle block/unblock action according to the flag */
 
diff --git a/logviewer/CMakeLists.txt b/logviewer/CMakeLists.txt
index 44ec6e5..bb22191 100644
--- a/logviewer/CMakeLists.txt
+++ b/logviewer/CMakeLists.txt
@@ -15,6 +15,7 @@ set(ktp-log-viewer_SRCS
         log-viewer.cpp
         entity-model.cpp
         message-view.cpp
+        entity-view.cpp
         conversation-date-picker.cpp
 )
 
diff --git a/logviewer/entity-model.h b/logviewer/entity-view.cpp
similarity index 54%
copy from logviewer/entity-model.h
copy to logviewer/entity-view.cpp
index cd6649e..1ef5ef4 100644
--- a/logviewer/entity-model.h
+++ b/logviewer/entity-view.cpp
@@ -17,68 +17,45 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
+#include "entity-view.h"
 
-#ifndef ENTITYMODEL_H
-#define ENTITYMODEL_H
+#include <KCmdLineArgs>
 
-#include <QAbstractListModel>
-
-#include <TelepathyQt/Types>
-
-#include <TelepathyLoggerQt4/Entity>
 #include <TelepathyQt/Account>
+#include <TelepathyLoggerQt4/Entity>
 
+#include "entity-model.h"
 
-/**
-    Lists all avilable entities.
-
-    roles:
-      - Qt::DisplayRole - name
-      - Qt::DecorationRole - avatar
-      - EntityModel::IdRole
-      - EntityModel::TypeRole - EntityType (EntityTypeContact/Room/Self/Unknown)
-      - EntityModel::EntityRole - relevant Tpl::EntityPtr
-  */
-
-namespace Tpl{
-    class PendingOperation;
+EntityView::EntityView(QWidget *parent) :
+    QListView(parent)
+{
 }
 
-
-class EntityModelItem {
-public:
-    Tpl::EntityPtr entity;
-    Tp::AccountPtr account;
-};
-
-class EntityModel : public QAbstractListModel
+void EntityView::rowsInserted(const QModelIndex &parent, int start, int end)
 {
-    Q_OBJECT
-public:
-    enum Role {
-        IdRole = Qt::UserRole,
-        TypeRole,
-        EntityRole,
-        AccountRole
-    };
-
-
-    explicit EntityModel(QObject *parent = 0);
-    void setAccountManager(const Tp::AccountManagerPtr &accountManager);
-
-    int rowCount(const QModelIndex &parent) const;
-    QVariant data(const QModelIndex &index, int role) const;
-
-private Q_SLOTS:
-    void onEntitiesSearchFinished(Tpl::PendingOperation*);
-
-private:
-    QList<EntityModelItem> m_entities;
-
-};
-
-Q_DECLARE_METATYPE(Tpl::EntityPtr);
-Q_DECLARE_METATYPE(Tp::AccountPtr);
-
-
-#endif // ENTITYMODEL_H
+    QListView::rowsInserted(parent, start, end);
+    static bool loadedCurrentContact = false;
+
+    if (loadedCurrentContact) {
+        return;
+    }
+
+    if (KCmdLineArgs::parsedArgs()->count() == 2) {
+        QString selectAccountId = KCmdLineArgs::parsedArgs()->arg(0);
+        QString selectContactId = KCmdLineArgs::parsedArgs()->arg(1);
+
+        for (int i=start; i<end;i++) {
+            QModelIndex index = model()->index(i, 0, parent);
+            QString accountId = index.data(EntityModel::AccountRole).value<Tp::AccountPtr>()->uniqueIdentifier();
+            QString contactId = index.data(EntityModel::EntityRole).value<Tpl::EntityPtr>()->identifier();
+
+            if (selectAccountId == accountId && selectContactId == contactId) {
+                setCurrentIndex(index);
+                Q_EMIT activated(index); // this is normally emitted when a user clicks a contact
+                //we emit it here to trigger the same results.
+                loadedCurrentContact = true;
+            }
+
+        }
+    }
+}
diff --git a/logviewer/conversation-date-picker.h b/logviewer/entity-view.h
similarity index 71%
copy from logviewer/conversation-date-picker.h
copy to logviewer/entity-view.h
index dd177cc..03c23d1 100644
--- a/logviewer/conversation-date-picker.h
+++ b/logviewer/entity-view.h
@@ -17,35 +17,22 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef CONVERSATIONDATEPICKER_H
-#define CONVERSATIONDATEPICKER_H
+#ifndef ENTITYVIEW_H
+#define ENTITYVIEW_H
 
-#include <KDatePicker>
+#include <QListView>
 
-#include <TelepathyLoggerQt4/Entity>
-#include <TelepathyQt/Types>
+//model is loaded asynchronously so we need to select the correct element on each new element
+//this is done in the view to avoid having to be careful with proxy models.
 
-namespace Tpl{
-    class PendingOperation;
-}
-
-class ConversationDatePicker : public KDatePicker
+class EntityView : public QListView
 {
     Q_OBJECT
 public:
-    explicit ConversationDatePicker(QWidget *parent = 0);
-
-    void setEntity(const Tp::AccountPtr &accout, const Tpl::EntityPtr &entity);
-    void clear();
-
-Q_SIGNALS:
-
-private Q_SLOTS:
-    void onDatesFinished(Tpl::PendingOperation*);
-
-private:
-    QList<QDate> m_setDates;
-
+    explicit EntityView(QWidget *parent = 0);
+    
+protected Q_SLOTS:
+    void rowsInserted(const QModelIndex &parent, int start, int end);
 };
 
-#endif // CONVERSATIONDATEPICKER_H
+#endif // ENTITYVIEW_H
diff --git a/logviewer/log-viewer.ui b/logviewer/log-viewer.ui
index 039f0b1..c5e6a09 100644
--- a/logviewer/log-viewer.ui
+++ b/logviewer/log-viewer.ui
@@ -17,7 +17,7 @@
    <item>
     <layout class="QVBoxLayout" name="verticalLayout">
      <item>
-      <widget class="QListView" name="entityList"/>
+      <widget class="EntityView" name="entityList"/>
      </item>
      <item>
       <widget class="KFilterProxySearchLine" name="entityFilter"/>
@@ -58,6 +58,11 @@
    <header>conversation-date-picker.h</header>
    <container>1</container>
   </customwidget>
+  <customwidget>
+   <class>EntityView</class>
+   <extends>QListView</extends>
+   <header>entity-view.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
diff --git a/logviewer/main.cpp b/logviewer/main.cpp
index 7f7660b..955001c 100644
--- a/logviewer/main.cpp
+++ b/logviewer/main.cpp
@@ -32,10 +32,16 @@ int main(int argc, char *argv[])
     aboutData.addAuthor(ki18n("Daniele E. Domenichelli"), ki18n("Developer"), "daniele.domenichelli at gmail.com");
     aboutData.setProductName("telepathy/logger"); //set the correct name for bug reporting
     aboutData.setLicense(KAboutData::License_GPL_V2);
+
     KCmdLineArgs::init(argc, argv, &aboutData);
 
-    KCmdLineArgs::parsedArgs();
-    KUniqueApplication a;
+    KCmdLineOptions options;
+    options.add("+accountID", ki18n("The UID of the account to preselect"));
+    options.add("+contactID", ki18n("The UID of the contact to preselect"));
+
+    KCmdLineArgs::addCmdLineOptions(options);
+
+    KApplication a;
     LogViewer w;
     w.show();
 

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list