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

kalarm

eventlistmodel.h

Go to the documentation of this file.
00001 /*
00002  *  eventlistmodel.h  -  model class for lists of alarms or templates
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 EVENTLISTMODEL_H
00022 #define EVENTLISTMODEL_H
00023 
00024 #include "kalarm.h"
00025 
00026 #include <QAbstractTableModel>
00027 #include <QSortFilterProxyModel>
00028 #include <QList>
00029 #include <QSize>
00030 
00031 #include "kcalendar.h"
00032 #include "alarmevent.h"
00033 #include "alarmresources.h"
00034 
00035 class QPixmap;
00036 namespace KCal { class Event; }
00037 class DateTime;
00038 class KAEvent;
00039 
00040 
00041 class EventListModel : public QAbstractTableModel
00042 {
00043         Q_OBJECT
00044     public:
00045         enum {   // data columns
00046             TimeColumn, TimeToColumn, RepeatColumn, ColourColumn, TypeColumn, TextColumn,
00047             TemplateNameColumn,
00048             ColumnCount
00049         };
00050         enum {   // additional roles
00051             StatusRole = Qt::UserRole,  // return ACTIVE/ARCHIVED
00052             ValueRole,                  // return numeric value
00053             SortRole                    // return the value to use for sorting
00054         };
00055 
00056         static EventListModel* alarms();
00057         static EventListModel* templates();
00058         ~EventListModel();
00059         virtual int           rowCount(const QModelIndex& parent = QModelIndex()) const;
00060         virtual int           columnCount(const QModelIndex& parent = QModelIndex()) const;
00061         virtual QModelIndex   index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
00062         virtual QVariant      data(const QModelIndex&, int role = Qt::DisplayRole) const;
00063         virtual bool          setData(const QModelIndex&, const QVariant& value, int role = Qt::EditRole);
00064         virtual QVariant      headerData(int section, Qt::Orientation, int role = Qt::DisplayRole) const;
00065         virtual Qt::ItemFlags flags(const QModelIndex&) const;
00066         static int            iconWidth()       { return mIconSize.width(); }
00067         QModelIndex           eventIndex(const KAEvent*) const;
00068         QModelIndex           eventIndex(const QString& eventId) const;
00069         void                  addEvent(KAEvent*);
00070         void                  addEvents(const KAEvent::List&);
00071         bool                  updateEvent(KAEvent* event)           { return updateEvent(mEvents.indexOf(event)); }
00072         bool                  updateEvent(const QString& eventId)   { return updateEvent(findEvent(eventId)); }
00073         bool                  updateEvent(const QString& oldId, KAEvent* newEvent);
00074         void                  removeEvent(const KAEvent* event)     { removeEvent(mEvents.indexOf(const_cast<KAEvent*>(event))); }
00075         void                  removeEvent(const QString& eventId)   { removeEvent(findEvent(eventId)); }
00076         void                  removeResource(AlarmResource*);
00077         static KAEvent*       event(const QModelIndex&);
00078 
00079     public slots:
00080         void                  reload();
00081 
00082     private slots:
00083         void     slotUpdateTimeTo();
00084         void     slotUpdateArchivedColour(const QColor&);
00085         void     slotUpdateDisabledColour(const QColor&);
00086         void     slotUpdateWorkingHours();
00087         void     slotResourceLoaded(AlarmResource*, bool active);
00088         void     slotResourceStatusChanged(AlarmResource*, AlarmResources::Change);
00089 
00090     private:
00091         explicit EventListModel(KCalEvent::Status, QObject* parent = 0);
00092         bool     updateEvent(int row);
00093         void     removeEvent(int row);
00094         int      findEvent(const QString& eventId) const;
00095         QString  alarmTimeText(const DateTime&) const;
00096         QString  timeToAlarmText(const DateTime&) const;
00097         QString  repeatText(const KAEvent*) const;
00098         QString  repeatOrder(const KAEvent*) const;
00099         QPixmap* eventIcon(const KAEvent*) const;
00100         QString  whatsThisText(int column) const;
00101 
00102         static EventListModel* mAlarmInstance;     // the instance containing all alarms
00103         static EventListModel* mTemplateInstance;  // the instance containing all templates
00104         static QPixmap* mTextIcon;
00105         static QPixmap* mFileIcon;
00106         static QPixmap* mCommandIcon;
00107         static QPixmap* mEmailIcon;
00108         static QSize    mIconSize;      // maximum size of any icon
00109         static int      mTimeHourPos;   // position of hour within time string, or -1 if leading zeroes included
00110 
00111         KAEvent::List       mEvents;
00112         KCalEvent::Status   mStatus;    // types of events contained in this model
00113 
00114         using QObject::event;   // prevent "hidden" warning
00115 };
00116 
00117 
00118 class EventListFilterModel : public QSortFilterProxyModel
00119 {
00120         Q_OBJECT
00121     public:
00122         explicit EventListFilterModel(EventListModel* baseModel, QObject* parent = 0);
00123         KAEvent* event(int row) const;
00124         KAEvent* event(const QModelIndex&) const;
00125     
00126     private slots:
00127         void     slotDataChanged(const QModelIndex&, const QModelIndex&);
00128 
00129     private:
00130         using QObject::event;   // prevent "hidden" warning
00131 };
00132 
00133 #endif // EVENTLISTMODEL_H
00134 

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