kalarm

functions.h

Go to the documentation of this file.
00001 /*
00002  *  functions.h  -  miscellaneous functions
00003  *  Program:  kalarm
00004  *  Copyright © 2004-2006 by David Jarvie <software@astrojar.org.uk>
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 <qsize.h>
00027 #include <qstring.h>
00028 
00029 #include "alarmevent.h"
00030 
00031 class QObject;
00032 class QWidget;
00033 class QString;
00034 class KAction;
00035 class KActionCollection;
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 QString& eventID = QString::null);
00066 bool                readConfigWindowSize(const char* window, QSize&);
00067 void                writeConfigWindowSize(const char* window, const QSize&);
00071 FileType            fileType(const QString& mimetype);
00073 int                 Version();
00074 inline int          Version(int major, int minor, int rev)     { return major*10000 + minor*100 + rev; }
00075 int                 getVersionNumber(const QString& version, QString* subVersion = 0);
00077 inline int          currentCalendarVersion()        { return KAEvent::calVersion(); }
00078 inline QString      currentCalendarVersionString()  { return KAEvent::calVersionString(); }
00079 QString             browseFile(const QString& caption, QString& defaultDir, const QString& initialFile = QString::null,
00080                                const QString& filter = QString::null, int mode = 0, QWidget* parent = 0, const char* name = 0);
00081 bool                edit(const QString& eventID);
00082 bool                editNew(const QString& templateName = QString::null);
00084 KAction*            createNewAlarmAction(const QString& label, QObject* receiver, const char* slot, KActionCollection*, const char* name);
00086 TemplateMenuAction* createNewFromTemplateAction(const QString& label, QObject* receiver, const char* slot, KActionCollection*, const char* name);
00090 QValueList<KAEvent> templateList();
00091 void                outputAlarmWarnings(QWidget* parent, const KAEvent* = 0);
00092 void                resetDaemon();
00093 void                resetDaemonIfQueued();    // must only be called from KAlarmApp::processQueue()
00094 QString             runKMail(bool minimise);
00095 bool                runProgram(const QCString& program, const QCString& windowName, QCString& dcopName, QString& errorMessage);
00096 
00097 UpdateStatus        addEvent(KAEvent&, AlarmListView* selectionView, QWidget* errmsgParent = 0, bool useEventID = false, bool allowKOrgUpdate = true);
00098 bool                addExpiredEvent(KAEvent&);
00099 UpdateStatus        addTemplate(KAEvent&, TemplateListView* selectionView, QWidget* errmsgParent = 0);
00100 UpdateStatus        modifyEvent(KAEvent& oldEvent, const KAEvent& newEvent, AlarmListView* selectionView, QWidget* errmsgParent = 0);
00101 UpdateStatus        updateEvent(KAEvent&, AlarmListView* selectionView, QWidget* errmsgParent = 0, bool archiveOnDelete = true, bool incRevision = true);
00102 UpdateStatus        updateTemplate(const KAEvent&, TemplateListView* selectionView, QWidget* errmsgParent = 0);
00103 UpdateStatus        deleteEvent(KAEvent&, bool archive = true, QWidget* errmsgParent = 0);
00104 UpdateStatus        deleteTemplate(const KAEvent&);
00105 void                deleteDisplayEvent(const QString& eventID);
00106 UpdateStatus        reactivateEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false);
00107 UpdateStatus        enableEvent(KAEvent&, AlarmListView* selectionView, bool enable);
00108 void                displayUpdateError(QWidget* parent, UpdateStatus, UpdateError, int nAlarms);
00109 void                displayKOrgUpdateError(QWidget* parent, KOrgUpdateError, int nAlarms);
00110 
00111 QString             stripAccel(const QString&);
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
KDE Home | KDE Accessibility Home | Description of Access Keys