• 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
resourcemodelview.h
Go to the documentation of this file.
1 /*
2  * resourcemodelview.h - model/view classes for alarm resource lists
3  * Program: kalarm
4  * Copyright © 2007,2008,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 RESOURCEMODELVIEW_H
22 #define RESOURCEMODELVIEW_H
23 
24 #include "kalarm.h"
25 
26 #include "resources/alarmresource.h"
27 #include "resources/alarmresources.h"
28 
29 #include <QAbstractListModel>
30 #include <QSortFilterProxyModel>
31 #include <QItemDelegate>
32 #include <QListView>
33 #include <QList>
34 #include <QFont>
35 
36 using namespace KAlarmCal;
37 
38 class ResourceModel : public QAbstractListModel
39 {
40  Q_OBJECT
41  public:
42  static ResourceModel* instance(QObject* parent = 0);
43  virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
44  virtual QModelIndex index(int row, int column, const QModelIndex& parent) const;
45  virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
46  virtual bool setData(const QModelIndex&, const QVariant& value, int role = Qt::EditRole);
47  virtual Qt::ItemFlags flags(const QModelIndex&) const;
48  AlarmResource* resource(const QModelIndex&) const;
49  void removeResource(AlarmResource*);
50  void notifyChange(const QModelIndex&);
51 
52  private slots:
53  void refresh();
54  void addResource(AlarmResource*);
55  void updateResource(AlarmResource*);
56  void slotStandardChanged(CalEvent::Type);
57  void slotLoaded(AlarmResource*, bool active);
58  void slotStatusChanged(AlarmResource*, AlarmResources::Change);
59 
60  private:
61  explicit ResourceModel(QObject* parent = 0);
62 
63  static ResourceModel* mInstance;
64  QList<AlarmResource*> mResources;
65  QString mErrorPrompt;
66  QFont mFont;
67 };
68 
69 
70 class ResourceFilterModel : public QSortFilterProxyModel
71 {
72  Q_OBJECT
73  public:
74  ResourceFilterModel(QAbstractItemModel* baseModel, QObject* parent);
75  void setFilter(CalEvent::Type);
76  AlarmResource* resource(int row) const;
77  AlarmResource* resource(const QModelIndex&) const;
78  void notifyChange(int row);
79  void notifyChange(const QModelIndex&);
80 
81  protected:
82  virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
83 
84  private:
85  CalEvent::Type mResourceType;
86 };
87 
88 
89 class ResourceView : public QListView
90 {
91  Q_OBJECT
92  public:
93  explicit ResourceView(QWidget* parent = 0) : QListView(parent) {}
94  virtual void setModel(QAbstractItemModel*);
95  AlarmResource* resource(int row) const;
96  AlarmResource* resource(const QModelIndex&) const;
97  void notifyChange(int row) const;
98  void notifyChange(const QModelIndex&) const;
99 
100  protected:
101  virtual void mouseReleaseEvent(QMouseEvent*);
102  virtual bool viewportEvent(QEvent*);
103 };
104 
105 
106 class ResourceDelegate : public QItemDelegate
107 {
108  Q_OBJECT
109  public:
110  explicit ResourceDelegate(ResourceView* parent = 0) : QItemDelegate(parent) {}
111  virtual bool editorEvent(QEvent*, QAbstractItemModel*, const QStyleOptionViewItem&, const QModelIndex&);
112 };
113 
114 #endif // RESOURCEMODELVIEW_H
115 
116 // vim: et sw=4:
QModelIndex
QEvent
QWidget
QFont
QMouseEvent
ResourceView
Definition: resourcemodelview.h:89
QListView
QStyleOptionViewItem
QObject
QAbstractListModel
QItemDelegate
QString
QList< AlarmResource * >
ResourceDelegate::ResourceDelegate
ResourceDelegate(ResourceView *parent=0)
Definition: resourcemodelview.h:110
QSortFilterProxyModel
ResourceView::ResourceView
ResourceView(QWidget *parent=0)
Definition: resourcemodelview.h:93
kalarm.h
QAbstractItemModel
ResourceModel
Definition: resourcemodelview.h:38
ResourceFilterModel
Definition: resourcemodelview.h:70
QVariant
ResourceDelegate
Definition: resourcemodelview.h:106
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