kalarm

functions.h

Go to the documentation of this file.
00001 /*
00002  *  functions.h  -  miscellaneous functions
00003  *  Program:  kalarm
00004  *  Copyright (C) 2004, 2005 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 <qptrlist.h>
00028 #include <qstring.h>
00029 
00030 #include "alarmevent.h"
00031 
00032 class QObject;
00033 class QWidget;
00034 class QString;
00035 class KAction;
00036 class KActionCollection;
00037 namespace KCal { class Event; }
00038 class KAEvent;
00039 class MainWindow;
00040 class AlarmListView;
00041 class TemplateListView;
00042 class TemplateMenuAction;
00043 
00044 namespace KAlarm
00045 {
00046 
00048 enum FileType { Unknown, TextPlain, TextFormatted, TextApplication, Image };
00050 enum UpdateStatus {
00051     UPDATE_OK,          // update succeeded
00052     UPDATE_ERROR,       // update failed completely
00053     UPDATE_KORG_ERR     // update succeeded, but KOrganizer update failed
00054 };
00056 enum UpdateError { KORG_ERR_ADD, KORG_ERR_MODIFY, KORG_ERR_DELETE };
00057 
00058 
00060 MainWindow*         displayMainWindowSelected(const QString& eventID = QString::null);
00061 bool                readConfigWindowSize(const char* window, QSize&);
00062 void                writeConfigWindowSize(const char* window, const QSize&);
00066 FileType            fileType(const QString& mimetype);
00067 inline int          Version(int major, int minor, int rev)     { return major*10000 + minor*100 + rev; }
00068 int                 getVersionNumber(const QString& version, QString* subVersion = 0);
00069 QString             browseFile(const QString& caption, QString& defaultDir, const QString& initialFile = QString::null,
00070                                const QString& filter = QString::null, int mode = 0, QWidget* parent = 0, const char* name = 0);
00072 KAction*            createNewAlarmAction(const QString& label, QObject* receiver, const char* slot, KActionCollection*, const char* name);
00074 TemplateMenuAction* createNewFromTemplateAction(const QString& label, QObject* receiver, const char* slot, KActionCollection*, const char* name);
00078 QValueList<KAEvent> templateList();
00079 void                outputAlarmWarnings(QWidget* parent, const KAEvent* = 0);
00080 void                resetDaemon();
00081 void                resetDaemonIfQueued();    // must only be called from KAlarmApp::processQueue()
00082 QString             runKMail(bool minimise);
00083 bool                runProgram(const QCString& program, const QCString& windowName, QCString& dcopName, QString& errorMessage);
00084 
00085 UpdateStatus        addEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false, bool allowKOrgUpdate = true);
00086 bool                addExpiredEvent(KAEvent&);
00087 bool                addTemplate(KAEvent&, TemplateListView* selectionView);
00088 UpdateStatus        modifyEvent(KAEvent& oldEvent, const KAEvent& newEvent, AlarmListView* selectionView);
00089 void                updateEvent(KAEvent&, AlarmListView* selectionView, bool archiveOnDelete = true, bool incRevision = true);
00090 void                updateTemplate(const KAEvent&, TemplateListView* selectionView);
00091 UpdateStatus        deleteEvent(KAEvent&, bool archive = true);
00092 void                deleteTemplate(const KAEvent&);
00093 void                deleteDisplayEvent(const QString& eventID);
00094 UpdateStatus        reactivateEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false);
00095 void                enableEvent(KAEvent&, AlarmListView* selectionView, bool enable);
00096 void                displayUpdateError(QWidget* parent, UpdateError, bool multipleAlarms = false);
00097 
00098 QString             stripAccel(const QString&);
00099 
00100 int                 localeFirstDayOfWeek();
00101 
00102 /* Given a standard KDE day number, return the day number in the week for the user's locale.
00103  * Standard day number = 1 (Mon) .. 7 (Sun)
00104  * Locale day number in week = 0 .. 6
00105  */
00106 inline int          weekDay_to_localeDayInWeek(int weekDay)  { return (weekDay + 7 - localeFirstDayOfWeek()) % 7; }
00107 
00108 /* Given a day number in the week for the user's locale, return the standard KDE day number.
00109  * 'index' = 0 .. 6
00110  * Standard day number = 1 (Mon) .. 7 (Sun)
00111  */
00112 inline int          localeDayInWeek_to_weekDay(int index)  { return (index + localeFirstDayOfWeek() - 1) % 7 + 1; }
00113 
00114 } // namespace KAlarm
00115 
00116 #endif // FUNCTIONS_H
KDE Home | KDE Accessibility Home | Description of Access Keys