[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: [Kde-pim] Korganizer patch
From: "Scott R.Little" <little () eng ! utah ! edu>
Date: 2001-08-03 0:29:31
[Download RAW message or body]
Hi guys,
Well, this is my first attempt at a patch so please go easy on me, but let
me know if things don't work or if I have done something wrong.
This is patch for korganizer (yeah, it probably won't get into CVS for a
bit, but that is okay w/ me) that adds alarms to todos. It also fixes a few
smaller bugs that I was experiencing. It should prevent the problem of
certain events w/out alarms triggering alarms randomly. It should also fix
the problem where todos always write a start date even if the option is not
enabled. That is about it. Let me know what you think.
Thanks,
Scott Little
--
i feel stupid - but i think i been catchin' on
"Mad Season" by Matchbox 20
["korganizer.patch" (text/x-diff)]
? kdepim/abbrowser/Makefile.in
? kdepim/abbrowser/Makefile
? kdepim/abbrowser/abbrowseriface.kidl
? kdepim/abbrowser/abbrowseriface_skel.cpp
? kdepim/abbrowser/abbrowser
? kdepim/abbrowser/pics/Makefile.in
? kdepim/abbrowser/pics/Makefile
? kdepim/doc/abbrowser/Makefile.in
? kdepim/doc/abbrowser/Makefile
? kdepim/doc/kandy/index.cache.bz2
? kdepim/doc/korganizer/index.cache.bz2
? kdepim/doc/kpilot/index.cache.bz2
Index: kdepim//korganizer/alarmdaemon.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/alarmdaemon.cpp,v
retrieving revision 1.51
diff -u -3 -d -p -r1.51 alarmdaemon.cpp
--- kdepim//korganizer/alarmdaemon.cpp 2001/05/08 11:49:53 1.51
+++ kdepim//korganizer/alarmdaemon.cpp 2001/08/02 23:33:18
@@ -103,6 +103,8 @@ AlarmDaemon::AlarmDaemon(QObject *parent
connect(mAlarmTimer,SIGNAL(timeout()),mCalendar,SLOT(checkAlarms()));
connect(mCalendar, SIGNAL(alarmSignal(QList<Event> &)),
SLOT(showAlarms(QList<Event> &)));
+ connect(mCalendar, SIGNAL(alarmSignal(QList<Todo> &)),
+ SLOT(showTodoAlarms(QList<Todo> &)));
}
AlarmDaemon::~AlarmDaemon()
@@ -161,7 +163,21 @@ void AlarmDaemon::showAlarms(QList<Event
for (anEvent = alarmEvents.first(); anEvent; anEvent = alarmEvents.next()) {
mAlarmDialog->appendEvent(anEvent);
}
+
+ showDialog();
+}
+void AlarmDaemon::showTodoAlarms(QList<Todo> &alarmTodos)
+{
+ // leave immediately if alarms are off
+ if (!mDocker->alarmsOn()) return;
+
+ Todo *aTodo;
+
+ for (aTodo = alarmTodos.first(); aTodo; aTodo = alarmTodos.next()) {
+ mAlarmDialog->appendTodo(aTodo);
+ }
+
showDialog();
}
@@ -180,7 +196,7 @@ bool AlarmDaemon::process(const QCString
void AlarmDaemon::suspend(int duration)
{
-// kdDebug() << "AlarmDaemon::suspend() " << duration << " minutes" << endl;
+ //kdDebug() << "AlarmDaemon::suspend() " << duration << " minutes" << endl;
connect(mSuspendTimer,SIGNAL(timeout()),SLOT(showDialog()));
@@ -189,7 +205,8 @@ void AlarmDaemon::suspend(int duration)
void AlarmDaemon::showDialog()
{
+ kdDebug() << "Entered alarmDaemon::showDialog" << endl;
KNotifyClient::beep();
mAlarmDialog->show();
- mAlarmDialog->eventNotification();
+ mAlarmDialog->incidenceNotification();
}
Index: kdepim//korganizer/alarmdaemon.h
===================================================================
RCS file: /home/kde/kdepim/korganizer/alarmdaemon.h,v
retrieving revision 1.22
diff -u -3 -d -p -r1.22 alarmdaemon.h
--- kdepim//korganizer/alarmdaemon.h 2001/05/05 22:47:28 1.22
+++ kdepim//korganizer/alarmdaemon.h 2001/08/02 23:33:18
@@ -10,6 +10,7 @@
#include "calendar.h"
#include "event.h"
+#include "todo.h"
class AlarmDialog;
@@ -55,12 +56,15 @@ class AlarmDaemon : public QObject, DCOP
public slots:
void showAlarms(QList<Event> &alarmEvents);
+ void showTodoAlarms(QList<Todo> &alarmTodos);
void reloadCal();
void suspend(int duration);
void showDialog();
-
+
+
signals:
void alarmSignal(QList<Event> &);
+ void alarmTSignal(QList<Todo> &);
private:
AlarmDockWindow *mDocker;
Index: kdepim//korganizer/alarmdialog.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/alarmdialog.cpp,v
retrieving revision 1.5
diff -u -3 -d -p -r1.5 alarmdialog.cpp
--- kdepim//korganizer/alarmdialog.cpp 2001/04/11 01:05:44 1.5
+++ kdepim//korganizer/alarmdialog.cpp 2001/08/02 23:33:18
@@ -8,6 +8,7 @@
#include <klocale.h>
#include <kprocess.h>
#include <kaudioplayer.h>
+#include <kdebug.h>
#include "event.h"
@@ -57,6 +58,7 @@ void AlarmDialog::clearEvents()
void AlarmDialog::slotOk()
{
clearEvents();
+ clearTodos();
accept();
}
@@ -66,7 +68,25 @@ void AlarmDialog::slotUser1()
accept();
}
-void AlarmDialog::eventNotification()
+void AlarmDialog::incidenceNotification()
+{
+ Incidence *anIncidence;
+
+ for (anIncidence = mIncidence.first(); anIncidence;
+ anIncidence = mIncidence.next()) {
+ if (!anIncidence->alarm()->programFile().isEmpty()) {
+ KProcess proc;
+ proc << anIncidence->alarm()->programFile().latin1();
+ proc.start(KProcess::DontCare);
+ }
+
+ if (!anIncidence->alarm()->audioFile().isEmpty()) {
+ KAudioPlayer::play(anIncidence->alarm()->audioFile().latin1());
+ }
+ }
+}
+
+/*void AlarmDialog::eventNotification()
{
Event *anEvent;
@@ -82,4 +102,34 @@ void AlarmDialog::eventNotification()
KAudioPlayer::play(anEvent->alarm()->audioFile().latin1());
}
}
+}*/
+
+void AlarmDialog::appendTodo(Todo *todo)
+{
+ mEventViewer->appendTodo(todo);
+ mTodos.append(todo);
}
+
+void AlarmDialog::clearTodos()
+{
+ mEventViewer->clearEvents();
+ mTodos.clear();
+}
+
+/*void AlarmDialog::todoNotification()
+{
+ Todo *aTodo;
+
+ for (aTodo = mTodos.first(); aTodo;
+ aTodo = mTodos.next()) {
+ if (!aTodo->alarm()->programFile().isEmpty()) {
+ KProcess proc;
+ proc << aTodo->alarm()->programFile().latin1();
+ proc.start(KProcess::DontCare);
+ }
+
+ if (!aTodo->alarm()->audioFile().isEmpty()) {
+ KAudioPlayer::play(aTodo->alarm()->audioFile().latin1());
+ }
+ }
+}*/
Index: kdepim//korganizer/alarmdialog.h
===================================================================
RCS file: /home/kde/kdepim/korganizer/alarmdialog.h,v
retrieving revision 1.4
diff -u -3 -d -p -r1.4 alarmdialog.h
--- kdepim//korganizer/alarmdialog.h 2001/04/18 23:28:57 1.4
+++ kdepim//korganizer/alarmdialog.h 2001/08/02 23:33:18
@@ -8,6 +8,8 @@
#include <kdialogbase.h>
#include <event.h>
+#include <todo.h>
+#include <incidence.h>
using namespace KCal;
@@ -22,10 +24,18 @@ class AlarmDialog : public KDialogBase {
void appendEvent(Event *event);
- void eventNotification();
+ //void eventNotification();
void clearEvents();
+ void incidenceNotification();
+
+ void appendTodo(Todo *todo);
+
+ //void todoNotification();
+
+ void clearTodos();
+
public slots:
void slotOk();
void slotUser1();
@@ -39,6 +49,11 @@ class AlarmDialog : public KDialogBase {
QList<Event> mEvents;
QSpinBox *mSuspendSpin;
+
+ QList<Todo> mTodos;
+
+ QList<Incidence> mIncidence;
+
};
#endif
Index: kdepim//korganizer/koeditorgeneraltodo.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koeditorgeneraltodo.cpp,v
retrieving revision 1.18
diff -u -3 -d -p -r1.18 koeditorgeneraltodo.cpp
--- kdepim//korganizer/koeditorgeneraltodo.cpp 2001/06/21 16:03:23 1.18
+++ kdepim//korganizer/koeditorgeneraltodo.cpp 2001/08/02 23:33:18
@@ -16,6 +16,8 @@
#include <kstddirs.h>
#include <kbuttonbox.h>
#include <kmessagebox.h>
+#include <kfiledialog.h>
+#include <kdebug.h>
#include "koprefs.h"
#include "todo.h"
@@ -30,8 +32,8 @@ KOEditorGeneralTodo::KOEditorGeneralTodo
mSpacing = spacing;
initTimeBox();
+ initAlarmBox();
initMisc();
-
initLayout();
QWidget::setTabOrder(summaryEdit, completedCombo);
@@ -39,7 +41,10 @@ KOEditorGeneralTodo::KOEditorGeneralTodo
QWidget::setTabOrder(priorityCombo, descriptionEdit);
QWidget::setTabOrder(descriptionEdit, categoriesButton);
QWidget::setTabOrder(categoriesButton, mSecrecyCombo);
+ QWidget::setTabOrder(mSecrecyCombo, alarmButton);
+
summaryEdit->setFocus();
+
}
KOEditorGeneralTodo::~KOEditorGeneralTodo()
@@ -154,6 +159,49 @@ void KOEditorGeneralTodo::initMisc()
categoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
}
+void KOEditorGeneralTodo::initAlarmBox()
+{
+ QPixmap pixmap;
+
+ alarmBell = new QLabel(this);
+ alarmBell->setPixmap(SmallIcon("bell"));
+
+ alarmButton = new QCheckBox( this, "CheckBox_2" );
+ alarmButton->setText( i18n("Reminder:") );
+
+ alarmTimeEdit = new KRestrictedLine( this, "alarmTimeEdit",
+ "1234567890");
+ alarmTimeEdit->setText("");
+
+ alarmIncrCombo = new QComboBox(false, this);
+ alarmIncrCombo->insertItem(i18n("minute(s)"));
+ alarmIncrCombo->insertItem(i18n("hour(s)"));
+ alarmIncrCombo->insertItem(i18n("day(s)"));
+ alarmIncrCombo->setMinimumHeight(20);
+
+ alarmSoundButton = new QPushButton( this, "PushButton_4" );
+ pixmap = SmallIcon("playsound");
+ // alarmSoundButton->setText( i18n("WAV") );
+ alarmSoundButton->setPixmap(pixmap);
+ alarmSoundButton->setToggleButton(true);
+ QToolTip::add(alarmSoundButton, i18n("No sound set"));
+
+ alarmProgramButton = new QPushButton( this, "PushButton_5" );
+ pixmap = SmallIcon("runprog");
+ // alarmProgramButton->setText( i18n("PROG") );
+ alarmProgramButton->setPixmap(pixmap);
+ alarmProgramButton->setToggleButton(true);
+ QToolTip::add(alarmProgramButton, i18n("No program set"));
+
+ connect(alarmButton, SIGNAL(toggled(bool)),
+ this, SLOT(alarmStuffEnable(bool)));
+
+ connect(alarmSoundButton, SIGNAL(clicked()),
+ this, SLOT(pickAlarmSound()));
+ connect(alarmProgramButton, SIGNAL(clicked()),
+ this, SLOT(pickAlarmProgram()));
+}
+
void KOEditorGeneralTodo::initLayout()
{
QBoxLayout *layoutTop = new QVBoxLayout(this);
@@ -175,9 +223,23 @@ void KOEditorGeneralTodo::initLayout()
layoutCompletion->addStretch();
layoutCompletion->addWidget(priorityLabel);
layoutCompletion->addWidget(priorityCombo);
-
- layoutTop->addWidget(descriptionEdit);
-
+
+ QBoxLayout *layoutAlarmLine = new QHBoxLayout;
+ layoutTop->addLayout(layoutAlarmLine);
+
+ QBoxLayout *layoutAlarmBox = new QHBoxLayout;
+ layoutAlarmLine->addLayout(layoutAlarmBox);
+ layoutAlarmBox->addWidget(alarmBell);
+ layoutAlarmBox->addWidget(alarmButton);
+ layoutAlarmBox->addWidget(alarmTimeEdit);
+ layoutAlarmBox->addWidget(alarmIncrCombo);
+ layoutAlarmBox->addWidget(alarmSoundButton);
+ layoutAlarmBox->addWidget(alarmProgramButton);
+
+ layoutAlarmLine->addStretch(1);
+
+ layoutTop->addWidget(descriptionEdit,1);
+
QBoxLayout *layoutCategories = new QHBoxLayout;
layoutTop->addLayout(layoutCategories);
layoutCategories->addWidget(categoriesButton);
@@ -186,6 +248,59 @@ void KOEditorGeneralTodo::initLayout()
layoutCategories->addWidget(mSecrecyCombo);
}
+void KOEditorGeneralTodo::pickAlarmSound()
+{
+ QString prefix = KGlobal::dirs()->findResourceDir("appdata", "sounds/alert.wav");
+ if (!alarmSoundButton->isOn()) {
+ alarmSound = "";
+ QToolTip::remove(alarmSoundButton);
+ QToolTip::add(alarmSoundButton, i18n("No sound set"));
+ } else {
+ QString fileName(KFileDialog::getOpenFileName(prefix,
+ i18n("*.wav|Wav Files"), this));
+ if (!fileName.isEmpty()) {
+ alarmSound = fileName;
+ QToolTip::remove(alarmSoundButton);
+ QString dispStr = i18n("Playing '%1'").arg(fileName);
+ QToolTip::add(alarmSoundButton, dispStr);
+ }
+ }
+ if (alarmSound.isEmpty())
+ alarmSoundButton->setOn(false);
+}
+
+void KOEditorGeneralTodo::pickAlarmProgram()
+{
+ if (!alarmProgramButton->isOn()) {
+ alarmProgram = "";
+ QToolTip::remove(alarmProgramButton);
+ QToolTip::add(alarmProgramButton, i18n("No program set"));
+ } else {
+ QString fileName(KFileDialog::getOpenFileName(QString::null, QString::null, \
this)); + if (!fileName.isEmpty()) {
+ alarmProgram = fileName;
+ QToolTip::remove(alarmProgramButton);
+ QString dispStr = i18n("Running '%1'").arg(fileName);
+ QToolTip::add(alarmProgramButton, dispStr);
+ }
+ }
+ if (alarmProgram.isEmpty())
+ alarmProgramButton->setOn(false);
+}
+
+void KOEditorGeneralTodo::alarmStuffEnable(bool enable)
+{
+ alarmTimeEdit->setEnabled(enable);
+ alarmSoundButton->setEnabled(enable);
+ alarmProgramButton->setEnabled(enable);
+ alarmIncrCombo->setEnabled(enable);
+}
+
+void KOEditorGeneralTodo::alarmStuffDisable(bool disable)
+{
+ alarmStuffEnable(!disable);
+}
+
void KOEditorGeneralTodo::setCategories(const QString &str)
{
categoriesLabel->setText(str);
@@ -197,6 +312,7 @@ void KOEditorGeneralTodo::setDefaults(QD
noTimeButton->setChecked(allDay);
timeStuffDisable(allDay);
+ alarmStuffDisable(allDay);
mNoDueCheck->setChecked(true);
dueStuffDisable(true);
@@ -213,18 +329,36 @@ void KOEditorGeneralTodo::setDefaults(QD
mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
priorityCombo->setCurrentItem(2);
-
+
completedCombo->setCurrentItem(0);
+
+ // TODO: Implement a KPrefsComboItem to solve this in a clean way.
+ int alarmTime;
+ int a[] = { 1,5,10,15,30 };
+ int index = KOPrefs::instance()->mAlarmTime;
+ if (index < 0 || index > 4) {
+ alarmTime = 0;
+ } else {
+ alarmTime = a[index];
+ }
+ alarmTimeEdit->setText(QString::number(alarmTime));
+ alarmStuffEnable(false);
+
+ mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
}
void KOEditorGeneralTodo::readTodo(Todo *todo)
{
+ QDateTime tmpDT, dueDT;
+ int i;
+
summaryEdit->setText(todo->summary());
descriptionEdit->setText(todo->description());
// organizer information
ownerLabel->setText(i18n("Owner: ") + todo->organizer());
if (todo->hasDueDate()) {
+ dueDT = todo->dtDue();
mDueDateEdit->setDate(todo->dtDue().date());
mDueTimeEdit->setTime(todo->dtDue().time());
mNoDueCheck->setChecked(false);
@@ -257,10 +391,52 @@ void KOEditorGeneralTodo::readTodo(Todo
setCategories(todo->categoriesStr());
mSecrecyCombo->setCurrentItem(todo->secrecy());
+
+ // set up alarm stuff
+ alarmButton->setChecked(todo->alarm()->enabled());
+ if (alarmButton->isChecked()) {
+ alarmStuffEnable(true);
+ tmpDT = todo->alarm()->time();
+ if (tmpDT.isValid()) {
+ i = tmpDT.secsTo(dueDT);
+ i = i / 60; // make minutes
+ if (i % 60 == 0) { // divides evenly into hours?
+ i = i / 60;
+ alarmIncrCombo->setCurrentItem(1);
+ }
+ if (i % 24 == 0) { // divides evenly into days?
+ i = i / 24;
+ alarmIncrCombo->setCurrentItem(2);
+ }
+ } else {
+ i = 5;
+ }
+ alarmTimeEdit->setText(QString::number(i));
+
+ if (!todo->alarm()->programFile().isEmpty()) {
+ alarmProgram = todo->alarm()->programFile();
+ alarmProgramButton->setOn(true);
+ QString dispStr = i18n("Running '%1'").arg(alarmProgram);
+ QToolTip::add(alarmProgramButton, dispStr);
+ }
+ if (!todo->alarm()->audioFile().isEmpty()) {
+ alarmSound = todo->alarm()->audioFile();
+ alarmSoundButton->setOn(true);
+ QString dispStr = i18n("Playing '%1'").arg(alarmSound);
+ QToolTip::add(alarmSoundButton, dispStr);
+ }
+ }
+ else {
+ alarmStuffEnable(false);
+ }
}
void KOEditorGeneralTodo::writeTodo(Todo *todo)
{
+ // temp. until something better happens.
+ QString tmpStr;
+ int j;
+
todo->setSummary(summaryEdit->text());
todo->setDescription(descriptionEdit->text());
todo->setCategories(categoriesLabel->text());
@@ -281,7 +457,7 @@ void KOEditorGeneralTodo::writeTodo(Todo
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
todo->setDtDue(tmpDT);
-
+
tmpDate = mStartDateEdit->getDate();
tmpTime.setHMS(0,0,0);
tmpDT.setDate(tmpDate);
@@ -313,6 +489,38 @@ void KOEditorGeneralTodo::writeTodo(Todo
if (completedCombo->currentItem() == 5 && mCompleted.isValid()) {
todo->setCompleted(mCompleted);
}
+
+ // alarm stuff
+ if (alarmButton->isChecked()) {
+ todo->alarm()->setEnabled(true);
+ tmpStr = alarmTimeEdit->text();
+ j = tmpStr.toInt() * -60;
+ if (alarmIncrCombo->currentItem() == 1)
+ j = j * 60;
+ else if (alarmIncrCombo->currentItem() == 2)
+ j = j * (60 * 24);
+
+ tmpDT = todo->dtDue();
+ tmpDT = tmpDT.addSecs(j);
+ todo->alarm()->setTime(tmpDT);
+ if (!alarmProgram.isEmpty() && alarmProgramButton->isOn())
+ todo->alarm()->setProgramFile(alarmProgram);
+ else
+ todo->alarm()->setProgramFile("");
+ if (!alarmSound.isEmpty() && alarmSoundButton->isOn())
+ todo->alarm()->setAudioFile(alarmSound);
+ else
+ todo->alarm()->setAudioFile("");
+ } else {
+ todo->alarm()->setEnabled(false);
+ todo->alarm()->setProgramFile("");
+ todo->alarm()->setAudioFile("");
+ }
+
+ // note, that if on the details tab the "Transparency" option is implemented,
+ // we will have to change this to suit.
+ //todo->setTransparency(freeTimeCombo->currentItem());
+
}
void KOEditorGeneralTodo::dueStuffDisable(bool disable)
Index: kdepim//korganizer/koeditorgeneraltodo.h
===================================================================
RCS file: /home/kde/kdepim/korganizer/koeditorgeneraltodo.h,v
retrieving revision 1.10
diff -u -3 -d -p -r1.10 koeditorgeneraltodo.h
--- kdepim//korganizer/koeditorgeneraltodo.h 2001/06/10 23:46:43 1.10
+++ kdepim//korganizer/koeditorgeneraltodo.h 2001/08/02 23:33:18
@@ -50,14 +50,20 @@ class KOEditorGeneralTodo : public QWidg
void startStuffDisable(bool disable);
void completedChanged(int);
+ void alarmStuffEnable(bool enable);
+ void alarmStuffDisable(bool disable);
+ void pickAlarmSound();
+ void pickAlarmProgram();
+
protected:
void initMisc();
void initLayout();
void initTimeBox();
-
+ void initAlarmBox();
+
void setCompletedDate();
- private:
+ private:
QGroupBox *timeGroupBox;
QLabel *summaryLabel;
QLineEdit *summaryEdit;
@@ -77,6 +83,13 @@ class KOEditorGeneralTodo : public QWidg
QPushButton *categoriesButton;
QLabel *categoriesLabel;
+
+ QLabel *alarmBell;
+ QCheckBox *alarmButton;
+ KRestrictedLine *alarmTimeEdit;
+ QPushButton *alarmSoundButton;
+ QPushButton *alarmProgramButton;
+ QComboBox *alarmIncrCombo;
// variables for the todo stuff
QCheckBox *mNoDueCheck;
Index: kdepim//libkcal/calendarlocal.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/calendarlocal.cpp,v
retrieving revision 1.5
diff -u -3 -d -p -r1.5 calendarlocal.cpp
--- kdepim//libkcal/calendarlocal.cpp 2001/05/15 14:36:05 1.5
+++ kdepim//libkcal/calendarlocal.cpp 2001/08/02 23:33:19
@@ -368,7 +368,10 @@ void CalendarLocal::checkAlarms()
QIntDictIterator<QList<Event> > dictIt(*mCalDict);
QList<Event> *tmpList;
Event *anEvent;
+ QList<Todo> alarmTodos;
+ Todo *aTodo;
QDateTime tmpDT;
+
// this function has to look at every event in the whole database
// and find if any have an alarm pending.
@@ -377,11 +380,15 @@ void CalendarLocal::checkAlarms()
tmpList = dictIt.current();
for (anEvent = tmpList->first(); anEvent;
anEvent = tmpList->next()) {
- tmpDT = anEvent->alarm()->time();
- if (tmpDT.date() == QDate::currentDate()) {
- if ((tmpDT.time().hour() == QTime::currentTime().hour()) &&
- (tmpDT.time().minute() == QTime::currentTime().minute()))
- alarmEvents.append(anEvent);
+ if (anEvent->alarm()->enabled()) {
+ tmpDT = anEvent->alarm()->time();
+ //kdDebug() << "calendarlocal::checkAlarms - tmpDT of " << anEvent->summary() << " \
- " << tmpDT.date().toString() << endl; + if (tmpDT.date() == QDate::currentDate()) {
+ if ((tmpDT.time().hour() == QTime::currentTime().hour()) &&
+ (tmpDT.time().minute() == QTime::currentTime().minute())) {
+ alarmEvents.append(anEvent);
+ }
+ }
}
}
++dictIt;
@@ -395,9 +402,25 @@ void CalendarLocal::checkAlarms()
alarmEvents.append(anEvent);
}
}
-
if (!alarmEvents.isEmpty())
emit alarmSignal(alarmEvents);
+
+ for(aTodo = mTodoList.first(); aTodo; aTodo = mTodoList.next()) {
+ if (aTodo->alarm()->enabled()) {
+ tmpDT = aTodo->alarm()->time();
+ //kdDebug() << "calendarlocal::checkAlarms - tmpDT of " << aTodo->summary() << \
" - " << tmpDT.date().toString() << endl; + if (tmpDT.date() == \
QDate::currentDate()) { + if ((tmpDT.time().hour() == QTime::currentTime().hour()) &&
+ (tmpDT.time().minute() == QTime::currentTime().minute())) {
+ alarmTodos.append(aTodo);
+ }
+ }
+ }
+ }
+
+ if (!alarmTodos.isEmpty()) {
+ emit alarmSignal(alarmTodos);
+ }
}
/****************************** PROTECTED METHODS ****************************/
Index: kdepim//libkcal/calendarlocal.h
===================================================================
RCS file: /home/kde/kdepim/libkcal/calendarlocal.h,v
retrieving revision 1.2
diff -u -3 -d -p -r1.2 calendarlocal.h
--- kdepim//libkcal/calendarlocal.h 2001/04/26 15:36:55 1.2
+++ kdepim//libkcal/calendarlocal.h 2001/08/02 23:33:19
@@ -89,7 +89,9 @@ class CalendarLocal : public Calendar {
signals:
/** emitted at regular intervals to indicate that the events in the
list have triggered an alarm. */
+ //void alarmSignal(QList<Incidence> &);
void alarmSignal(QList<Event> &);
+ void alarmSignal(QList<Todo> &);
/** emitted whenever an event in the calendar changes. Emits a pointer
to the changed event. */
void calUpdated(Incidence *);
@@ -119,8 +121,8 @@ class CalendarLocal : public Calendar {
private:
QIntDict<QList<Event> > *mCalDict; // dictionary of lists of events.
QList<Event> mRecursList; // list of repeating events.
-
- QList<Todo> mTodoList; // list of "todo" items.
+
+ QList<Todo> mTodoList; // list of todo items.
QMap<QDate,Journal *> mJournalMap;
Index: kdepim//libkcal/icalformatimpl.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/icalformatimpl.cpp,v
retrieving revision 1.8
diff -u -3 -d -p -r1.8 icalformatimpl.cpp
--- kdepim//libkcal/icalformatimpl.cpp 2001/06/29 09:23:55 1.8
+++ kdepim//libkcal/icalformatimpl.cpp 2001/08/02 23:33:19
@@ -64,6 +64,19 @@ icalcomponent *ICalFormatImpl::writeTodo
icalcomponent_add_property(vtodo,icalproperty_new_due(due));
}
+ // start time
+ if (todo->hasStartDate()) {
+ icaltimetype start;
+ if (todo->doesFloat()) {
+ kdDebug() << "§§ Incidence " << todo->summary() << " floats." << endl;
+ start = writeICalDate(todo->dtStart().date());
+ } else {
+ kdDebug() << "§§ incidence " << todo->summary() << " has time." << endl;
+ start = writeICalDateTime(todo->dtStart());
+ }
+ icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start));
+ }
+
// completion date
if (todo->isCompleted()) {
if (!todo->hasCompletedDate()) {
@@ -92,7 +105,18 @@ icalcomponent *ICalFormatImpl::writeEven
icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
writeIncidence(vevent,event);
-
+
+ // start time
+ icaltimetype start;
+ if (event->doesFloat()) {
+ kdDebug() << "§§ Incidence " << event->summary() << " floats." << endl;
+ start = writeICalDate(event->dtStart().date());
+ } else {
+ kdDebug() << "§§ incidence " << event->summary() << " has time." << endl;
+ start = writeICalDateTime(event->dtStart());
+ }
+ icalcomponent_add_property(vevent,icalproperty_new_dtstart(start));
+
// end time
icaltimetype end;
if (event->doesFloat()) {
@@ -199,18 +223,6 @@ void ICalFormatImpl::writeIncidence(ical
icalcomponent_add_property(parent,p);
}
}
-
- // start time
- icaltimetype start;
- if (incidence->doesFloat()) {
- kdDebug() << "§§ Incidence " << incidence->summary() << " floats." << endl;
- start = writeICalDate(incidence->dtStart().date());
- } else {
- kdDebug() << "§§ incidence " << incidence->summary() << " has time." << endl;
- start = writeICalDateTime(incidence->dtStart());
- }
- icalcomponent_add_property(parent,icalproperty_new_dtstart(start));
-
// description
if (!incidence->description().isEmpty()) {
icalcomponent_add_property(parent,icalproperty_new_description(
@@ -632,7 +644,7 @@ icalcomponent *ICalFormatImpl::writeAlar
Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo)
{
Todo *todo = new Todo;
-
+
readIncidence(vtodo,todo);
icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY);
@@ -652,6 +664,7 @@ Todo *ICalFormatImpl::readTodo(icalcompo
if (icaltime.is_date) {
todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0)));
todo->setFloats(true);
+
} else {
todo->setDtDue(readICalDateTime(icaltime));
todo->setFloats(false);
@@ -676,9 +689,9 @@ Todo *ICalFormatImpl::readTodo(icalcompo
case ICAL_DTSTART_PROPERTY:
// Flag that todo has start date. Value is read in by readIncidence().
- todo->setHasStartDate(true);
+ todo->setHasStartDate(true);
break;
-
+
default:
// kdDebug() << "ICALFormat::readTodo(): Unknown property: " << kind
// << endl;
@@ -904,7 +917,7 @@ void ICalFormatImpl::readIncidence(icalc
break;
case ICAL_DTSTART_PROPERTY: // start date and time
- icaltime = icalproperty_get_dtstart(p);
+ icaltime = icalproperty_get_dtstart(p);
if (icaltime.is_date) {
incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0)));
incidence->setFloats(true);
@@ -1325,8 +1338,8 @@ void ICalFormatImpl::readRecurrenceRule(
void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence)
{
- kdDebug() << "Read alarm for " << incidence->summary() << endl;
-
+ //kdDebug() << "Read alarm for " << incidence->summary() << endl;
+
KOAlarm* koalarm = incidence->alarm();
koalarm->setRepeatCount(0);
koalarm->setEnabled(true);
@@ -1426,6 +1439,28 @@ void ICalFormatImpl::readAlarm(icalcompo
}
}
}
+
+ if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) {
+ VObject *a;
+ if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
+ aTodo->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a))));
+ deleteStr(s);
+ }
+ aTodo->setEnabled(true);
+ if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) {
+ if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
+ aTodo->setProgramFile(s = fakeCString(vObjectUStringZValue(a)));
+ deleteStr(s);
+ }
+ }
+ if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) {
+ if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
+ aTodo->setAudioFile(s = fakeCString(vObjectUStringZValue(a)));
+ deleteStr(s);
+ }
+ }
+ }
+
#endif
}
Index: kdepim//libkcal/incidence.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/incidence.cpp,v
retrieving revision 1.4
diff -u -3 -d -p -r1.4 incidence.cpp
--- kdepim//libkcal/incidence.cpp 2001/06/22 21:01:26 1.4
+++ kdepim//libkcal/incidence.cpp 2001/08/02 23:33:19
@@ -136,17 +136,17 @@ const QString &Incidence::organizer() co
void Incidence::setDtStart(const QDateTime &dtStart)
-{
- int diffsecs = mDtStart.secsTo(dtStart);
-
+{
+ /*int diffsecs = mDtStart.secsTo(dtStart);
+
if (mReadOnly) return;
if (alarm()->enabled())
- alarm()->setTime(alarm()->time().addSecs(diffsecs));
+ alarm()->setTime(alarm()->time().addSecs(diffsecs));*/
mDtStart = dtStart;
recurrence()->setRecurStart(mDtStart);
- alarm()->setAlarmStart(mDtStart);
+ //alarm()->setAlarmStart(mDtStart);
emit eventUpdated(this);
}
Index: kdepim//libkcal/todo.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/todo.cpp,v
retrieving revision 1.3
diff -u -3 -d -p -r1.3 todo.cpp
--- kdepim//libkcal/todo.cpp 2001/06/22 11:17:49 1.3
+++ kdepim//libkcal/todo.cpp 2001/08/02 23:33:19
@@ -24,14 +24,19 @@ Todo::~Todo()
}
void Todo::setDtDue(const QDateTime &dtDue)
-{
- int diffsecs = mDtDue.secsTo(dtDue);
-
- if (mReadOnly) return;
- if (alarm()->enabled())
+{
+ //int diffsecs = mDtDue.secsTo(dtDue);
+
+ /*if (mReadOnly) return;
+ if (alarm()->enabled()) {
alarm()->setTime(alarm()->time().addSecs(diffsecs));
-
+ }*/
mDtDue = dtDue;
+
+ //kdDebug() << "setDtDue says date is " << mDtDue.toString() << endl;
+
+ //alarm()->setAlarmStart(mDtDue);
+
emit eventUpdated(this);
}
Index: kdepim//libkcal/vcalformat.cpp
===================================================================
RCS file: /home/kde/kdepim/libkcal/vcalformat.cpp,v
retrieving revision 1.3
diff -u -3 -d -p -r1.3 vcalformat.cpp
--- kdepim//libkcal/vcalformat.cpp 2001/06/22 11:17:49 1.3
+++ kdepim//libkcal/vcalformat.cpp 2001/08/02 23:33:19
@@ -484,6 +484,30 @@ VObject *VCalFormat::eventToVTodo(const
addPropValue(vtodo, VCCategoriesProp, tmpStr.utf8());
}
+ // alarm stuff
+ kdDebug() << "vcalformat::eventToVTodo was called" << endl;
+ if (anEvent->alarm()->enabled()) {
+ VObject *a = addProp(vtodo, VCDAlarmProp);
+ tmpStr = qDateTimeToISO(anEvent->alarm()->time());
+ addPropValue(a, VCRunTimeProp, tmpStr.latin1());
+ addPropValue(a, VCRepeatCountProp, "1");
+ addPropValue(a, VCDisplayStringProp, "beep!");
+ if (!anEvent->alarm()->audioFile().isEmpty()) {
+ a = addProp(vtodo, VCAAlarmProp);
+ addPropValue(a, VCRunTimeProp, tmpStr.latin1());
+ addPropValue(a, VCRepeatCountProp, "1");
+ addPropValue(a, VCAudioContentProp,
+ (const char *)QFile::encodeName(anEvent->alarm()->audioFile()));
+ }
+ if (!anEvent->alarm()->programFile().isEmpty()) {
+ a = addProp(vtodo, VCPAlarmProp);
+ addPropValue(a, VCRunTimeProp, tmpStr.latin1());
+ addPropValue(a, VCRepeatCountProp, "1");
+ addPropValue(a, VCProcedureNameProp,
+ (const char *)QFile::encodeName(anEvent->alarm()->programFile()));
+ }
+ }
+
// pilot sync stuff
tmpStr.sprintf("%i",anEvent->pilotId());
addPropValue(vtodo, KPilotIdProp, tmpStr.latin1());
@@ -918,6 +942,31 @@ Todo *VCalFormat::VTodoToEvent(VObject *
anEvent->setHasStartDate(false);
}
+ /* alarm stuff */
+ //kdDebug() << "vcalformat::VTodoToEvent called" << endl;
+ if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) {
+ VObject *a;
+ if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
+ anEvent->alarm()->setTime(ISOToQDateTime(s = \
fakeCString(vObjectUStringZValue(a)))); + deleteStr(s);
+ }
+ anEvent->alarm()->setEnabled(true);
+ if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) {
+ if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
+ s = fakeCString(vObjectUStringZValue(a));
+ anEvent->alarm()->setProgramFile(QFile::decodeName(s));
+ deleteStr(s);
+ }
+ }
+ if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) {
+ if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
+ s = fakeCString(vObjectUStringZValue(a));
+ anEvent->alarm()->setAudioFile(QFile::decodeName(s));
+ deleteStr(s);
+ }
+ }
+ }
+
// related todo
if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) {
anEvent->setRelatedToVUID(s = fakeCString(vObjectUStringZValue(vo)));
_______________________________________________
Kde-pim mailing list
Kde-pim@master.kde.org
http://master.kde.org/mailman/listinfo/kde-pim
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic