[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: Re: [Kde-pim] New feature for KAlarm in KDE 3.5.3
From: David Jarvie <lists () astrojar ! org ! uk>
Date: 2006-04-23 11:35:44
Message-ID: 200604231235.45283.lists () astrojar ! org ! uk
[Download RAW message or body]
On Saturday 22 April 2006 23:20, Allen Winter wrote:
> On Saturday 22 April 2006 18:15, David Jarvie wrote:
> > On Saturday 22 April 2006 22:08, Allen Winter wrote:
> > > On Saturday 22 April 2006 08:20, David Jarvie wrote:
> > > > I want to add a small feature to KAlarm for the next KDE 3.5 branch
> > > > issue. It is to add a DCOP call to display the alarm edit dialogue,
> > > > optionally creating a new alarm or editing an existing one. There are
> > > > also new command line options to access the same functions. This is a
> > > > feature which has been requested for use in a SuperKaramba module.
> > > >
> > > > Below is this feature's compliance with the conditions laid down in
> > > > kde-core-devel. Are there any objections to committing this?
> > >
> > > [snip]
> > >
> > > > > - last and the most important: It must be posted to the mailing
> > > > > list for the SVN module (kde-core-devel for those without) and must
> > > > > be approved by the module's maintainer (TWG for those without)
> > > >
> > > > Here it is.
> > >
> > > ?? where is here?
> >
> > I meant, here is the posting. Or do you mean that you want to see a
> > patch?
>
> I assumed you meant to attach a patch.
Here is the patch.
--
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/linux/kalarm.html
["kalarm.diff" (text/x-diff)]
Index: kalarmiface.h
===================================================================
--- kalarmiface.h (revision 532908)
+++ kalarmiface.h (working copy)
@@ -338,6 +338,18 @@
virtual bool scheduleEmail(const QString& fromID, const QString& addresses, const \
QString& subject, const QString& message,
const QString& attachments, const QString& \
startDateTime, int lateCancel, unsigned flags,
int repeatType, int repeatInterval, const QString& \
endDateTime) = 0; + /** Open the alarm edit dialog to edit an existing alarm.
+ * @param eventId The unique ID of the event to be edited, or QString::null \
to create a new alarm. + * @return false if the alarm could not be found or is \
read-only, true otherwise. + */
+ virtual bool edit(const QString& eventID) = 0;
+ /** Open the alarm edit dialog to edit a new alarm.
+ * @param templateName Name of the alarm template to base the new alarm on, or \
QString::null if none. + * If a template is specified but \
cannot be found, the alarm edit dialog is still + * opened but \
is (obviously) not preset with the template. + * @return false if an alarm template \
was specified but could not be found, true otherwise. + */
+ virtual bool editNew(const QString& templateName) = 0;
};
#endif // KALARMIFACE_H
Index: functions.h
===================================================================
--- functions.h (revision 532908)
+++ functions.h (working copy)
@@ -24,7 +24,6 @@
/** @file functions.h - miscellaneous functions */
#include <qsize.h>
-#include <qptrlist.h>
#include <qstring.h>
#include "alarmevent.h"
@@ -68,6 +67,8 @@
int getVersionNumber(const QString& version, QString* subVersion = \
0); QString browseFile(const QString& caption, QString& defaultDir, \
const QString& initialFile = QString::null,
const QString& filter = QString::null, int mode = 0, \
QWidget* parent = 0, const char* name = 0); +bool edit(const QString& \
eventID); +bool editNew(const QString& templateName = QString::null);
/** Create a "New Alarm" KAction */
KAction* createNewAlarmAction(const QString& label, QObject* receiver, \
const char* slot, KActionCollection*, const char* name); /** Create a "New From \
Template" KAction */
Index: dcophandler.cpp
===================================================================
--- dcophandler.cpp (revision 532908)
+++ dcophandler.cpp (working copy)
@@ -27,10 +27,13 @@
#include <libkpimidentities/identitymanager.h>
#include <libkpimidentities/identity.h>
+#include "alarmcalendar.h"
#include "daemon.h"
+#include "functions.h"
#include "kalarmapp.h"
#include "kamail.h"
#include "karecurrence.h"
+#include "mainwindow.h"
#include "preferences.h"
#include "dcophandler.moc"
@@ -194,7 +197,17 @@
return scheduleEmail(fromID, addresses, subject, message, attachments, start, \
lateCancel, flags, recur); }
+bool DcopHandler::edit(const QString& eventID)
+{
+ return KAlarm::edit(eventID);
+}
+bool DcopHandler::editNew(const QString& templateName)
+{
+ return KAlarm::editNew(templateName);
+}
+
+
/******************************************************************************
* Schedule a message alarm, after converting the parameters from strings.
*/
Index: mainwindow.cpp
===================================================================
--- mainwindow.cpp (revision 532908)
+++ mainwindow.cpp (working copy)
@@ -608,27 +608,36 @@
if (item)
{
KAEvent event = item->event();
- EditAlarmDlg editDlg(false, i18n("Edit Alarm"), this, "editDlg", &event);
- if (editDlg.exec() == QDialog::Accepted)
- {
- KAEvent newEvent;
- bool changeDeferral = !editDlg.getEvent(newEvent);
+ executeEdit(event, this);
+ }
+}
- // Update the event in the displays and in the calendar file
- if (changeDeferral)
- {
- // The only change has been to an existing deferral
- KAlarm::updateEvent(newEvent, mListView, true, false); // keep the same event \
ID
- }
- else
- {
- if (KAlarm::modifyEvent(event, newEvent, mListView) == KAlarm::UPDATE_KORG_ERR)
- KAlarm::displayKOrgUpdateError(this, KAlarm::KORG_ERR_MODIFY, 1);
- }
- Undo::saveEdit(event, newEvent);
+/******************************************************************************
+* Open the Edit Alarm dialogue to edit the specified alarm.
+*/
+void MainWindow::executeEdit(KAEvent& event, MainWindow* win)
+{
+ EditAlarmDlg editDlg(false, i18n("Edit Alarm"), win, "editDlg", &event);
+ if (editDlg.exec() == QDialog::Accepted)
+ {
+ KAEvent newEvent;
+ bool changeDeferral = !editDlg.getEvent(newEvent);
- KAlarm::outputAlarmWarnings(&editDlg, &newEvent);
+ // Update the event in the displays and in the calendar file
+ AlarmListView* view = win ? win->mListView : 0;
+ if (changeDeferral)
+ {
+ // The only change has been to an existing deferral
+ KAlarm::updateEvent(newEvent, view, true, false); // keep the same event ID
}
+ else
+ {
+ if (KAlarm::modifyEvent(event, newEvent, view) == KAlarm::UPDATE_KORG_ERR)
+ KAlarm::displayKOrgUpdateError(win, KAlarm::KORG_ERR_MODIFY, 1);
+ }
+ Undo::saveEdit(event, newEvent);
+
+ KAlarm::outputAlarmWarnings(&editDlg, &newEvent);
}
}
Index: kalarmapp.cpp
===================================================================
--- kalarmapp.cpp (revision 532908)
+++ kalarmapp.cpp (working copy)
@@ -360,6 +360,35 @@
}
}
else
+ if (args->isSet("edit"))
+ {
+ QString eventID = args->getOption("edit");
+ if (!initCheck())
+ {
+ exitCode = 1;
+ break;
+ }
+ if (!KAlarm::edit(eventID))
+ {
+ USAGE(i18n("%1: Event %2 not found, or not \
editable").arg(QString::fromLatin1("--edit")).arg(eventID)) + exitCode = 1;
+ break;
+ }
+ }
+ else
+ if (args->isSet("edit-new") || args->isSet("edit-new-preset"))
+ {
+ QString templ;
+ if (args->isSet("edit-new-preset"))
+ templ = args->getOption("edit-new-preset");
+ if (!initCheck())
+ {
+ exitCode = 1;
+ break;
+ }
+ KAlarm::editNew(templ);
+ }
+ else
if (args->isSet("file") || args->isSet("exec") || args->isSet("mail") || \
args->count()) {
// Display a message or file, execute a command, or send an email
Index: mainwindow.h
===================================================================
--- mainwindow.h (revision 532908)
+++ mainwindow.h (working copy)
@@ -59,6 +59,7 @@
{ executeNew(w, 0, a, t); }
static void executeNew(const KAEvent& e, MainWindow* w = 0)
{ executeNew(w, &e); }
+ static void executeEdit(KAEvent&, MainWindow* = 0);
static void executeDragEnterEvent(QDragEnterEvent*);
static void executeDropEvent(MainWindow*, QDropEvent*);
static void closeAll();
Index: main.cpp
===================================================================
--- main.cpp (revision 532908)
+++ main.cpp (working copy)
@@ -53,6 +53,10 @@
{ "disable", I18N_NOOP("Disable the alarm"), 0 },
{ "e", 0, 0 },
{ "!exec <commandline>", I18N_NOOP("Execute a shell command line"), 0 },
+ { "edit <eventID>", I18N_NOOP("Display the alarm edit dialog to edit the specified \
alarm"), 0 }, + { "n", 0, 0 },
+ { "edit-new", I18N_NOOP("Display the alarm edit dialog to edit a new alarm"), 0 },
+ { "edit-new-preset <templateName>", I18N_NOOP("Display the alarm edit dialog, \
preset with a template"), 0 }, { "f", 0, 0 },
{ "file <url>", I18N_NOOP("File to display"), 0 },
{ "F", 0, 0 },
@@ -106,7 +110,7 @@
KAboutData aboutData(PROGRAM_NAME, I18N_NOOP("KAlarm"), KALARM_VERSION,
I18N_NOOP("Personal alarm message, command and email scheduler for KDE"),
KAboutData::License_GPL,
- "(c) 2001 - 2005, David Jarvie", 0, \
"http://www.astrojar.org.uk/linux/kalarm.html"); + "(c) 2001-2006, David Jarvie", 0, \
"http://www.astrojar.org.uk/linux/kalarm.html"); aboutData.addAuthor("David Jarvie", \
0, "software@astrojar.org.uk");
KCmdLineArgs::init(argc, argv, &aboutData);
Index: functions.cpp
===================================================================
--- functions.cpp (revision 532908)
+++ functions.cpp (working copy)
@@ -459,6 +459,61 @@
}
/******************************************************************************
+* Display the alarm edit dialogue to edit a specified alarm.
+*/
+bool edit(const QString& eventID)
+{
+ AlarmCalendar* cal;
+ switch (KAEvent::uidStatus(eventID))
+ {
+ case KAEvent::ACTIVE:
+ cal = AlarmCalendar::activeCalendar();
+ break;
+ case KAEvent::TEMPLATE:
+ cal = AlarmCalendar::templateCalendarOpen();
+ break;
+ default:
+ kdError(5950) << "KAlarm::edit(" << eventID << "): event not active or template" \
<< endl; + return false;
+ }
+ KCal::Event* kcalEvent = cal->event(eventID);
+ if (!kcalEvent)
+ {
+ kdError(5950) << "KAlarm::edit(): event ID not found: " << eventID << endl;
+ return false;
+ }
+ KAEvent event(*kcalEvent);
+ MainWindow::executeEdit(event);
+ return true;
+}
+
+/******************************************************************************
+* Display the alarm edit dialogue to edit a new alarm, optionally preset with
+* a template.
+*/
+bool editNew(const QString& templateName)
+{
+ bool result = true;
+ if (!templateName.isEmpty())
+ {
+ AlarmCalendar* cal = AlarmCalendar::templateCalendarOpen();
+ if (cal)
+ {
+ KAEvent templateEvent = KAEvent::findTemplateName(*cal, templateName);
+ if (templateEvent.valid())
+ {
+ MainWindow::executeNew(templateEvent);
+ return true;
+ }
+ kdWarning(5950) << "KAlarm::editNew(" << templateName << "): template not found" \
<< endl; + }
+ result = false;
+ }
+ MainWindow::executeNew();
+ return result;
+}
+
+/******************************************************************************
* Returns a list of all alarm templates.
* If shell commands are disabled, command alarm templates are omitted.
*/
Index: dcophandler.h
===================================================================
--- dcophandler.h (revision 532908)
+++ dcophandler.h (working copy)
@@ -67,6 +67,8 @@
virtual bool scheduleEmail(const QString& fromID, const QString& addresses, const \
QString& subject, const QString& message,
const QString& attachments, const QString& \
startDateTime, int lateCancel, unsigned flags,
int recurType, int recurInterval, const QString& \
endDateTime); + virtual bool edit(const QString& eventID);
+ virtual bool editNew(const QString& templateName);
private:
static bool scheduleMessage(const QString& message, const DateTime& start, int \
lateCancel, unsigned flags,
_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic