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

akonadi

  • 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
26CollectionFilterModel::CollectionFilterModel( QObject *parent )
27 : QSortFilterProxyModel( parent ), mRights( Akonadi::Collection::ReadOnly )
28{
29}
30
31void CollectionFilterModel::addContentMimeTypeFilter( const QString &mimeType )
32{
33 mContentMimeTypes.insert( mimeType );
34 invalidateFilter();
35}
36
37void CollectionFilterModel::setRightsFilter( Akonadi::Collection::Rights rights )
38{
39 mRights = rights;
40 invalidateFilter();
41}
42
43bool 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:76
Akonadi::Collection::ReadOnly
@ ReadOnly
Can only read items or subcollection of this collection.
Definition: collection.h:87
Akonadi::EntityTreeModel::CollectionRole
@ CollectionRole
The collection.
Definition: entitytreemodel.h:336
CollectionFilterModel::addContentMimeTypeFilter
void addContentMimeTypeFilter(const QString &mimeType)
Adds a mime type to the content mime type filter list.
Definition: collectionfiltermodel.cpp:31
CollectionFilterModel::setRightsFilter
void setRightsFilter(Akonadi::Collection::Rights rights)
Sets the collection rights filter.
Definition: collectionfiltermodel.cpp:37
CollectionFilterModel::CollectionFilterModel
CollectionFilterModel(QObject *parent)
Creates a new collection filter model.
Definition: collectionfiltermodel.cpp:26
Akonadi
FreeBusyManager::Singleton.
Definition: actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.5 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-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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