kalarm

templatelistview.h

00001 /*
00002  *  templatelistview.h  -  widget showing list of alarm templates
00003  *  Program:  kalarm
00004  *  Copyright (C) 2004, 2005 by David Jarvie <software@astrojar.org.uk>
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 TEMPLATELISTVIEW_H
00022 #define TEMPLATELISTVIEW_H
00023 
00024 #include "kalarm.h"
00025 
00026 #include <qmap.h>
00027 #include <klistview.h>
00028 
00029 #include "eventlistviewbase.h"
00030 
00031 class TemplateListView;
00032 
00033 
00034 class TemplateListViewItem : public EventListViewItemBase
00035 {
00036     public:
00037         TemplateListViewItem(TemplateListView* parent, const KAEvent&);
00038         TemplateListView*      templateListView() const  { return (TemplateListView*)listView(); }
00039         // Overridden base class methods
00040         TemplateListViewItem*  nextSibling() const       { return (TemplateListViewItem*)QListViewItem::nextSibling(); }
00041         virtual QString        key(int column, bool ascending) const;
00042     protected:
00043         virtual QString        lastColumnText() const;
00044     private:
00045         QString                mIconOrder;        // controls ordering of icon column
00046 };
00047 
00048 
00049 class TemplateListView : public EventListViewBase
00050 {
00051         Q_OBJECT
00052     public:
00053         explicit TemplateListView(bool includeCmdAlarms, const QString& whatsThisText, QWidget* parent = 0, const char* name = 0);
00054         ~TemplateListView();
00055         int                    iconColumn() const     { return mIconColumn; }
00056         int                    nameColumn() const     { return mNameColumn; }
00057         // Overridden base class methods
00058         static void            addEvent(const KAEvent& e, EventListViewBase* v)
00059                                      { EventListViewBase::addEvent(e, mInstanceList, v); }
00060         static void            modifyEvent(const KAEvent& e, EventListViewBase* v)
00061                                      { EventListViewBase::modifyEvent(e.id(), e, mInstanceList, v); }
00062         static void            modifyEvent(const QString& oldEventID, const KAEvent& newEvent, EventListViewBase* v)
00063                                      { EventListViewBase::modifyEvent(oldEventID, newEvent, mInstanceList, v); }
00064         static void            deleteEvent(const QString& eventID)
00065                                      { EventListViewBase::deleteEvent(eventID, mInstanceList); }
00066         TemplateListViewItem*  getEntry(const QString& eventID)  { return (TemplateListViewItem*)EventListViewBase::getEntry(eventID); }
00067         TemplateListViewItem*  selectedItem() const   { return (TemplateListViewItem*)EventListViewBase::selectedItem(); }
00068         TemplateListViewItem*  currentItem() const    { return (TemplateListViewItem*)EventListViewBase::currentItem(); }
00069         TemplateListViewItem*  firstChild() const     { return (TemplateListViewItem*)EventListViewBase::firstChild(); }
00070         virtual void           setSelected(QListViewItem* item, bool selected)         { EventListViewBase::setSelected(item, selected); }
00071         virtual void           setSelected(TemplateListViewItem* item, bool selected)  { EventListViewBase::setSelected(item, selected); }
00072         virtual QValueList<EventListViewBase*> instances()   { return mInstanceList; }
00073 
00074     protected:
00075         virtual void           populate();
00076         EventListViewItemBase* createItem(const KAEvent&);
00077         virtual QString        whatsThisText(int column) const;
00078 
00079     private:
00080         static QValueList<EventListViewBase*> mInstanceList;
00081         QString                mWhatsThisText;    // default QWhatsThis text
00082         int                    mIconColumn;       // index to icon column
00083         int                    mNameColumn;       // index to template name column
00084         bool                   mExcludeCmdAlarms; // omit command alarms from the list
00085 };
00086 
00087 #endif // TEMPLATELISTVIEW_H
00088 
KDE Home | KDE Accessibility Home | Description of Access Keys