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

kalarm

resourcemodelview.h

Go to the documentation of this file.
00001 /*
00002  *  resourcemodelview.h  -  model/view classes for alarm resource lists
00003  *  Program:  kalarm
00004  *  Copyright © 2007,2008 by David Jarvie <djarvie@kde.org>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef RESOURCEMODELVIEW_H
00022 #define RESOURCEMODELVIEW_H
00023 
00024 #include "kalarm.h"
00025 
00026 #include <QAbstractListModel>
00027 #include <QSortFilterProxyModel>
00028 #include <QItemDelegate>
00029 #include <QListView>
00030 #include <QList>
00031 #include <QFont>
00032 #include <QColor>
00033 
00034 #include "resources/alarmresource.h"
00035 #include "resources/alarmresources.h"
00036 
00037 
00038 class ResourceModel : public QAbstractListModel
00039 {
00040         Q_OBJECT
00041     public:
00042         static ResourceModel* instance(QObject* parent = 0);
00043         virtual int      rowCount(const QModelIndex& parent = QModelIndex()) const;
00044         virtual QModelIndex index(int row, int column, const QModelIndex& parent) const;
00045         virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
00046         virtual bool     setData(const QModelIndex&, const QVariant& value, int role = Qt::EditRole);
00047         virtual Qt::ItemFlags flags(const QModelIndex&) const;
00048         AlarmResource*   resource(const QModelIndex&) const;
00049         void             removeResource(AlarmResource*);
00050         void             notifyChange(const QModelIndex&);
00051 
00052     private slots:
00053         void             refresh();
00054         void             addResource(AlarmResource*);
00055         void             updateResource(AlarmResource*);
00056         void             slotStandardChanged(AlarmResource::Type);
00057         void             slotLoaded(AlarmResource*, bool active);
00058         void             slotStatusChanged(AlarmResource*, AlarmResources::Change);
00059 
00060     private:
00061         explicit ResourceModel(QObject* parent = 0);
00062 
00063         static ResourceModel* mInstance;
00064         QList<AlarmResource*> mResources;
00065         QString               mErrorPrompt;
00066         QFont                 mFont;
00067 };
00068 
00069 
00070 class ResourceFilterModel : public QSortFilterProxyModel
00071 {
00072     public:
00073         ResourceFilterModel(QAbstractItemModel* baseModel, QObject* parent);
00074         void           setFilter(AlarmResource::Type);
00075         AlarmResource* resource(int row) const;
00076         AlarmResource* resource(const QModelIndex&) const;
00077         void           notifyChange(int row);
00078         void           notifyChange(const QModelIndex&);
00079 
00080     protected:
00081         virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
00082 
00083     private:
00084         AlarmResource::Type mResourceType;
00085 };
00086 
00087 
00088 class ResourceView : public QListView
00089 {
00090     public:
00091         ResourceView(QWidget* parent = 0)  : QListView(parent) {}
00092         virtual void   setModel(QAbstractItemModel*);
00093         AlarmResource* resource(int row) const;
00094         AlarmResource* resource(const QModelIndex&) const;
00095         void           notifyChange(int row) const;
00096         void           notifyChange(const QModelIndex&) const;
00097 
00098     protected:
00099         virtual void   mouseReleaseEvent(QMouseEvent*);
00100         virtual bool   viewportEvent(QEvent*);
00101 };
00102 
00103 
00104 class ResourceDelegate : public QItemDelegate
00105 {
00106     public:
00107         ResourceDelegate(ResourceView* parent = 0)  : QItemDelegate(parent) {}
00108         virtual bool editorEvent(QEvent*, QAbstractItemModel*, const QStyleOptionViewItem&, const QModelIndex&);
00109 };
00110 
00111 #endif // RESOURCEMODELVIEW_H
00112 

kalarm

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal