[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bkdepim=5D_kaddressbook=3A_Don=27t_show_a_checkbox_n?=
From: Till Adam <till () kdab ! com>
Date: 2011-04-30 18:09:16
Message-ID: 20110430180916.437EDA60A4 () git ! kde ! org
[Download RAW message or body]
Git commit d66885f8233f4402302148b6c6a992c5529ebe30 by Till Adam.
Committed on 06/03/2011 at 21:56.
Pushed by tilladam into branch 'master'.
Don't show a checkbox next to structural collections.
M +40 -1 kaddressbook/mainwidget.cpp
http://commits.kde.org/kdepim/d66885f8233f4402302148b6c6a992c5529ebe30
diff --git a/kaddressbook/mainwidget.cpp b/kaddressbook/mainwidget.cpp
index 8c0c793..924fba1 100644
--- a/kaddressbook/mainwidget.cpp
+++ b/kaddressbook/mainwidget.cpp
@@ -79,6 +79,45 @@
#include <QtGui/QSplitter>
#include <QtGui/QStackedWidget>
+
+
+namespace {
+static bool isStructuralCollection( const Akonadi::Collection &collection )
+{
+ QStringList mimeTypes;
+ mimeTypes << KABC::Addressee::mimeType() << KABC::ContactGroup::mimeType();
+ const QStringList collectionMimeTypes = collection.contentMimeTypes();
+ foreach ( const QString &mimeType, mimeTypes ) {
+ if ( collectionMimeTypes.contains( mimeType ) )
+ return false;
+ }
+ return true;
+}
+
+class StructuralCollectionsNotCheckableProxy : public Future::KCheckableProxyModel {
+public:
+ StructuralCollectionsNotCheckableProxy(QObject* parent)
+ :Future::KCheckableProxyModel(parent)
+ { }
+
+ /* reimp */ QVariant data( const QModelIndex &index, int role ) const
+ {
+ if ( !index.isValid() )
+ return QVariant();
+
+ if ( role == Qt::CheckStateRole ) {
+ // Don't show the checkbox if the collection can't contain incidences
+ const Akonadi::Collection collection = index.data( \
Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>(); + if ( \
collection.isValid() && isStructuralCollection( collection ) ) { + return \
QVariant(); + }
+ }
+ return Future::KCheckableProxyModel::data( index, role );
+ }
+};
+
+}
+
MainWidget::MainWidget( KXMLGUIClient *guiClient, QWidget *parent )
: QWidget( parent ), mAllContactsModel( 0 ), mXmlGuiClient( guiClient )
{
@@ -141,7 +180,7 @@ MainWidget::MainWidget( KXMLGUIClient *guiClient, QWidget *parent \
) mCollectionTree->setHeaderGroup( Akonadi::EntityTreeModel::CollectionTreeHeaders \
);
mCollectionSelectionModel = new QItemSelectionModel( mCollectionTree );
- Future::KCheckableProxyModel *checkableProxyModel = new \
Future::KCheckableProxyModel( this ); + StructuralCollectionsNotCheckableProxy \
*checkableProxyModel = new StructuralCollectionsNotCheckableProxy( this ); \
checkableProxyModel->setSelectionModel( mCollectionSelectionModel ); \
checkableProxyModel->setSourceModel( mCollectionTree );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic