2 * commandoptions.h - extract command line options
4 * Copyright © 2001-2016 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef COMMANDOPTIONS_H
22 #define COMMANDOPTIONS_H
27 #include <kalarmcal/kaevent.h>
28 #include <kalarmcal/karecurrence.h>
30 #include <kdatetime.h>
33 #include <QStringList>
34 class QCommandLineParser
;
35 class QCommandLineOption
;
37 using namespace KAlarmCal
;
44 CMD_ERROR
, // error in command line options
47 TRIGGER_EVENT
, // --triggerEvent
48 CANCEL_EVENT
, // --cancelEvent
50 EDIT_NEW_PRESET
, // --edit-new-preset
51 EDIT_NEW
, // --edit-new-display, --edit-new-command, --edit-new-email
52 NEW
, // --file, --exec-display, --exec, --mail, message
55 static QStringList
setOptions(QCommandLineParser
*, const QStringList
& args
);
56 static void process();
57 static CommandOptions
* instance() { return mInstance
; }
58 Command
command() const { return mCommand
; }
59 QString
commandName() const { return optionName(mCommandOpt
); }
60 EventId
eventId() const { return mEventId
; }
61 QString
templateName() const { return mTemplateName
; }
62 EditAlarmDlg::Type
editType() const { return mEditType
; }
63 KAEvent::SubAction
editAction() const { return mEditAction
; }
64 QString
text() const { return mText
; }
65 KDateTime
alarmTime() const { return mAlarmTime
; }
66 KARecurrence
* recurrence() const { return mRecurrence
; }
67 int subRepeatCount() const { return mRepeatCount
; }
68 KCalCore::Duration
subRepeatInterval() const { return mRepeatInterval
; }
69 int lateCancel() const { return mLateCancel
; }
70 QColor
bgColour() const { return mBgColour
; }
71 QColor
fgColour() const { return mFgColour
; }
72 int reminderMinutes() const { return mReminderMinutes
; }
73 QString
audioFile() const { return mAudioFile
; }
74 float audioVolume() const { return mAudioVolume
; }
75 KCalCore::Person::List
addressees() const { return mAddressees
; }
76 QStringList
attachments() const { return mAttachments
; }
77 QString
subject() const { return mSubject
; }
78 uint
fromID() const { return mFromID
; }
79 KAEvent::Flags
flags() const { return mFlags
; }
80 bool disableAll() const { return mDisableAll
; }
82 KDateTime
simulationTime() const { return mSimulationTime
; }
84 static void printError(const QString
& errmsg
);
131 Num_Options
, // number of Option values
132 Opt_Message
// special value representing "message"
135 explicit CommandOptions();
136 bool checkCommand(Option
, Command
, EditAlarmDlg::Type
= EditAlarmDlg::NO_TYPE
);
137 inline void setError(const QString
& error
);
138 void setErrorRequires(Option opt
, Option opt2
, Option opt3
= Num_Options
);
139 void setErrorParameter(Option
);
140 void setErrorIncompatible(Option opt1
, Option opt2
);
141 void checkEditType(EditAlarmDlg::Type type
, Option opt
)
142 { checkEditType(type
, EditAlarmDlg::NO_TYPE
, opt
); }
143 void checkEditType(EditAlarmDlg::Type
, EditAlarmDlg::Type
, Option
);
144 static QString
arg(int n
);
145 static QString
optionName(Option
, bool shortName
= false);
147 static CommandOptions
* mInstance
; // the unique instance
148 static QCommandLineParser
* mParser
;
149 static QVector
<QCommandLineOption
*> mOptions
; // all possible command line options
150 static QStringList mExecArguments
; // arguments for --exec or --exec-display
151 QString mError
; // error message
152 Command mCommand
; // the selected command
153 Option mCommandOpt
; // option for the selected command
154 EventId mEventId
; // TRIGGER_EVENT, CANCEL_EVENT, EDIT: event ID
155 QString mTemplateName
; // EDIT_NEW_PRESET: template name
156 EditAlarmDlg::Type mEditType
; // NEW, EDIT_NEW_*: alarm edit type
157 KAEvent::SubAction mEditAction
; // NEW: alarm edit sub-type
158 bool mEditActionSet
; // NEW: mEditAction is valid
159 QString mText
; // NEW: alarm text
160 KDateTime mAlarmTime
; // NEW: alarm time
161 KARecurrence
* mRecurrence
; // NEW: recurrence
162 int mRepeatCount
; // NEW: sub-repetition count
163 KCalCore::Duration mRepeatInterval
; // NEW: sub-repetition interval
164 int mLateCancel
; // NEW: late-cancellation interval
165 QColor mBgColour
; // NEW: background colour
166 QColor mFgColour
; // NEW: foreground colour
167 int mReminderMinutes
;// NEW: reminder period
168 QString mAudioFile
; // NEW: audio file path
169 float mAudioVolume
; // NEW: audio file volume
170 KCalCore::Person::List mAddressees
; // NEW: email addressees
171 QStringList mAttachments
; // NEW: email attachment file names
172 QString mSubject
; // NEW: email subject
173 uint mFromID
; // NEW: email sender ID
174 KAEvent::Flags mFlags
; // NEW: event flags
175 bool mDisableAll
; // disable all alarm monitoring
177 KDateTime mSimulationTime
; // system time to be simulated, or invalid if none
181 #endif // COMMANDOPTIONS_H