23 #include <tdelocale.h>
26 #include "alarmcalendar.h"
28 #include "templatelistview.moc"
35 TQValueList<EventListViewBase*> TemplateListView::mInstanceList;
38 TemplateListView::TemplateListView(
bool includeCmdAlarms,
const TQString& whatsThisText, TQWidget* parent,
const char* name)
39 : EventListViewBase(parent, name),
40 mWhatsThisText(whatsThisText),
43 mExcludeCmdAlarms(!includeCmdAlarms)
45 addColumn(TQString());
46 addLastColumn(i18n(
"Name"));
47 setSorting(mNameColumn);
48 setColumnAlignment(mIconColumn, TQt::AlignHCenter);
49 setColumnWidthMode(mIconColumn, TQListView::Maximum);
51 mInstanceList.append(
this);
54 TemplateListView::~TemplateListView()
56 mInstanceList.remove(
this);
62 void TemplateListView::populate()
64 TQValueList<KAEvent> templates = KAlarm::templateList();
65 for (TQValueList<KAEvent>::Iterator it = templates.begin(); it != templates.end(); ++it)
72 EventListViewItemBase* TemplateListView::createItem(
const KAEvent& event)
74 return new TemplateListViewItem(
this, event);
80 TQString TemplateListView::whatsThisText(
int column)
const
82 if (column == mIconColumn)
83 return i18n(
"Alarm type");
84 if (column == mNameColumn)
85 return i18n(
"Name of the alarm template");
86 return mWhatsThisText;
95 TemplateListViewItem::TemplateListViewItem(TemplateListView* parent,
const KAEvent& event)
96 : EventListViewItemBase(parent, event)
101 switch (event.action())
103 case KAAlarm::FILE: index = 2;
break;
104 case KAAlarm::COMMAND: index = 3;
break;
105 case KAAlarm::EMAIL: index = 4;
break;
106 case KAAlarm::MESSAGE:
107 default: index = 1;
break;
109 mIconOrder.sprintf(
"%01u", index);
110 setPixmap(templateListView()->iconColumn(), *eventIcon());
116 TQString TemplateListViewItem::lastColumnText()
const
118 return event().templateName();
124 TQString TemplateListViewItem::key(
int column,
bool)
const
126 TemplateListView* listView = templateListView();
127 if (column == listView->iconColumn())
129 return text(column).lower();
KAEvent corresponds to a KCal::Event instance.