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);
00066 inline int          Version(int major, int minor, int rev)     { return major*10000 + minor*100 + rev; }
00067 int                 getVersionNumber(const QString& version, QString* subVersion = 0);
00068 QString             browseFile(const QString& caption, QString& defaultDir, const QString& initialFile = QString::null,
00069                                const QString& filter = QString::null, int mode = 0, QWidget* parent = 0, const char* name = 0);
00070 bool                edit(const QString& eventID);
00071 bool                editNew(const QString& templateName = QString::null);
00073 KAction*            createNewAlarmAction(const QString& label, QObject* receiver, const char* slot, KActionCollection*, const char* name);
00075 TemplateMenuAction* createNewFromTemplateAction(const QString& label, QObject* receiver, const char* slot, KActionCollection*, const char* name);
00079 QValueList<KAEvent> templateList();
00080 void                outputAlarmWarnings(QWidget* parent, const KAEvent* = 0);
00081 void                resetDaemon();
00082 void                resetDaemonIfQueued();    // must only be called from KAlarmApp::processQueue()
00083 QString             runKMail(bool minimise);
00084 bool                runProgram(const QCString& program, const QCString& windowName, QCString& dcopName, QString& errorMessage);
00085 
00086 UpdateStatus        addEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false, bool allowKOrgUpdate = true);
00087 bool                addExpiredEvent(KAEvent&);
00088 bool                addTemplate(KAEvent&, TemplateListView* selectionView);
00089 UpdateStatus        modifyEvent(KAEvent& oldEvent, const KAEvent& newEvent, AlarmListView* selectionView);
00090 void                updateEvent(KAEvent&, AlarmListView* selectionView, bool archiveOnDelete = true, bool incRevision = true);
00091 void                updateTemplate(const KAEvent&, TemplateListView* selectionView);
00092 UpdateStatus        deleteEvent(KAEvent&, bool archive = true);
00093 void                deleteTemplate(const KAEvent&);
00094 void                deleteDisplayEvent(const QString& eventID);
00095 UpdateStatus        reactivateEvent(KAEvent&, AlarmListView* selectionView, bool useEventID = false);
00096 void                enableEvent(KAEvent&, AlarmListView* selectionView, bool enable);
00097 void                displayKOrgUpdateError(QWidget* parent, UpdateError, int nAlarms);
00098 
00099 QString             stripAccel(const QString&);
00100 
00101 int                 localeFirstDayOfWeek();
00102 
00103 /* Given a standard KDE day number, return the day number in the week for the user's locale.
00104  * Standard day number = 1 (Mon) .. 7 (Sun)
00105  * Locale day number in week = 0 .. 6
00106  */
00107 inline int          weekDay_to_localeDayInWeek(int weekDay)  { return (weekDay + 7 - localeFirstDayOfWeek()) % 7; }
00108 
00109 /* Given a day number in the week for the user's locale, return the standard KDE day number.
00110  * 'index' = 0 .. 6
00111  * Standard day number = 1 (Mon) .. 7 (Sun)
00112  */
00113 inline int          localeDayInWeek_to_weekDay(int index)  { return (index + localeFirstDayOfWeek() - 1) % 7 + 1; }
00114 
00115 } // namespace KAlarm
00116 
00117 #endif // FUNCTIONS_H
KDE Home | KDE Accessibility Home | Description of Access Keys