[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:14:34 UTC 2016


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

The following commit has been merged in the master branch:
commit e65e7fc099d647d62fd7eb36f8ae905839b2a935
Author: David Edmundson <kde at davidedmundson.co.uk>
Date:   Mon Apr 21 00:29:17 2014 +0200

    Add a filter to hide empty groups as well as fix expansion of metacontacts
    
    Remove our rather bad style workaroudn to expand groups with only one
    entry, and instead just filter them out at the model level.
    
    REVIEW: 117671
---
 CMakeLists.txt                                     |  1 +
 contact-list-widget.cpp                            | 38 ++++--------------
 contact-list-widget_p.h                            |  1 -
 empty-row-filter.cpp                               | 45 ++++++++++++++++++++++
 contact-list-application.cpp => empty-row-filter.h | 37 +++++++++---------
 5 files changed, 73 insertions(+), 49 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e66359..8736636 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,6 +47,7 @@ set (ktp_contactlist_SRCS
      contact-delegate-compact.cpp
      account-button.cpp
      account-buttons-panel.cpp
+     empty-row-filter.cpp
      filter-bar.cpp
      main.cpp
      main-widget.cpp
diff --git a/contact-list-widget.cpp b/contact-list-widget.cpp
index 6f92a72..936c3d1 100644
--- a/contact-list-widget.cpp
+++ b/contact-list-widget.cpp
@@ -58,34 +58,13 @@
 #include "contact-delegate.h"
 #include "contact-delegate-compact.h"
 #include "contact-overlays.h"
+#include "empty-row-filter.h"
 
 
 #ifdef HAVE_KPEOPLE
 #include <kpeople/personsmodel.h>
 #endif
 
-//create a new style that does not draw the vertical lines in the tree view
-//this maps "draw branch" to "draw right arrow" and "draw down arrow"
-//we cannot just override drawBranches as then we cannot highlight the active branch
-//Qt does so by utilising some internal methods of QTreeView
-class NoLinesStyle: public QProxyStyle
-{
-    void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const
-    {
-        if (element == QStyle::PE_IndicatorBranch) {
-            if (option->state & QStyle::State_Children) {
-                if (option->state & QStyle::State_Open) {
-                    return QProxyStyle::drawPrimitive(PE_IndicatorArrowDown, option, painter, widget);
-                } else {
-                    return QProxyStyle::drawPrimitive(PE_IndicatorArrowRight, option, painter, widget);
-                }
-            }
-        } else {
-            return QProxyStyle::drawPrimitive(element, option, painter, widget);
-        }
-    }
-};
-
 ContactListWidget::ContactListWidget(QWidget *parent)
     : QTreeView(parent),
       d_ptr(new ContactListWidgetPrivate)
@@ -103,16 +82,9 @@ ContactListWidget::ContactListWidget(QWidget *parent)
     d->model->setTrackUnreadMessages(true);
     d->model->setDynamicSortFilter(true);
     d->model->setSortRole(Qt::DisplayRole);
-    d->style.reset(new NoLinesStyle());
 
-    setStyle(d->style.data());
-    setSortingEnabled(true);
-    sortByColumn(0, Qt::AscendingOrder);
     loadGroupStatesFromConfig();
 
-    connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
-            this, SLOT(onNewGroupModelItemsInserted(QModelIndex,int,int)));
-
     header()->hide();
     setSortingEnabled(true);
     setEditTriggers(NoEditTriggers);
@@ -178,10 +150,16 @@ void ContactListWidget::setAccountManager(const Tp::AccountManagerPtr &accountMa
     d->accountManager = accountManager;
     d->model->setAccountManager(accountManager);
 
+    EmptyRowFilter *rowFilter= new EmptyRowFilter(this);
+    rowFilter->setSourceModel(d->model);
+
+    connect(rowFilter, SIGNAL(rowsInserted(QModelIndex,int,int)),
+            this, SLOT(onNewGroupModelItemsInserted(QModelIndex,int,int)));
+
     // We set the model only when the account manager is set.
     // This fixes the weird horizontal scrollbar bug
     // See https://bugs.kde.org/show_bug.cgi?id=316260
-    setModel(d->model);
+    setModel(rowFilter);
 
     connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
             this, SIGNAL(contactSelectionChanged()));
diff --git a/contact-list-widget_p.h b/contact-list-widget_p.h
index e4a5eb3..df117bc 100644
--- a/contact-list-widget_p.h
+++ b/contact-list-widget_p.h
@@ -54,7 +54,6 @@ public:
     Tp::AccountManagerPtr         accountManager;
     KTp::ContactsModel::GroupMode groupMode; // Stores current grouping mode (by accounts or by groups)
     QPersistentModelIndex         selectedIndex;
-    QScopedPointer<QStyle>        style;
 };
 
 #endif //CONTACT_LIST_WIDGET_P_H
diff --git a/empty-row-filter.cpp b/empty-row-filter.cpp
new file mode 100644
index 0000000..23b1081
--- /dev/null
+++ b/empty-row-filter.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2014  David Edmundson <david 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 Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "empty-row-filter.h"
+
+#include <KTp/types.h>
+
+EmptyRowFilter::EmptyRowFilter(QObject *parent):
+    QSortFilterProxyModel(parent)
+{
+    setDynamicSortFilter(true);
+}
+
+bool EmptyRowFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+{
+    const QModelIndex &index = sourceModel()->index(sourceRow, 0, sourceParent);
+    if (index.data(KTp::RowTypeRole).toInt() == KTp::GroupRowType) {
+        return sourceModel()->rowCount(index) > 0;
+    }
+
+    //hide the expanded view for single contacts
+    if (sourceParent.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType) {
+        return false;
+    }
+
+    return true;
+}
+
+#include "empty-row-filter.moc"
diff --git a/contact-list-application.cpp b/empty-row-filter.h
similarity index 55%
copy from contact-list-application.cpp
copy to empty-row-filter.h
index 8b2a8e0..81598e3 100644
--- a/contact-list-application.cpp
+++ b/empty-row-filter.h
@@ -1,7 +1,6 @@
 /*
- * Contact List Application
- *
- * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
+ * Removes empty rows from the model
+ * Copyright (C) 2014  David Edmundson <david 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
@@ -15,24 +14,26 @@
  *
  * 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
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
  */
 
-#include "contact-list-application.h"
+#ifndef ROWFILTER_H
+#define ROWFILTER_H
 
-ContactListApplication::ContactListApplication() :
-    KUniqueApplication(),
-    m_isShuttingDown(false)
-{
-}
+#include <QSortFilterProxyModel>
 
-void ContactListApplication::commitData(QSessionManager &sm)
+class EmptyRowFilter : public QSortFilterProxyModel
 {
-    m_isShuttingDown = true;
-    KUniqueApplication::commitData(sm);
-}
+    Q_OBJECT
 
-bool ContactListApplication::isShuttingDown() const
-{
-    return m_isShuttingDown;
-}
+public:
+    EmptyRowFilter(QObject *parent=0);
+
+protected:
+    virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
+
+private:
+};
+
+#endif // ROWFILTER_H

-- 
ktp-contact-list packaging



More information about the pkg-kde-commits mailing list