• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
  • contact
collectionfiltermodel.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #include "collectionfiltermodel_p.h"
23 
24 #include <akonadi/entitytreemodel.h>
25 
26 CollectionFilterModel::CollectionFilterModel( QObject *parent )
27  : QSortFilterProxyModel( parent ), mRights( Akonadi::Collection::ReadOnly )
28 {
29 }
30 
31 void CollectionFilterModel::addContentMimeTypeFilter( const QString &mimeType )
32 {
33  mContentMimeTypes.insert( mimeType );
34  invalidateFilter();
35 }
36 
37 void CollectionFilterModel::setRightsFilter( Akonadi::Collection::Rights rights )
38 {
39  mRights = rights;
40  invalidateFilter();
41 }
42 
43 bool CollectionFilterModel::filterAcceptsRow( int row, const QModelIndex &parent ) const
44 {
45  bool accepted = true;
46 
47  const QModelIndex index = sourceModel()->index( row, 0, parent );
48  const Akonadi::Collection collection = index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
49  if ( !collection.isValid() ) {
50  return false;
51  }
52 
53  if ( !mContentMimeTypes.isEmpty() ) {
54  QSet<QString> contentMimeTypes = collection.contentMimeTypes().toSet();
55  accepted = accepted && !( contentMimeTypes.intersect( mContentMimeTypes ).isEmpty() );
56  }
57 
58  if ( mRights != Akonadi::Collection::ReadOnly ) {
59  accepted = accepted && ( collection.rights() & mRights );
60  }
61 
62  return accepted;
63 }
64 
65 #include "moc_collectionfiltermodel_p.cpp"
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::Collection::ReadOnly
Can only read items or subcollection of this collection.
Definition: collection.h:87
Akonadi::EntityTreeModel::CollectionRole
The collection.
Definition: entitytreemodel.h:335
Akonadi::Collection::rights
Rights rights() const
Returns the rights the user has on the collection.
Definition: collection.cpp:99
Akonadi::Collection::contentMimeTypes
QStringList contentMimeTypes() const
Returns a list of possible content mimetypes, e.g.
Definition: collection.cpp:115
CollectionFilterModel::addContentMimeTypeFilter
void addContentMimeTypeFilter(const QString &mimeType)
Adds a mime type to the content mime type filter list.
Definition: collectionfiltermodel.cpp:31
CollectionFilterModel::CollectionFilterModel
CollectionFilterModel(QObject *parent)
Creates a new collection filter model.
Definition: collectionfiltermodel.cpp:26
Akonadi::Entity::isValid
bool isValid() const
Returns whether the entity is valid.
Definition: entity.cpp:97
CollectionFilterModel::setRightsFilter
void setRightsFilter(Akonadi::Collection::Rights rights)
Sets the collection rights filter.
Definition: collectionfiltermodel.cpp:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal