functions.h
Go to the documentation of this file.
00001 /* 00002 * functions.h - miscellaneous functions 00003 * Program: kalarm 00004 * Copyright © 2004-2006,2009 by David Jarvie <djarvie@kde.org> 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 FUNCTIONS_H 00022 #define FUNCTIONS_H 00023 00026 #include <tqsize.h> 00027 #include <tqstring.h> 00028 00029 #include "alarmevent.h" 00030 00031 class TQObject; 00032 class TQWidget; 00033 class TQString; 00034 class TDEAction; 00035 class TDEActionCollection; 00036 namespace KCal { class Event; } 00037 class KAEvent; 00038 class MainWindow; 00039 class AlarmListView; 00040 class TemplateListView; 00041 class TemplateMenuAction; 00042 00043 namespace KAlarm 00044 { 00045 00047 enum FileType { Unknown, TextPlain, TextFormatted, TextApplication, Image }; 00051 enum UpdateStatus { 00052 UPDATE_OK, // update succeeded 00053 UPDATE_KORG_ERR, // update succeeded, but KOrganizer update failed 00054 UPDATE_ERROR, // update failed partially 00055 UPDATE_FAILED, // update failed completely 00056 SAVE_FAILED // calendar was updated in memory, but save failed 00057 }; 00059 enum UpdateError { ERR_ADD, ERR_DELETE, ERR_REACTIVATE, ERR_TEMPLATE }; 00061 enum KOrgUpdateError { KORG_ERR_ADD, KORG_ERR_MODIFY, KORG_ERR_DELETE }; 00062 00063 00065 MainWindow* displayMainWindowSelected(const TQString& eventID = TQString()); 00066 bool readConfigWindowSize(const char* window, TQSize&); 00067 void writeConfigWindowSize(const char* window, const TQSize&); 00071 FileType fileType(const TQString& mimetype); 00073 int Version(); 00074 inline int Version(int major, int minor, int rev) { return major*10000 + minor*100 + rev; } 00075 int getVersionNumber(const TQString& version, TQString* subVersion = 0); 00077 inline int currentCalendarVersion() { return KAEvent::calVersion(); } 00078 inline TQString currentCalendarVersionString() { return KAEvent::calVersionString(); } 00079 TQString browseFile(const TQString& caption, TQString& defaultDir, const TQString& initialFile = TQString(), 00080 const TQString& filter = TQString(), int mode = 0, TQWidget* parent = 0, const char* name = 0); 00081 bool edit(const TQString& eventID); 00082 bool editNew(const TQString& templateName = TQString()); 00084 TDEAction* createNewAlarmAction(const TQString& label, TQObject* receiver, const char* slot, TDEActionCollection*, const char* name); 00086 TemplateMenuAction* createNewFromTemplateAction(const TQString& label, TQObject* receiver, const char* slot, TDEActionCollection*, const char* name); 00090 TQValueList<KAEvent> templateList(); 00091 void outputAlarmWarnings(TQWidget* parent, const KAEvent* = 0); 00092 void resetDaemon(); 00093 void resetDaemonIfQueued(); // must only be called from KAlarmApp::processQueue() 00094 TQString runKMail(bool minimise); 00095 bool runProgram(const TQCString& program, const TQCString& windowName, TQCString& dcopName, TQString& errorMessage); 00096 00097 UpdateStatus addEvent(KAEvent&, AlarmListView* selectionView, TQWidget* errmsgParent = 0, bool useEventID = false, bool allowKOrgUpdate = true); 00098 bool addExpiredEvent(KAEvent&); 00099 UpdateStatus addTemplate(KAEvent&, TemplateListView* selectionView, TQWidget* errmsgParent = 0); 00100 UpdateStatus modifyEvent(KAEvent& oldEvent, const KAEvent& newEvent, AlarmListView* selectionView, TQWidget* errmsgParent = 0); 00101 UpdateStatus updateEvent(KAEvent&, AlarmListView* selectionView, TQWidget* errmsgParent = 0, bool archiveOnDelete = true, bool incRevision = true); 00102 UpdateStatus updateTemplate(const KAEvent&, TemplateListView* selectionView, TQWidget* errmsgParent = 0); 00103 UpdateStatus deleteEvent(KAEvent&, bool archive = true, TQWidget* errmsgParent = 0); 00104 UpdateStatus deleteTemplate(const KAEvent&); 00105 void deleteDisplayEvent(const TQString& eventID); 00106 UpdateStatus reactivateEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false); 00107 UpdateStatus enableEvent(KAEvent&, AlarmListView* selectionView, bool enable); 00108 void displayUpdateError(TQWidget* parent, UpdateStatus, UpdateError, int nAlarms); 00109 void displayKOrgUpdateError(TQWidget* parent, KOrgUpdateError, int nAlarms); 00110 00111 TQString stripAccel(const TQString&); 00112 00113 int localeFirstDayOfWeek(); 00114 00115 /* Given a standard KDE day number, return the day number in the week for the user's locale. 00116 * Standard day number = 1 (Mon) .. 7 (Sun) 00117 * Locale day number in week = 0 .. 6 00118 */ 00119 inline int weekDay_to_localeDayInWeek(int weekDay) { return (weekDay + 7 - localeFirstDayOfWeek()) % 7; } 00120 00121 /* Given a day number in the week for the user's locale, return the standard KDE day number. 00122 * 'index' = 0 .. 6 00123 * Standard day number = 1 (Mon) .. 7 (Sun) 00124 */ 00125 inline int localeDayInWeek_to_weekDay(int index) { return (index + localeFirstDayOfWeek() - 1) % 7 + 1; } 00126 00127 } // namespace KAlarm 00128 00129 #endif // FUNCTIONS_H