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 };
00049 enum UpdateStatus {
00050     UPDATE_OK,          // update succeeded
00051     UPDATE_ERROR,       // update failed completely
00052     UPDATE_KORG_ERR     // update succeeded, but KOrganizer update failed
00053 };
00055 enum UpdateError { KORG_ERR_ADD, KORG_ERR_MODIFY, KORG_ERR_DELETE };
00056 
00057 
00059 MainWindow*         displayMainWindowSelected(const QString& eventID = QString::null);
00060 bool                readConfigWindowSize(const char* window, QSize&);
00061 void                writeConfigWindowSize(const char* window, const QSize&);
00065 FileType            fileType(const QString& mimetype);
00067 int                 Version();
00068 inline int          Version(int major, int minor, int rev)     { return major*10000 + minor*100 + rev; }
00069 int                 getVersionNumber(const QString& version, QString* subVersion = 0);
00071 inline int          currentCalendarVersion()        { return KAEvent::calVersion(); }
00072 inline QString      currentCalendarVersionString()  { return KAEvent::calVersionString(); }
00073 QString             browseFile(const QString& caption, QString& defaultDir, const QString& initialFile = QString::null,
00074                                const QString& filter = QString::null, int mode = 0, QWidget* parent = 0, const char* name = 0);
00075 bool                edit(const QString& eventID);
00076 bool                editNew(const QString& templateName = QString::null);
00078 KAction*            createNewAlarmAction(const QString& label, QObject* receiver, const char* slot, KActionCollection*, const char* name);
00080 TemplateMenuAction* createNewFromTemplateAction(const QString& label, QObject* receiver, const char* slot, KActionCollection*, const char* name);
00084 QValueList<KAEvent> templateList();
00085 void                outputAlarmWarnings(QWidget* parent, const KAEvent* = 0);
00086 void                resetDaemon();
00087 void                resetDaemonIfQueued();    // must only be called from KAlarmApp::processQueue()
00088 QString             runKMail(bool minimise);
00089 bool                runProgram(const QCString& program, const QCString& windowName, QCString& dcopName, QString& errorMessage);
00090 
00091 UpdateStatus        addEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false, bool allowKOrgUpdate = true);
00092 bool                addExpiredEvent(KAEvent&);
00093 bool                addTemplate(KAEvent&, TemplateListView* selectionView);
00094 UpdateStatus        modifyEvent(KAEvent& oldEvent, const KAEvent& newEvent, AlarmListView* selectionView);
00095 void                updateEvent(KAEvent&, AlarmListView* selectionView, bool archiveOnDelete = true, bool incRevision = true);
00096 void                updateTemplate(const KAEvent&, TemplateListView* selectionView);
00097 UpdateStatus        deleteEvent(KAEvent&, bool archive = true);
00098 void                deleteTemplate(const KAEvent&);
00099 void                deleteDisplayEvent(const QString& eventID);
00100 UpdateStatus        reactivateEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false);
00101 void                enableEvent(KAEvent&, AlarmListView* selectionView, bool enable);
00102 void                displayKOrgUpdateError(QWidget* parent, UpdateError, int nAlarms);
00103 
00104 QString             stripAccel(const QString&);
00105 
00106 int                 localeFirstDayOfWeek();
00107 
00108 /* Given a standard KDE day number, return the day number in the week for the user's locale.
00109  * Standard day number = 1 (Mon) .. 7 (Sun)
00110  * Locale day number in week = 0 .. 6
00111  */
00112 inline int          weekDay_to_localeDayInWeek(int weekDay)  { return (weekDay + 7 - localeFirstDayOfWeek()) % 7; }
00113 
00114 /* Given a day number in the week for the user's locale, return the standard KDE day number.
00115  * 'index' = 0 .. 6
00116  * Standard day number = 1 (Mon) .. 7 (Sun)
00117  */
00118 inline int          localeDayInWeek_to_weekDay(int index)  { return (index + localeFirstDayOfWeek() - 1) % 7 + 1; }
00119 
00120 } // namespace KAlarm
00121 
00122 #endif // FUNCTIONS_H
KDE Home | KDE Accessibility Home | Description of Access Keys