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

akonadi

  • akonadi
  • calendar
etmcalendar_p.h
1/*
2 Copyright (c) 2011-2012 Sérgio Martins <iamsergio@gmail.com>
3
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
8
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18*/
19
20#ifndef AKONADI_ETMCALENDAR_P_H
21#define AKONADI_ETMCALENDAR_P_H
22
23#include "etmcalendar.h"
24#include "calendarbase_p.h"
25#include "incidencechanger.h"
26#include "calendarmodel_p.h"
27
28#include <akonadi/entitytreemodel.h>
29#include <KCheckableProxyModel>
30
31#include <QSet>
32#include <QModelIndex>
33
34class QAbstractItemModel;
35class CheckableProxyModel;
36class KSelectionProxyModel;
37
38namespace Akonadi {
39
40class EntityTreeModel;
41class EntityMimeTypeFilterModel;
42class CollectionFilterProxyModel;
43class CalFilterProxyModel;
44
45static bool isStructuralCollection(const Akonadi::Collection &collection)
46{
47 QStringList mimeTypes;
48 mimeTypes << QLatin1String("text/calendar")
49 << KCalCore::Event::eventMimeType()
50 << KCalCore::Todo::todoMimeType()
51 << KCalCore::Journal::journalMimeType();
52 const QStringList collectionMimeTypes = collection.contentMimeTypes();
53 foreach(const QString &mimeType, mimeTypes) {
54 if (collectionMimeTypes.contains(mimeType))
55 return false;
56 }
57
58 return true;
59}
60
61class CheckableProxyModel : public KCheckableProxyModel {
62 Q_OBJECT
63public:
64 CheckableProxyModel(QObject *parent = 0) : KCheckableProxyModel(parent)
65 {
66 }
67
68 QVariant data(const QModelIndex &index, int role) const
69 {
70 if (role == Qt::CheckStateRole) {
71 // Don't show the checkbox if the collection can't contain incidences
72 const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
73 if (isStructuralCollection(collection))
74 return QVariant();
75 }
76 return KCheckableProxyModel::data(index, role);
77 }
78};
79
80class ETMCalendarPrivate : public CalendarBasePrivate
81{
82 Q_OBJECT
83public:
84
85 explicit ETMCalendarPrivate(ETMCalendar *qq);
86 ~ETMCalendarPrivate();
87
88 void init();
89 void setupFilteredETM();
90 void loadFromETM();
91
92public Q_SLOTS:
93 Akonadi::Item::List itemsFromModel(const QAbstractItemModel *model,
94 const QModelIndex &parentIndex = QModelIndex(),
95 int start = 0,
96 int end = -1);
97
98 Akonadi::Collection::List collectionsFromModel(const QAbstractItemModel *model,
99 const QModelIndex &parentIndex = QModelIndex(),
100 int start = 0,
101 int end = -1);
102
103 // KCalCore::CalFilter has changed.
104 void onFilterChanged();
105
106 void clear();
107 void updateItem(const Akonadi::Item &);
108 Akonadi::Item itemFromIndex(const QModelIndex &idx);
109 Akonadi::Collection collectionFromIndex(const QModelIndex &index);
110 void itemsAdded(const Akonadi::Item::List &items);
111 void itemsRemoved(const Akonadi::Item::List &items);
112
113 void onRowsInserted(const QModelIndex &index, int start, int end);
114 void onRowsRemoved(const QModelIndex &index, int start, int end);
115 void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
116 void onRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd,
117 const QModelIndex &destinationParent, int destinationRow);
118
119 void onLayoutChangedInFilteredModel();
120 void onModelResetInFilteredModel();
121 void onDataChangedInFilteredModel(const QModelIndex &topLeft, const QModelIndex &bottomRight);
122 void onRowsInsertedInFilteredModel(const QModelIndex &index, int start, int end);
123 void onRowsAboutToBeRemovedInFilteredModel(const QModelIndex &index, int start, int end);
124 void onCollectionChanged(const Akonadi::Collection &, const QSet<QByteArray> &);
125 void onCollectionPopulated(Akonadi::Collection::Id);
126
127public:
128 Akonadi::CalendarModel::Ptr mETM;
129 Akonadi::EntityMimeTypeFilterModel *mFilteredETM;
130
131 // akonadi id to collections
132 QHash<Akonadi::Entity::Id, Akonadi::Collection> mCollectionMap;
133 CheckableProxyModel *mCheckableProxyModel;
134 Akonadi::CollectionFilterProxyModel *mCollectionProxyModel;
135 Akonadi::CalFilterProxyModel *mCalFilterProxyModel; //KCalCore::CalFilter stuff
136 KSelectionProxyModel *mSelectionProxy;
137 bool mCollectionFilteringEnabled;
138 QSet<Akonadi::Collection::Id> mPopulatedCollectionIds;
139 QStringList mMimeTypes;
140private:
141 ETMCalendar *const q;
142};
143
144}
145
146#endif
Akonadi::CollectionFilterProxyModel
A proxy model that filters collections by mime type.
Definition collectionfilterproxymodel.h:55
Akonadi::Collection
Represents a collection of PIM items.
Definition collection.h:76
Akonadi::Collection::List
QList< Collection > List
Describes a list of collections.
Definition collection.h:81
Akonadi::EntityMimeTypeFilterModel
A proxy model that filters entities by mime type.
Definition entitymimetypefiltermodel.h:62
Akonadi::EntityTreeModel::CollectionRole
@ CollectionRole
The collection.
Definition entitytreemodel.h:336
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition entity.h:65
Akonadi
FreeBusyManager::Singleton.
Definition actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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
  • 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