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 
31 class TQObject;
32 class TQWidget;
33 class TQString;
34 class TDEAction;
35 class TDEActionCollection;
36 namespace KCal { class Event; }
37 class KAEvent;
38 class MainWindow;
39 class AlarmListView;
40 class TemplateListView;
41 class TemplateMenuAction;
42 
43 namespace KAlarm
44 {
45 
47 enum 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 };
59 enum UpdateError { ERR_ADD, ERR_DELETE, ERR_REACTIVATE, ERR_TEMPLATE };
61 enum KOrgUpdateError { KORG_ERR_ADD, KORG_ERR_MODIFY, KORG_ERR_DELETE };
62 
63 
65 MainWindow* displayMainWindowSelected(const TQString& eventID = TQString());
66 bool readConfigWindowSize(const char* window, TQSize&);
67 void writeConfigWindowSize(const char* window, const TQSize&);
71 FileType fileType(const TQString& mimetype);
73 int Version();
74 inline int Version(int major, int minor, int rev) { return major*10000 + minor*100 + rev; }
75 int getVersionNumber(const TQString& version, TQString* subVersion = 0);
77 inline int currentCalendarVersion() { return KAEvent::calVersion(); }
78 inline TQString currentCalendarVersionString() { return KAEvent::calVersionString(); }
79 TQString 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);
81 bool edit(const TQString& eventID);
82 bool editNew(const TQString& templateName = TQString());
84 TDEAction* createNewAlarmAction(const TQString& label, TQObject* receiver, const char* slot, TDEActionCollection*, const char* name);
86 TemplateMenuAction* createNewFromTemplateAction(const TQString& label, TQObject* receiver, const char* slot, TDEActionCollection*, const char* name);
90 TQValueList<KAEvent> templateList();
91 void outputAlarmWarnings(TQWidget* parent, const KAEvent* = 0);
92 void resetDaemon();
93 void resetDaemonIfQueued(); // must only be called from KAlarmApp::processQueue()
94 TQString runKMail(bool minimise);
95 bool runProgram(const TQCString& program, const TQCString& windowName, TQCString& dcopName, TQString& errorMessage);
96 
97 UpdateStatus addEvent(KAEvent&, AlarmListView* selectionView, TQWidget* errmsgParent = 0, bool useEventID = false, bool allowKOrgUpdate = true);
98 bool addExpiredEvent(KAEvent&);
99 UpdateStatus addTemplate(KAEvent&, TemplateListView* selectionView, TQWidget* errmsgParent = 0);
100 UpdateStatus modifyEvent(KAEvent& oldEvent, const KAEvent& newEvent, AlarmListView* selectionView, TQWidget* errmsgParent = 0);
101 UpdateStatus updateEvent(KAEvent&, AlarmListView* selectionView, TQWidget* errmsgParent = 0, bool archiveOnDelete = true, bool incRevision = true);
102 UpdateStatus updateTemplate(const KAEvent&, TemplateListView* selectionView, TQWidget* errmsgParent = 0);
103 UpdateStatus deleteEvent(KAEvent&, bool archive = true, TQWidget* errmsgParent = 0);
104 UpdateStatus deleteTemplate(const KAEvent&);
105 void deleteDisplayEvent(const TQString& eventID);
106 UpdateStatus reactivateEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false);
107 UpdateStatus enableEvent(KAEvent&, AlarmListView* selectionView, bool enable);
108 void displayUpdateError(TQWidget* parent, UpdateStatus, UpdateError, int nAlarms);
109 void displayKOrgUpdateError(TQWidget* parent, KOrgUpdateError, int nAlarms);
110 
111 TQString stripAccel(const TQString&);
112 
113 int 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  */
119 inline 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  */
125 inline 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