[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:05:09 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=1a7badc

The following commit has been merged in the master branch:
commit 1a7badcefb2f63022d6a6204a2f7ab81e50c113c
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Mon Feb 28 01:16:28 2011 +0000

    Add a filter proxy model, show only online users.
---
 CMakeLists.txt                          |  1 +
 accountfiltermodel.cpp                  | 54 +++++++++++++++++++++++++++++++++
 accountbutton.h => accountfiltermodel.h | 38 +++++++++++------------
 accounts-model.cpp                      |  2 +-
 main-widget.cpp                         | 16 +++++++---
 main-widget.h                           |  4 ++-
 6 files changed, 88 insertions(+), 27 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 881b874..375fcc4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,6 +48,7 @@ set (contactlist_SRCS
      contactdelegateoverlay.cpp 
      accountbutton.cpp 
      accounts-model.cpp
+     accountfiltermodel.cpp
      contact-model-item.cpp
      tree-node.cpp
      accounts-model-item.cpp
diff --git a/accountfiltermodel.cpp b/accountfiltermodel.cpp
new file mode 100644
index 0000000..5eb2b0f
--- /dev/null
+++ b/accountfiltermodel.cpp
@@ -0,0 +1,54 @@
+/*
+ * Provide some filters on the account model
+ *
+ * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
+ *
+ * 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 St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "accountfiltermodel.h"
+#include "accounts-model.h"
+
+AccountFilterModel::AccountFilterModel(QObject *parent)
+    : QSortFilterProxyModel(parent),
+      m_filterOfflineUsers(false)
+{
+
+}
+
+void AccountFilterModel::filterOfflineUsers(bool filterOfflineUsers)
+{
+    m_filterOfflineUsers = filterOfflineUsers;
+}
+
+bool AccountFilterModel::filterOfflineUsers() const
+{
+    return m_filterOfflineUsers;
+}
+
+
+bool AccountFilterModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
+{
+    //if we're looking at filtering an account or not
+    if (source_parent != QModelIndex()) {
+        if (m_filterOfflineUsers &&
+            source_parent.child(source_row, 0).data(AccountsModel::PresenceTypeRole).toUInt()
+                == Tp::ConnectionPresenceTypeOffline) {
+            return false;
+        }
+    }
+
+    return true;
+}
diff --git a/accountbutton.h b/accountfiltermodel.h
similarity index 58%
copy from accountbutton.h
copy to accountfiltermodel.h
index 3f590fe..c650c28 100644
--- a/accountbutton.h
+++ b/accountfiltermodel.h
@@ -1,7 +1,7 @@
 /*
- * Tool button which controls account's presence
- * 
- * Copyright (C) 2011 Martin Klapetek <martin dot klapetek at gmail dot com>
+ * Provide some filters on the account model
+ *
+ * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -18,28 +18,24 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef TELEPATHY_ACCOUNTBUTTON_H
-#define TELEPATHY_ACCOUNTBUTTON_H
-
-#include <QToolButton>
-#include <QLineEdit>
-
-#include <TelepathyQt4/Account>
+#ifndef ACCOUNTFILTERMODEL_H
+#define ACCOUNTFILTERMODEL_H
 
-class QAction;
+#include <QSortFilterProxyModel>
 
-class AccountButton : public QToolButton
+class AccountFilterModel : public QSortFilterProxyModel
 {
-    Q_OBJECT
-    
 public:
-    AccountButton(const Tp::AccountPtr &account, QWidget *parent = 0);
-    
-public Q_SLOTS:
-    void setAccountStatus(QAction *action);
-    
+    AccountFilterModel(QObject *parent=0);
+
+    void filterOfflineUsers(bool filterOfflineUsers);
+    bool filterOfflineUsers() const;
+
+protected:
+    bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
+
 private:
-    Tp::AccountPtr m_account;
+    bool m_filterOfflineUsers;
 };
 
-#endif // TELEPATHY_ACCOUNTBUTTON_H
+#endif // ACCOUNTFILTERMODEL_H
diff --git a/accounts-model.cpp b/accounts-model.cpp
index 1747d7e..de1a0f8 100644
--- a/accounts-model.cpp
+++ b/accounts-model.cpp
@@ -303,4 +303,4 @@ QModelIndex AccountsModel::parent(const QModelIndex &index) const
         // no parent: return root node
         return QModelIndex();
     }
-}
\ No newline at end of file
+}
diff --git a/main-widget.cpp b/main-widget.cpp
index 1871c8d..6cc5c3a 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -52,6 +52,7 @@
 #include "accountbutton.h"
 #include "contactoverlays.h"
 #include "accounts-model.h"
+#include "accountfiltermodel.h"
 
 #define PREFERRED_TEXTCHAT_HANDLER "org.freedesktop.Telepathy.Client.KDEChatHandler"
 
@@ -270,7 +271,8 @@ void ContactDelegate::triggerRepaint()
 
 MainWidget::MainWidget(QWidget *parent)
  : QWidget(parent),
-   m_model(0)
+   m_model(0),
+   m_modelFilter(0)
 {
 
     // Check if Nepomuk Query service client is up and running
@@ -364,7 +366,12 @@ void MainWidget::onAccountManagerReady(Tp::PendingOperation* op)
     }
     
     m_model = new AccountsModel(m_accountManager, this);
-    m_contactsListView->setModel(m_model);
+    m_modelFilter = new AccountFilterModel(this);
+    m_modelFilter->setSourceModel(m_model);
+    m_modelFilter->setDynamicSortFilter(true);
+    m_modelFilter->filterOfflineUsers(true);
+    m_contactsListView->setModel(m_modelFilter);
+
 
     QList<Tp::AccountPtr> accounts = m_accountManager->allAccounts();
     foreach (Tp::AccountPtr account, accounts) 
@@ -474,10 +481,11 @@ void MainWidget::startTextChannel(const QModelIndex &index)
         return;
     }
     
-    Tp::ContactPtr contact = m_model->contactForIndex(index);
+    QModelIndex realIndex = m_modelFilter->mapToSource(index);
+    Tp::ContactPtr contact = m_model->contactForIndex(realIndex);
     kDebug() << "Requesting chat for contact" << contact->alias();
     
-    Tp::AccountPtr account = m_model->accountForContactIndex(index);
+    Tp::AccountPtr account = m_model->accountForContactIndex(realIndex);
     
     Tp::PendingChannelRequest* channelRequest = account->ensureTextChat(contact);
     connect(channelRequest, SIGNAL(finished(Tp::PendingOperation*)), SLOT(onChannelJoined(Tp::PendingOperation*)));
diff --git a/main-widget.h b/main-widget.h
index 5ff8649..6bddfff 100644
--- a/main-widget.h
+++ b/main-widget.h
@@ -34,6 +34,7 @@
 class KMenu;
 class KSelectAction;
 class AccountsModel;
+class AccountFilterModel;
 
 class ContactDelegate : public QStyledItemDelegate, public ContactDelegateOverlayContainer
 {
@@ -68,10 +69,10 @@ private:
     int         m_fadingValue;
 };
 
+
 class MainWidget : public QWidget, Ui::MainWidget
 {
     Q_OBJECT
-
 public:
     MainWidget(QWidget *parent = 0);
     ~MainWidget();
@@ -124,6 +125,7 @@ public Q_SLOTS:
     
 private:
     AccountsModel*          m_model;
+    AccountFilterModel*     m_modelFilter;
     Tp::AccountManagerPtr   m_accountManager;
     KMenu*                  m_accountMenu;
     KSelectAction*          m_setStatusAction;

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list