[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepimlibs] akonadi/calendar: Filter out items from the KCheckableProxyModel.
From:       Sergio Martins <iamsergio () gmail ! com>
Date:       2012-12-23 19:23:21
Message-ID: 20121223192321.73658A6091 () git ! kde ! org
[Download RAW message or body]

Git commit 120e06124cfda36ae520d3e9d6b436298e3c5c8e by Sergio Martins.
Committed on 23/12/2012 at 20:19.
Pushed by smartins into branch 'master'.

Filter out items from the KCheckableProxyModel.

There's no point in having items with checkboxes.

M  +12   -10   akonadi/calendar/etmcalendar.cpp
M  +2    -0    akonadi/calendar/etmcalendar_p.h

http://commits.kde.org/kdepimlibs/120e06124cfda36ae520d3e9d6b436298e3c5c8e

diff --git a/akonadi/calendar/etmcalendar.cpp b/akonadi/calendar/etmcalendar.cpp
index c3e27fc..b39f7b2 100644
--- a/akonadi/calendar/etmcalendar.cpp
+++ b/akonadi/calendar/etmcalendar.cpp
@@ -32,6 +32,7 @@
 #include <akonadi/entitydisplayattribute.h>
 #include <akonadi/entitymimetypefiltermodel.h>
 #include <akonadi/entitytreemodel.h>
+#include <akonadi/collectionfilterproxymodel.h>
 #include <KSelectionProxyModel>
 #include <kcheckableproxymodel.h>
 
@@ -100,27 +101,28 @@ void ETMCalendarPrivate::init()
 
 void ETMCalendarPrivate::setupFilteredETM()
 {
-  // Our calendar tree must be sorted.
-  QSortFilterProxyModel *sortFilterProxy = new QSortFilterProxyModel( this );
-  sortFilterProxy->setObjectName( "Sort" );
-  sortFilterProxy->setDynamicSortFilter( true );
-  sortFilterProxy->setSortCaseSensitivity( Qt::CaseInsensitive );
-  sortFilterProxy->setSourceModel( mETM );
-
   // We're only interested in the CollectionTitle column
   KColumnFilterProxyModel *columnFilterProxy = new KColumnFilterProxyModel( this );
-  columnFilterProxy->setSourceModel( sortFilterProxy );
+  columnFilterProxy->setSourceModel( mETM );
   columnFilterProxy->setVisibleColumn( CalendarModel::CollectionTitle );
   columnFilterProxy->setObjectName( "Remove columns" );
 
+  mCollectionProxyModel = new Akonadi::CollectionFilterProxyModel( this );
+  mCollectionProxyModel->setObjectName( "Only show collections" );
+  mCollectionProxyModel->setDynamicSortFilter( true );
+  mCollectionProxyModel->addMimeTypeFilter( QString::fromLatin1( "text/calendar" ) );
+  mCollectionProxyModel->setExcludeVirtualCollections( true );
+  mCollectionProxyModel->setSortCaseSensitivity( Qt::CaseInsensitive );
+  mCollectionProxyModel->setSourceModel( columnFilterProxy );
+
   // Keep track of selected items.
-  QItemSelectionModel* selectionModel = new QItemSelectionModel( columnFilterProxy );
+  QItemSelectionModel* selectionModel = new QItemSelectionModel( mCollectionProxyModel );
   selectionModel->setObjectName( "Calendar Selection Model" );
 
   // Make item selection work by means of checkboxes.
   mCheckableProxyModel = new KCheckableProxyModel( this );
   mCheckableProxyModel->setSelectionModel( selectionModel );
-  mCheckableProxyModel->setSourceModel( columnFilterProxy );
+  mCheckableProxyModel->setSourceModel( mCollectionProxyModel );
   mCheckableProxyModel->setObjectName( "Add checkboxes" );
 
   KSelectionProxyModel* selectionProxy = new KSelectionProxyModel( selectionModel, /**parent=*/this );
diff --git a/akonadi/calendar/etmcalendar_p.h b/akonadi/calendar/etmcalendar_p.h
index ad141b6..17afccc 100644
--- a/akonadi/calendar/etmcalendar_p.h
+++ b/akonadi/calendar/etmcalendar_p.h
@@ -34,6 +34,7 @@ namespace Akonadi {
 
 class EntityTreeModel;
 class EntityMimeTypeFilterModel;
+class CollectionFilterProxyModel;
 
 class ETMCalendarPrivate : public CalendarBasePrivate
 {
@@ -82,6 +83,7 @@ public:
   // akonadi id to collections
   QHash<Akonadi::Entity::Id, Akonadi::Collection> mCollectionMap;
   KCheckableProxyModel *mCheckableProxyModel;
+  Akonadi::CollectionFilterProxyModel *mCollectionProxyModel;
 private:
   ETMCalendar *const q;
 };
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic