kalarm

functions.h
Go to the documentation of this file.
1/*
2 * functions.h - miscellaneous functions
3 * Program: kalarm
4 * Copyright © 2004-2006,2009 by David Jarvie <djarvie@kde.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef FUNCTIONS_H
22#define FUNCTIONS_H
23
26#include <tqsize.h>
27#include <tqstring.h>
28
29#include "alarmevent.h"
30
31class TQObject;
32class TQWidget;
33class TQString;
34class TDEAction;
35class TDEActionCollection;
36namespace KCal { class Event; }
37class KAEvent;
38class MainWindow;
39class AlarmListView;
40class TemplateListView;
41class TemplateMenuAction;
42
43namespace KAlarm
44{
45
47enum FileType { Unknown, TextPlain, TextFormatted, TextApplication, Image };
52 UPDATE_OK, // update succeeded
53 UPDATE_KORG_ERR, // update succeeded, but KOrganizer update failed
54 UPDATE_ERROR, // update failed partially
55 UPDATE_FAILED, // update failed completely
56 SAVE_FAILED // calendar was updated in memory, but save failed
57};
59enum UpdateError { ERR_ADD, ERR_DELETE, ERR_REACTIVATE, ERR_TEMPLATE };
61enum KOrgUpdateError { KORG_ERR_ADD, KORG_ERR_MODIFY, KORG_ERR_DELETE };
62
63
65MainWindow* displayMainWindowSelected(const TQString& eventID = TQString());
66bool readConfigWindowSize(const char* window, TQSize&);
67void writeConfigWindowSize(const char* window, const TQSize&);
71FileType fileType(const TQString& mimetype);
73int Version();
74inline int Version(int major, int minor, int rev) { return major*10000 + minor*100 + rev; }
75int getVersionNumber(const TQString& version, TQString* subVersion = 0);
77inline int currentCalendarVersion() { return KAEvent::calVersion(); }
78inline TQString currentCalendarVersionString() { return KAEvent::calVersionString(); }
79TQString browseFile(const TQString& caption, TQString& defaultDir, const TQString& initialFile = TQString(),
80 const TQString& filter = TQString(), int mode = 0, TQWidget* parent = 0, const char* name = 0);
81bool edit(const TQString& eventID);
82bool editNew(const TQString& templateName = TQString());
84TDEAction* createNewAlarmAction(const TQString& label, TQObject* receiver, const char* slot, TDEActionCollection*, const char* name);
86TemplateMenuAction* createNewFromTemplateAction(const TQString& label, TQObject* receiver, const char* slot, TDEActionCollection*, const char* name);
90TQValueList<KAEvent> templateList();
91void outputAlarmWarnings(TQWidget* parent, const KAEvent* = 0);
92void resetDaemon();
93void resetDaemonIfQueued(); // must only be called from KAlarmApp::processQueue()
94TQString runKMail(bool minimise);
95bool runProgram(const TQCString& program, const TQCString& windowName, TQCString& dcopName, TQString& errorMessage);
96
97UpdateStatus addEvent(KAEvent&, AlarmListView* selectionView, TQWidget* errmsgParent = 0, bool useEventID = false, bool allowKOrgUpdate = true);
98bool addExpiredEvent(KAEvent&);
99UpdateStatus addTemplate(KAEvent&, TemplateListView* selectionView, TQWidget* errmsgParent = 0);
100UpdateStatus modifyEvent(KAEvent& oldEvent, const KAEvent& newEvent, AlarmListView* selectionView, TQWidget* errmsgParent = 0);
101UpdateStatus updateEvent(KAEvent&, AlarmListView* selectionView, TQWidget* errmsgParent = 0, bool archiveOnDelete = true, bool incRevision = true);
102UpdateStatus updateTemplate(const KAEvent&, TemplateListView* selectionView, TQWidget* errmsgParent = 0);
103UpdateStatus deleteEvent(KAEvent&, bool archive = true, TQWidget* errmsgParent = 0);
104UpdateStatus deleteTemplate(const KAEvent&);
105void deleteDisplayEvent(const TQString& eventID);
106UpdateStatus reactivateEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false);
107UpdateStatus enableEvent(KAEvent&, AlarmListView* selectionView, bool enable);
108void displayUpdateError(TQWidget* parent, UpdateStatus, UpdateError, int nAlarms);
109void displayKOrgUpdateError(TQWidget* parent, KOrgUpdateError, int nAlarms);
110
111TQString stripAccel(const TQString&);
112
113int localeFirstDayOfWeek();
114
115/* Given a standard KDE day number, return the day number in the week for the user's locale.
116 * Standard day number = 1 (Mon) .. 7 (Sun)
117 * Locale day number in week = 0 .. 6
118 */
119inline int weekDay_to_localeDayInWeek(int weekDay) { return (weekDay + 7 - localeFirstDayOfWeek()) % 7; }
120
121/* Given a day number in the week for the user's locale, return the standard KDE day number.
122 * 'index' = 0 .. 6
123 * Standard day number = 1 (Mon) .. 7 (Sun)
124 */
125inline int localeDayInWeek_to_weekDay(int index) { return (index + localeFirstDayOfWeek() - 1) % 7 + 1; }
126
127} // namespace KAlarm
128
129#endif // FUNCTIONS_H
represents calendar alarms and events
KAEvent corresponds to a KCal::Event instance.
Definition: alarmevent.h:232
KOrgUpdateError
Error codes supplied as parameter to displayKOrgUpdateError()
Definition: functions.h:61
int currentCalendarVersion()
Return which version of KAlarm was the first to use the current calendar/event format.
Definition: functions.h:77
UpdateStatus
Return codes from calendar update functions.
Definition: functions.h:51
UpdateError
Error codes supplied as parameter to displayUpdateError()
Definition: functions.h:59
FileType
Return codes from fileType()
Definition: functions.h:47