summaryrefslogtreecommitdiffstats
path: root/kalarm/templatelistview.h
blob: 530a073a08d5c056d49a557c9a50ff200d0fa48f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 *  templatelistview.h  -  widget showing list of alarm templates
 *  Program:  kalarm
 *  Copyright (C) 2004, 2005 by David Jarvie <[email protected]>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef TEMPLATELISTVIEW_H
#define TEMPLATELISTVIEW_H

#include "kalarm.h"

#include <tqmap.h>
#include <tdelistview.h>

#include "eventlistviewbase.h"

class TemplateListView;


class TemplateListViewItem : public EventListViewItemBase
{
	public:
		TemplateListViewItem(TemplateListView* parent, const KAEvent&);
		TemplateListView*      templateListView() const  { return (TemplateListView*)listView(); }
		// Overridden base class methods
		TemplateListViewItem*  nextSibling() const       { return (TemplateListViewItem*)TQListViewItem::nextSibling(); }
		virtual TQString        key(int column, bool ascending) const;
	protected:
		virtual TQString        lastColumnText() const;
	private:
		TQString                mIconOrder;        // controls ordering of icon column
};


class TemplateListView : public EventListViewBase
{
		Q_OBJECT
  
	public:
		explicit TemplateListView(bool includeCmdAlarms, const TQString& whatsThisText, TQWidget* parent = 0, const char* name = 0);
		~TemplateListView();
		int                    iconColumn() const     { return mIconColumn; }
		int                    nameColumn() const     { return mNameColumn; }
		// Overridden base class methods
		static void            addEvent(const KAEvent& e, EventListViewBase* v)
		                             { EventListViewBase::addEvent(e, mInstanceList, v); }
		static void            modifyEvent(const KAEvent& e, EventListViewBase* v)
		                             { EventListViewBase::modifyEvent(e.id(), e, mInstanceList, v); }
		static void            modifyEvent(const TQString& oldEventID, const KAEvent& newEvent, EventListViewBase* v)
		                             { EventListViewBase::modifyEvent(oldEventID, newEvent, mInstanceList, v); }
		static void            deleteEvent(const TQString& eventID)
		                             { EventListViewBase::deleteEvent(eventID, mInstanceList); }
		TemplateListViewItem*  getEntry(const TQString& eventID)  { return (TemplateListViewItem*)EventListViewBase::getEntry(eventID); }
		TemplateListViewItem*  selectedItem() const   { return (TemplateListViewItem*)EventListViewBase::selectedItem(); }
		TemplateListViewItem*  currentItem() const    { return (TemplateListViewItem*)EventListViewBase::currentItem(); }
		TemplateListViewItem*  firstChild() const     { return (TemplateListViewItem*)EventListViewBase::firstChild(); }
		virtual void           setSelected(TQListViewItem* item, bool selected)         { EventListViewBase::setSelected(item, selected); }
		virtual void           setSelected(TemplateListViewItem* item, bool selected)  { EventListViewBase::setSelected(item, selected); }
		virtual TQValueList<EventListViewBase*> instances()   { return mInstanceList; }

	protected:
		virtual void           populate();
		EventListViewItemBase* createItem(const KAEvent&);
		virtual TQString        whatsThisText(int column) const;

	private:
		static TQValueList<EventListViewBase*> mInstanceList;
		TQString                mWhatsThisText;    // default TQWhatsThis text
		int                    mIconColumn;       // index to icon column
		int                    mNameColumn;       // index to template name column
		bool                   mExcludeCmdAlarms; // omit command alarms from the list
};

#endif // TEMPLATELISTVIEW_H