• 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
  • 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 
27 #include <akonadi/entitytreemodel.h>
28 #include <KCheckableProxyModel>
29 
30 #include <QSet>
31 #include <QVector>
32 #include <QModelIndex>
33 
34 class QAbstractItemModel;
35 class CheckableProxyModel;
36 class KSelectionProxyModel;
37 
38 namespace Akonadi {
39 
40 class EntityTreeModel;
41 class EntityMimeTypeFilterModel;
42 class CollectionFilterProxyModel;
43 class CalFilterProxyModel;
44 
45 static 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 
61 class CheckableProxyModel : public KCheckableProxyModel {
62  Q_OBJECT
63 public:
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 
80 class ETMCalendarPrivate : public CalendarBasePrivate
81 {
82  Q_OBJECT
83 public:
84 
85  explicit ETMCalendarPrivate(ETMCalendar *qq);
86  ~ETMCalendarPrivate();
87 
88  void init();
89  void setupFilteredETM();
90  void loadFromETM();
91 
92 public 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 
127 public:
128  Akonadi::EntityTreeModel *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;
140 private:
141  ETMCalendar *const q;
142 };
143 
144 }
145 
146 #endif
Akonadi::CollectionFilterProxyModel
A proxy model that filters collections by mime type.
Definition: collectionfilterproxymodel.h:54
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition: entity.h:65
Akonadi::EntityMimeTypeFilterModel
A proxy model that filters entities by mime type.
Definition: entitymimetypefiltermodel.h:61
Akonadi::EntityTreeModel::CollectionRole
The collection.
Definition: entitytreemodel.h:335
Akonadi::EntityTreeModel
A model for collections and items together.
Definition: entitytreemodel.h:317
Akonadi::Collection::contentMimeTypes
QStringList contentMimeTypes() const
Returns a list of possible content mimetypes, e.g.
Definition: collection.cpp:115
Akonadi::Collection::List
QList< Collection > List
Describes a list of collections.
Definition: collection.h:81
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:27 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