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 <tqmap.h> 00027 #include <tdelistview.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*)TQListViewItem::nextSibling(); } 00041 virtual TQString key(int column, bool ascending) const; 00042 protected: 00043 virtual TQString lastColumnText() const; 00044 private: 00045 TQString mIconOrder; // controls ordering of icon column 00046 }; 00047 00048 00049 class TemplateListView : public EventListViewBase 00050 { 00051 Q_OBJECT 00052 00053 public: 00054 explicit TemplateListView(bool includeCmdAlarms, const TQString& whatsThisText, TQWidget* parent = 0, const char* name = 0); 00055 ~TemplateListView(); 00056 int iconColumn() const { return mIconColumn; } 00057 int nameColumn() const { return mNameColumn; } 00058 // Overridden base class methods 00059 static void addEvent(const KAEvent& e, EventListViewBase* v) 00060 { EventListViewBase::addEvent(e, mInstanceList, v); } 00061 static void modifyEvent(const KAEvent& e, EventListViewBase* v) 00062 { EventListViewBase::modifyEvent(e.id(), e, mInstanceList, v); } 00063 static void modifyEvent(const TQString& oldEventID, const KAEvent& newEvent, EventListViewBase* v) 00064 { EventListViewBase::modifyEvent(oldEventID, newEvent, mInstanceList, v); } 00065 static void deleteEvent(const TQString& eventID) 00066 { EventListViewBase::deleteEvent(eventID, mInstanceList); } 00067 TemplateListViewItem* getEntry(const TQString& eventID) { return (TemplateListViewItem*)EventListViewBase::getEntry(eventID); } 00068 TemplateListViewItem* selectedItem() const { return (TemplateListViewItem*)EventListViewBase::selectedItem(); } 00069 TemplateListViewItem* currentItem() const { return (TemplateListViewItem*)EventListViewBase::currentItem(); } 00070 TemplateListViewItem* firstChild() const { return (TemplateListViewItem*)EventListViewBase::firstChild(); } 00071 virtual void setSelected(TQListViewItem* item, bool selected) { EventListViewBase::setSelected(item, selected); } 00072 virtual void setSelected(TemplateListViewItem* item, bool selected) { EventListViewBase::setSelected(item, selected); } 00073 virtual TQValueList<EventListViewBase*> instances() { return mInstanceList; } 00074 00075 protected: 00076 virtual void populate(); 00077 EventListViewItemBase* createItem(const KAEvent&); 00078 virtual TQString whatsThisText(int column) const; 00079 00080 private: 00081 static TQValueList<EventListViewBase*> mInstanceList; 00082 TQString mWhatsThisText; // default TQWhatsThis text 00083 int mIconColumn; // index to icon column 00084 int mNameColumn; // index to template name column 00085 bool mExcludeCmdAlarms; // omit command alarms from the list 00086 }; 00087 00088 #endif // TEMPLATELISTVIEW_H 00089