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

kalarm

  • sources
  • kde-4.14
  • kdepim
  • kalarm
itemlistmodel.h
Go to the documentation of this file.
1 /*
2  * itemlistmodel.h - Akonadi item models
3  * Program: kalarm
4  * Copyright © 2010,2011 by David Jarvie <djarvie@kde.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef ITEMLISTMODEL_H
22 #define ITEMLISTMODEL_H
23 
24 #include "akonadimodel.h"
25 
26 #include <kalarmcal/kacalendar.h>
27 #include <kalarmcal/kaevent.h>
28 
29 #include <akonadi/entitymimetypefiltermodel.h>
30 
31 using namespace KAlarmCal;
32 
33 /*=============================================================================
34 = Class: ItemListModel
35 = Filter proxy model containing all items (alarms/templates) of specified mime
36 = types in enabled collections.
37 =============================================================================*/
38 class ItemListModel : public Akonadi::EntityMimeTypeFilterModel
39 {
40  Q_OBJECT
41  public:
45  explicit ItemListModel(CalEvent::Types allowed, QObject* parent = 0);
46 
47  CalEvent::Types includedTypes() const { return mAllowedTypes; }
48  KAEvent event(int row) const;
49  KAEvent event(const QModelIndex&) const;
50  using QObject::event; // prevent warning about hidden virtual method
51  QModelIndex eventIndex(Akonadi::Item::Id) const;
52 
54  bool haveEvents() const;
55 
56  virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
57  virtual Qt::ItemFlags flags(const QModelIndex&) const;
58 
59  static int iconWidth() { return AkonadiModel::iconSize().width(); }
60 
61  signals:
65  void haveEventsStatus(bool have);
66 
67  protected:
68  virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
69 
70  private slots:
71  void slotRowsInserted();
72  void slotRowsRemoved();
73  void collectionStatusChanged(const Akonadi::Collection& collection, AkonadiModel::Change change, const QVariant&, bool inserted);
74 
75  private:
76  CalEvent::Types mAllowedTypes; // types of events allowed in this model
77  bool mHaveEvents; // there are events in this model
78 };
79 
80 
81 /*=============================================================================
82 = Class: AlarmListModel
83 = Filter proxy model containing all alarms of specified mime types in enabled
84 = collections.
85 Equivalent to AlarmListFilterModel
86 =============================================================================*/
87 class AlarmListModel : public ItemListModel
88 {
89  Q_OBJECT
90  public:
91  enum { // data columns
92  TimeColumn = 0, TimeToColumn, RepeatColumn, ColourColumn, TypeColumn, TextColumn,
93  ColumnCount
94  };
95 
96  explicit AlarmListModel(QObject* parent = 0);
97  ~AlarmListModel();
98 
100  static AlarmListModel* all();
101 
106  void setEventTypeFilter(CalEvent::Types types);
107 
111  CalEvent::Types eventTypeFilter() const { return mFilterTypes; }
112 
113  virtual int columnCount(const QModelIndex& = QModelIndex()) const { return ColumnCount; }
114  virtual QVariant headerData(int section, Qt::Orientation, int role = Qt::DisplayRole) const;
115 
116  protected:
117  virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
118  virtual bool filterAcceptsColumn(int sourceCol, const QModelIndex& sourceParent) const;
119 
120  private:
121  static AlarmListModel* mAllInstance;
122 
123  CalEvent::Types mFilterTypes; // types of events contained in this model
124 };
125 
126 
127 /*=============================================================================
128 = Class: TemplateListModel
129 = Filter proxy model containing all alarm templates for specified alarm types
130 = in enabled collections.
131 Equivalent to TemplateListFilterModel
132 =============================================================================*/
133 class TemplateListModel : public ItemListModel
134 {
135  Q_OBJECT
136  public:
137  enum { // data columns
138  TypeColumn, TemplateNameColumn,
139  ColumnCount
140  };
141 
142  explicit TemplateListModel(QObject* parent = 0);
143  ~TemplateListModel();
144 
146  static TemplateListModel* all();
147 
149  void setAlarmActionFilter(KAEvent::Actions);
150 
152  KAEvent::Actions alarmActionFilter() const { return mActionsFilter; }
153 
155  void setAlarmActionsEnabled(KAEvent::Actions);
156 
158  KAEvent::Actions setAlarmActionsEnabled() const { return mActionsEnabled; }
159 
160  virtual int columnCount(const QModelIndex& = QModelIndex()) const { return ColumnCount; }
161  virtual QVariant headerData(int section, Qt::Orientation, int role = Qt::DisplayRole) const;
162  virtual Qt::ItemFlags flags(const QModelIndex&) const;
163 
164  protected:
165  virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
166  virtual bool filterAcceptsColumn(int sourceCol, const QModelIndex& sourceParent) const;
167 
168  private:
169  static TemplateListModel* mAllInstance;
170 
171  KAEvent::Actions mActionsEnabled; // disable types not in this mask
172  KAEvent::Actions mActionsFilter; // hide types not in this mask
173 };
174 
175 #endif // ITEMLISTMODEL_H
176 
177 // vim: et sw=4:
QModelIndex
QSize::width
int width() const
TemplateListModel::columnCount
virtual int columnCount(const QModelIndex &=QModelIndex()) const
Definition: itemlistmodel.h:160
ItemListModel::includedTypes
CalEvent::Types includedTypes() const
Definition: itemlistmodel.h:47
TemplateListModel
Definition: itemlistmodel.h:133
QObject::event
virtual bool event(QEvent *e)
akonadimodel.h
ItemListModel::iconWidth
static int iconWidth()
Definition: itemlistmodel.h:59
AlarmListModel::TypeColumn
Definition: itemlistmodel.h:92
QObject
AkonadiModel::Change
Change
Definition: akonadimodel.h:50
AlarmListModel::columnCount
virtual int columnCount(const QModelIndex &=QModelIndex()) const
Definition: itemlistmodel.h:113
AlarmListModel::eventTypeFilter
CalEvent::Types eventTypeFilter() const
Return the filter set by setEventTypeFilter().
Definition: itemlistmodel.h:111
TemplateListModel::alarmActionFilter
KAEvent::Actions alarmActionFilter() const
Return which alarm action types are included in the model.
Definition: itemlistmodel.h:152
TemplateListModel::TypeColumn
Definition: itemlistmodel.h:138
AkonadiModel::iconSize
static QSize iconSize()
Definition: akonadimodel.h:204
TemplateListModel::setAlarmActionsEnabled
KAEvent::Actions setAlarmActionsEnabled() const
Set which alarm types should be shown as disabled in the model.
Definition: itemlistmodel.h:158
AlarmListModel
Definition: itemlistmodel.h:87
ItemListModel
Definition: itemlistmodel.h:38
QVariant
Qt::ItemFlags
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalarm

Skip menu "kalarm"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

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