summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt3
-rw-r--r--korganizer/koeditorgeneral.h1
-rw-r--r--korganizer/koeditorgeneralevent.cpp2
-rw-r--r--korganizer/koeditorgeneralevent.h1
-rw-r--r--korganizer/koeditorgeneraltodo.cpp9
-rw-r--r--korganizer/koeditorgeneraltodo.h1
-rw-r--r--korganizer/koeditorrecurrence.cpp42
-rw-r--r--korganizer/koeditorrecurrence.h4
-rw-r--r--korganizer/koeventeditor.cpp4
-rw-r--r--korganizer/kotodoeditor.cpp8
10 files changed, 49 insertions, 26 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index fdaf740..4b965c1 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,104 +1,107 @@
Info about the changes in new versions of KDE-Pim/Pi
********** VERSION 2.1.9 ************
KO/Pi:
Fixed some problems of the new search options in the search dialog.
Fixed some problems in the new resource config options.
Changed the recurrence edit of events and todos such that the recurrence edit page now is notified about a change of the start date on the first page.
+Fixed a problem cearting new events in the agenda view if at the day/time is already an agenda item shown:
+Now you can click on the bottom/top of an allday agenda item and on the left/right of an agenda item to get the "new todo/new event" popup.
+
PwM/Pi:
Added "sec" to the timeout config settings to make it clear the timeout values are seconds.
********** VERSION 2.1.8 ************
KO/Pi:
Added info about the completion state of a todo in the ListView/Searchdialog.
If in TodoView is selected "do not show compledted todos" then completed todos are not shown in the ListView as well.
Fixed some updating problems when changing the filter.
KA/Pi:
In the addressee selection dialog now the formatted name is shown, if not empty.
Added a column "category" to the addressee selection dialog to make it possible to sort addressees after category.
Now in the addressee selection dialog a selected contact is remove with a single click from the selected list.
Fixed in the file selector on the Zaurus the problem that symbolic links to files/dirs were ignored.
Fixed the sorting for size in the file selector on the Z.
Changed the color selection dialog on the Zaurus to a more user friendly version.
********** VERSION 2.1.7 ************
KO/Pi:
Fixed several problems in the new Resource handling.
Added more options to the search dialog.
Fixed a problem in the Month view.
Added more options to the dialog when setting a todo to stopped.
Fixed two small problems in KO/Pi Alarm applet.
********** VERSION 2.1.6 ************
This release is for testing only.
KO/Pi:
Added to the list view (the list view is used in search dialog as well) the possibility to print it.
Added to the list view the possibility to hide entries, if you do not want to print all entries of the list view.
Added to the list view the possibility to add all subtodos of selected todos to an export/beam.
Added to the search dialog the possibility to make an additive search such that you can get a better list for export/printout.
Added to the search dialog the possibility to hide the checkboxes such that there is more space for the list view on the Zaurus.
Fixed a problem in the AlarmTimer Applet: Now utf8 messages are displayed properly.
Added support for multiple calendar files in KO/Pi. Only local ical (*.ics) files are supported as calendars.
In the sync profile config it is still missing to specify a particular calendar to sync with this profile. That setting will be added later.
Now on every sync the set of calendars is synced which are enabled in the resource view.
A calendar is enabled in the resource view if the "eye" column is checked.
You can set a calendar to be the default for new items( "+" column ).
You can tell KO/Pi to ignore all alarm of a calendar ( "bell" column ) and you can set it readonly.
To find out how to add a new calendar and how to remove a calendar is left as an exercise to the reader ...
********** VERSION 2.1.5 ************
This is the new stable version.
Bugfix:
Fixed a problem with agenda popup on the desktop in KO/Pi.
Fixed a crash when reloading file, e.g. after a passive pi-sync synchronization.
Added config option to not display completed todos in agenda view.
Addressee view is now using the formatted name, if defined.
That makes it possible to display "lastname, firstname" in that view now.
To set the formatted name for all contacts, please use menu:
Edit->Change->Set formatted name.
Fixed the bug in KA/Pi that is was not possible to add images to a contact on Windows.
********** VERSION 2.1.4 ************
Fixed two more bugs in the KA/Pi CSV import dialog:
Made it possible to read multi-line fields and import it to the "Note" field.
Fixed a problem in mapping custom fields, whatever a custem field is...
********** VERSION 2.1.3 ************
Changed the menu structure of the alarm applet:
Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List".
Fixed several problems in the KA/Pi CSV import dialog:
Added "Category", made codec configureable and made it possible to map many fields to the "Note" field.
********** VERSION 2.1.2 ************
Fixed a problem closing the alarm dialog on Zaurus with "OK" button.
Fixed a problem when importing data from Outlook with mutiple categories set.
Changed display of days in datenavigator:
Birthdays are now blue, not dark green.
When todo view is shown, no birtdays are shown and days with due todos are shown blue.
When journal view is shown, only holidays are shown and days with journals are blue.
Added Backup options to global config:
You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ).
It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again.
The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups.
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h
index 2069e9c..a8f6443 100644
--- a/korganizer/koeditorgeneral.h
+++ b/korganizer/koeditorgeneral.h
@@ -1,115 +1,116 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KOEDITORGENERAL_H
#define KOEDITORGENERAL_H
#include <qframe.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qlistview.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qspinbox.h>
#include <ktextedit.h>
#include <krestrictedline.h>
#include <libkcal/incidence.h>
#include "ktimeedit.h"
class KDateEdit;
class KOLocationBox;
using namespace KCal;
class KOEditorGeneral : public QObject
{
Q_OBJECT
public:
KOEditorGeneral (QObject* parent=0,const char* name=0);
virtual ~KOEditorGeneral();
void setFocusOn( int i );
void initHeader(QWidget *,QBoxLayout *);
void initDescription(QWidget *,QBoxLayout *);
void initSecrecy(QWidget *,QBoxLayout *);
void initCategories(QWidget *,QBoxLayout *);
void initAlarm(QWidget *,QBoxLayout *);
/** Set widgets to default values */
void setDefaults(bool allDay);
/** Read event object and setup widgets accordingly */
void readIncidence(Incidence *);
/** Write event settings to event object */
void writeIncidence(Incidence *);
/** Check if the input is valid. */
bool validateInput() { return true; }
void enableAlarm( bool enable );
void setSecrecy( int num );
public slots:
void setCategories(const QString &);
void editCategories();
protected slots:
void enableAlarmEdit( bool enable );
void disableAlarmEdit( bool disable );
void alarmDisable( bool disable );
void pickAlarmSound();
void pickAlarmProgram();
void slotSetFocusOn();
signals:
void openCategoryDialog();
void allAccepted();
+ void dateTimesChanged(QDateTime,QDateTime);
protected:
int mNextFocus;
//QLineEdit *mSummaryEdit;
//QLineEdit *mLocationEdit;
KOLocationBox *mSummaryEdit;
KOLocationBox *mLocationEdit;
QLabel *mAlarmBell;
QCheckBox *mAlarmButton;
QSpinBox *mAlarmTimeEdit;
QPushButton *mAlarmSoundButton;
QPushButton *mAlarmProgramButton;
QComboBox *mAlarmIncrCombo;
KTextEdit *mDescriptionEdit;
QLabel *mOwnerLabel;
QComboBox *mSecrecyCombo;
QCheckBox *mCancelBox;
QPushButton *mCategoriesButton;
QLabel *mCategoriesLabel;
private:
QString getFittingPath( const QString ) ;
QString mAlarmSound;
QString mAlarmProgram;
QString mAlarmMessage;
};
#endif
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp
index af97ee9..3dd7f5c 100644
--- a/korganizer/koeditorgeneralevent.cpp
+++ b/korganizer/koeditorgeneralevent.cpp
@@ -144,193 +144,193 @@ void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout)
this, SLOT(endDateChanged(QDate)));
connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime)));
connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime)));
}
void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout)
{
QBoxLayout *classLayout = new QHBoxLayout(topLayout);
QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent);
classLayout->addWidget(freeTimeLabel);
mFreeTimeCombo = new QComboBox(false, parent);
mFreeTimeCombo->insertItem(i18n("Busy"));
mFreeTimeCombo->insertItem(i18n("Free"));
classLayout->addWidget(mFreeTimeCombo);
}
void KOEditorGeneralEvent::timeStuffDisable(bool disable)
{
mStartTimeEdit->setEnabled( !disable );
mEndTimeEdit->setEnabled( !disable );
setDuration();
emitDateTimeStr();
}
void KOEditorGeneralEvent::dontAssociateTime(bool noTime)
{
timeStuffDisable(noTime);
//if(alarmButton->isChecked()) alarmStuffDisable(noTime);
allDayChanged(noTime);
}
void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end)
{
// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl;
if ( !mTemplate )
mStartDateEdit->setDate(start.date());
// KTimeEdit seems to emit some signals when setTime() is called.
mStartTimeEdit->blockSignals( true );
mStartTimeEdit->setTime(start.time());
mStartTimeEdit->blockSignals( false );
if ( !mTemplate )
mEndDateEdit->setDate(end.date());
mEndTimeEdit->setTime(end.time());
mCurrStartDateTime = start;
mCurrEndDateTime = end;
setDuration();
emitDateTimeStr();
}
void KOEditorGeneralEvent::sTimeChanged(QTime ti)
{
mStartTimeEdit->setTime( ti );
startTimeChanged ( ti);
}
void KOEditorGeneralEvent::eTimeChanged(QTime ti )
{
mEndTimeEdit->setTime( ti );
endTimeChanged( ti );
}
void KOEditorGeneralEvent::startTimeChanged(QTime newtime)
{
int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime);
mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) );
// adjust end time so that the event has the same duration as before.
if( secsep > 0 )
mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep);
mEndTimeEdit->setTime(mCurrEndDateTime.time());
mEndDateEdit->setDate(mCurrEndDateTime.date());
emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
}
void KOEditorGeneralEvent::endTimeChanged(QTime newtime)
{
mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0));
emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
}
void KOEditorGeneralEvent::startDateChanged(QDate newdate)
{
int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime);
mCurrStartDateTime.setDate(newdate);
// adjust end date so that the event has the same duration as before
mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep));
mEndDateEdit->setDate(mCurrEndDateTime.date());
-
+ qDebug("KOEditorGeneralEvent::startDateChanged ");
emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
}
void KOEditorGeneralEvent::endDateChanged(QDate newdate)
{
QDateTime newdt(newdate, mCurrEndDateTime.time());
if(newdt < mCurrStartDateTime) {
// oops, we can't let that happen.
newdt = mCurrStartDateTime;
mEndDateEdit->setDate(newdt.date());
mEndTimeEdit->setTime(newdt.time());
}
mCurrEndDateTime = newdt;
emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
}
void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay)
{
mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
mLocationEdit->load(KOLocationBox::LOCATION);
KOEditorGeneral::setDefaults(allDay);
mNoTimeButton->setChecked(allDay);
timeStuffDisable(allDay);
mFreeTimeCombo->setCurrentItem( 0 );
setDateTimes(from,to);
}
void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl )
{
QString tmpStr;
mTemplate = tmpl;
// the rest is for the events only
mNoTimeButton->setChecked(event->doesFloat());
timeStuffDisable(event->doesFloat());
setDateTimes(event->dtStart(),event->dtEnd());
mTemplate = false;
switch( event->transparency() ) {
case Event::Transparent:
mFreeTimeCombo->setCurrentItem(1);
break;
case Event::Opaque:
mFreeTimeCombo->setCurrentItem(0);
break;
}
mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
mLocationEdit->load(KOLocationBox::LOCATION);
readIncidence(event);
}
void KOEditorGeneralEvent::writeEvent(Event *event)
{
// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl;
writeIncidence(event);
QDate tmpDate;
QTime tmpTime;
QDateTime tmpDT;
// temp. until something better happens.
QString tmpStr;
if (mNoTimeButton->isChecked()) {
event->setFloats(true);
// need to change this.
tmpDate = mStartDateEdit->date();
tmpTime.setHMS(0,0,0);
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
event->setDtStart(tmpDT);
tmpDate = mEndDateEdit->date();
tmpTime.setHMS(0,0,0);
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
event->setDtEnd(tmpDT);
} else {
event->setFloats(false);
// set date/time end
tmpDate = mEndDateEdit->date();
tmpTime = mEndTimeEdit->getTime();
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
event->setDtEnd(tmpDT);
// set date/time start
tmpDate = mStartDateEdit->date();
tmpTime = mStartTimeEdit->getTime();
diff --git a/korganizer/koeditorgeneralevent.h b/korganizer/koeditorgeneralevent.h
index 9649806..d798905 100644
--- a/korganizer/koeditorgeneralevent.h
+++ b/korganizer/koeditorgeneralevent.h
@@ -1,111 +1,110 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef _KOEDITORGENERALEVENT_H
#define _KOEDITORGENERALEVENT_H
#include <qframe.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qmultilineedit.h>
#include <qlistview.h>
#include <qradiobutton.h>
#include <krestrictedline.h>
#include "koeditorgeneral.h"
#include "ktimeedit.h"
class KDateEdit;
using namespace KCal;
class KOEditorGeneralEvent : public KOEditorGeneral
{
Q_OBJECT
public:
KOEditorGeneralEvent (QObject* parent=0,const char* name=0);
virtual ~KOEditorGeneralEvent();
void initTime(QWidget *,QBoxLayout *);
void initClass(QWidget *,QBoxLayout *);
void finishSetup();
/** Set widgets to default values */
void setDefaults(QDateTime from,QDateTime to,bool allDay);
/**
Read event object and setup widgets accordingly. If templ is true, the
event is read as template, i.e. the time and date information isn't set.
*/
void readEvent( Event *, bool tmpl = false );
/** Write event settings to event object */
void writeEvent(Event *);
/** Check if the input is valid. */
bool validateInput();
public slots:
void setDateTimes(QDateTime start, QDateTime end);
void setDuration();
protected slots:
void timeStuffDisable(bool disable);
void dontAssociateTime(bool noTime);
void startTimeChanged(QTime);
void startDateChanged(QDate);
void endTimeChanged(QTime);
void endDateChanged(QDate);
void emitDateTimeStr();
void sTimeChanged(QTime);
void eTimeChanged(QTime);
signals:
- void dateTimesChanged(QDateTime start,QDateTime end);
void allDayChanged(bool);
void dateTimeStrChanged(const QString &);
private:
bool mTemplate;
QLabel *mStartDateLabel;
QLabel *mEndDateLabel;
KDateEdit *mStartDateEdit;
KDateEdit *mEndDateEdit;
KOTimeEdit *mStartTimeEdit;
KOTimeEdit *mEndTimeEdit;
QLabel *mDurationLabel;
QCheckBox *mNoTimeButton;
QComboBox *mFreeTimeCombo;
// current start and end date and time
QDateTime mCurrStartDateTime;
QDateTime mCurrEndDateTime;
};
#endif
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index e86b4d0..0a734ee 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -34,193 +34,194 @@
#include <kglobal.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kdebug.h>
#include <krestrictedline.h>
#include <kstandarddirs.h>
#include <kfiledialog.h>
#include <kdialog.h>
#include <libkcal/todo.h>
#include <libkdepim/kdateedit.h>
#include "koprefs.h"
#include "ktimeedit.h"
#include "koeditorgeneraltodo.h"
#include "kolocationbox.h"
KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent,
const char* name)
: KOEditorGeneral( parent, name)
{
}
KOEditorGeneralTodo::~KOEditorGeneralTodo()
{
}
void KOEditorGeneralTodo::finishSetup()
{
// QWidget::setTabOrder(mSummaryEdit, mLocationEdit);
// QWidget::setTabOrder(mLocationEdit, mDueCheck);
// QWidget::setTabOrder(mDueCheck, mDueDateEdit);
// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit);
// QWidget::setTabOrder(mDueTimeEdit, mStartCheck);
// QWidget::setTabOrder(mStartCheck, mStartDateEdit);
// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit);
// QWidget::setTabOrder(mStartTimeEdit, mTimeButton);
// QWidget::setTabOrder(mTimeButton, mCompletedCombo);
// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo);
// QWidget::setTabOrder(mPriorityCombo, mAlarmButton);
// QWidget::setTabOrder(mAlarmButton, mCategoriesButton);
// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo);
// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit);
mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
mSummaryEdit->setFocus();
}
void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout)
{
QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
i18n("Date && Time"),parent);
timeLayout->addWidget(timeGroupBox);
timeGroupBox->layout()->setSpacing( KDialog::spacingHintSmall() );
timeGroupBox->layout()->setMargin( KDialog::marginHint() );
QFrame *timeBoxFrame = new QFrame(timeGroupBox);
QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3);
layoutTimeBox->setSpacing(KDialog::spacingHintSmall());
layoutTimeBox->setColStretch( 1, 1 );
mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame);
layoutTimeBox->addWidget(mDueCheck,1,0);
connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool)));
connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm()));
mDueDateEdit = new KDateEdit(timeBoxFrame);
layoutTimeBox->addWidget(mDueDateEdit,1,1);
mDueTimeEdit = new KOTimeEdit(timeBoxFrame);
layoutTimeBox->addWidget(mDueTimeEdit,1,2);
mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame);
layoutTimeBox->addWidget(mStartCheck,0,0);
connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool)));
mStartDateEdit = new KDateEdit(timeBoxFrame);
layoutTimeBox->addWidget(mStartDateEdit,0,1);
mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
layoutTimeBox->addWidget(mStartTimeEdit,0,2);
mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame);
layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1);
connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool)));
connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime)));
connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime)));
-
+ connect(mStartDateEdit, SIGNAL(dateChanged(QDate)),
+ this, SLOT(startDateChanged(QDate)));
// some more layouting
//layoutTimeBox->setColStretch(3,1);
}
void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout)
{
mCompletedCombo = new QComboBox(parent);
// xgettext:no-c-format
mCompletedCombo->insertItem(i18n(" 0 %"));
// xgettext:no-c-format
mCompletedCombo->insertItem(i18n(" 20 %"));
// xgettext:no-c-format
mCompletedCombo->insertItem(i18n(" 40 %"));
// xgettext:no-c-format
mCompletedCombo->insertItem(i18n(" 60 %"));
// xgettext:no-c-format
mCompletedCombo->insertItem(i18n(" 80 %"));
// xgettext:no-c-format
mCompletedCombo->insertItem(i18n("100 %"));
connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int)));
topLayout->addWidget(mCompletedCombo);
mCompletedLabel = new QLabel(i18n("completed"),parent);
topLayout->addWidget(mCompletedLabel);
mCompleteDateEdit = new KDateEdit(parent);
topLayout->addWidget(mCompleteDateEdit );
mCompleteTimeEdit = new KOTimeEdit(parent);
topLayout->addWidget( mCompleteTimeEdit);
mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) );
mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) );
connect(mCompleteDateEdit,SIGNAL(setTimeTo(QTime)),mCompleteTimeEdit,SLOT(setTime(QTime)));
if ( QApplication::desktop()->width() <= 480 ) {
if ( QApplication::desktop()->width() < 320 )
mCompleteDateEdit->setMaximumWidth( 85 );
else
mCompleteDateEdit->setMaximumWidth( 140 );
topLayout->setSpacing( 0 );
}
}
void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout)
{
QHBox* h = new QHBox ( parent );
topLayout->addWidget( h );
QLabel *priorityLabel = new QLabel(i18n("Priority:"), h);
// topLayout->addWidget(priorityLabel);
mPriorityCombo = new QComboBox( h );
mPriorityCombo->insertItem(i18n("1 (high)"));
mPriorityCombo->insertItem(i18n("2"));
mPriorityCombo->insertItem(i18n("3"));
mPriorityCombo->insertItem(i18n("4"));
mPriorityCombo->insertItem(i18n("5 (low)"));
//topLayout->addWidget(mPriorityCombo);
}
void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout)
{
QBoxLayout *statusLayout = new QHBoxLayout(topLayout);
initCompletion( parent, statusLayout );
statusLayout->addStretch( 1 );
initPriority( parent, statusLayout );
}
void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
{
mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
mLocationEdit->load(KOLocationBox::LOCATION);
KOEditorGeneral::setDefaults(allDay);
mTimeButton->setChecked( !allDay );
if(mTimeButton->isChecked()) {
mTimeButton->setEnabled(true);
}
else {
mTimeButton->setEnabled(false);
}
enableTimeEdits( !allDay );
if ( due.isValid() ) {
mDueCheck->setChecked(true);
enableDueEdit(true);
alarmDisable(false);
} else {
mDueCheck->setChecked(false);
enableDueEdit(false);
due = QDateTime::currentDateTime().addDays(7);
@@ -302,193 +303,197 @@ void KOEditorGeneralTodo::writeTodo(Todo *todo)
todo->setHasStartDate(mStartCheck->isChecked());
QDate tmpDate;
QTime tmpTime;
QDateTime tmpDT;
if ( mTimeButton->isChecked() ) {
todo->setFloats(false);
// set due date/time
tmpDate = mDueDateEdit->date();
tmpTime = mDueTimeEdit->getTime();
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
todo->setDtDue(tmpDT);
// set start date/time
tmpDate = mStartDateEdit->date();
tmpTime = mStartTimeEdit->getTime();
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
todo->setDtStart(tmpDT);
} else {
todo->setFloats(true);
// need to change this.
tmpDate = mDueDateEdit->date();
tmpTime.setHMS(0,0,0);
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
todo->setDtDue(tmpDT);
tmpDate = mStartDateEdit->date();
tmpTime.setHMS(0,0,0);
tmpDT.setDate(tmpDate);
tmpDT.setTime(tmpTime);
todo->setDtStart(tmpDT);
}
todo->setPriority(mPriorityCombo->currentItem()+1);
// set completion state
if ( mCompletedCombo->currentItem() == 5 ) {
QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() );
if ( comp.isValid () ) {
todo->setPercentComplete(100);
todo->setCompleted(comp);
} else {
todo->setPercentComplete( 100 );
if ( mCompleted.isValid() )
todo->setCompleted(mCompleted);
}
} else {
todo->setPercentComplete(mCompletedCombo->currentItem() * 20);
}
mSummaryEdit->save(KOLocationBox::SUMMARYTODO);
}
void KOEditorGeneralTodo::enableDueEdit(bool enable)
{
mDueDateEdit->setEnabled( enable );
if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
mTimeButton->setEnabled(true);
}
else {
mTimeButton->setEnabled(false);
mTimeButton->setChecked(false);
}
if (enable) {
mDueTimeEdit->setEnabled( mTimeButton->isChecked() );
} else {
mDueTimeEdit->setEnabled( false );
}
emit datesChecked();
}
void KOEditorGeneralTodo::enableStartEdit( bool enable )
{
mStartDateEdit->setEnabled( enable );
if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
mTimeButton->setEnabled(true);
}
else {
mTimeButton->setEnabled(false);
mTimeButton->setChecked(false);
}
if (enable) {
mStartTimeEdit->setEnabled( mTimeButton->isChecked() );
} else {
mStartTimeEdit->setEnabled( false );
}
emit datesChecked();
}
-
+void KOEditorGeneralTodo::startDateChanged(QDate newdate)
+{
+ if ( mDueCheck->isChecked() )
+ emit dateTimesChanged(newdate,mDueDateEdit->date());
+}
void KOEditorGeneralTodo::enableTimeEdits(bool enable)
{
if(mStartCheck->isChecked()) {
mStartTimeEdit->setEnabled( enable );
}
if(mDueCheck->isChecked()) {
mDueTimeEdit->setEnabled( enable );
}
}
void KOEditorGeneralTodo::showAlarm()
{
if ( mDueCheck->isChecked() ) {
alarmDisable(false);
}
else {
alarmDisable(true);
}
}
bool KOEditorGeneralTodo::validateInput()
{
if (mDueCheck->isChecked()) {
if (!mDueDateEdit->inputIsValid()) {
KMessageBox::sorry(0,i18n("Please specify a valid due date."));
return false;
}
}
if (mStartCheck->isChecked()) {
if (!mStartDateEdit->inputIsValid()) {
KMessageBox::sorry(0,i18n("Please specify a valid start date."));
return false;
}
}
if (mStartCheck->isChecked() && mDueCheck->isChecked()) {
QDateTime startDate;
QDateTime dueDate;
startDate.setDate(mStartDateEdit->date());
dueDate.setDate(mDueDateEdit->date());
if (mTimeButton->isChecked()) {
startDate.setTime(mStartTimeEdit->getTime());
dueDate.setTime(mDueTimeEdit->getTime());
}
if (startDate > dueDate) {
KMessageBox::sorry(0,
i18n("The start date cannot be after the due date."));
return false;
}
}
return KOEditorGeneral::validateInput();
}
void KOEditorGeneralTodo::completedChanged(int index)
{
if (index == 5) {
//get rid of milli sec
mCompleted = QDateTime::currentDateTime();
}
setCompletedDate();
}
void KOEditorGeneralTodo::setCompletedDate()
{
if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) {
if ( QApplication::desktop()->width() < 480 ) {
mCompletedLabel->setText(i18n(" on"));
}
else
mCompletedLabel->setText(i18n(" completed on "));
mCompleteDateEdit->show();
mCompleteTimeEdit->show();
mCompleteTimeEdit->setTime( mCompleted.time() );
mCompleteDateEdit->setDate( mCompleted.date() );
} else {
mCompletedLabel->setText(i18n(" completed"));
mCompleteDateEdit->hide();
mCompleteTimeEdit->hide();
}
}
void KOEditorGeneralTodo::modified (Todo* todo, int modification)
{
switch (modification) {
case KOGlobals::PRIORITY_MODIFIED:
mPriorityCombo->setCurrentItem(todo->priority()-1);
break;
case KOGlobals::COMPLETION_MODIFIED:
mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
if (todo->isCompleted() && todo->hasCompletedDate()) {
mCompleted = todo->completed();
}
setCompletedDate();
break;
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h
index b198539..2e56a7a 100644
--- a/korganizer/koeditorgeneraltodo.h
+++ b/korganizer/koeditorgeneraltodo.h
@@ -1,109 +1,110 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef _KOEDITORGENERALTODO_H
#define _KOEDITORGENERALTODO_H
#include <qframe.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qgroupbox.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qmultilineedit.h>
#include <qlistview.h>
#include <qradiobutton.h>
#include "koeditorgeneral.h"
#include "koglobals.h"
class KRestrictedLine;
class KDateEdit;
using namespace KCal;
class KOEditorGeneralTodo : public KOEditorGeneral
{
Q_OBJECT
public:
KOEditorGeneralTodo (QObject* parent=0,const char* name=0);
virtual ~KOEditorGeneralTodo();
void initTime(QWidget *, QBoxLayout *);
void initStatus(QWidget *, QBoxLayout *);
void initCompletion(QWidget *, QBoxLayout *);
void initPriority(QWidget *, QBoxLayout *);
void finishSetup();
/** Set widgets to default values */
void setDefaults(QDateTime due,bool allDay);
/** Read todo object and setup widgets accordingly */
void readTodo(Todo *);
/** Write todo settings to event object */
void writeTodo(Todo *);
/** Check if the input is valid. */
bool validateInput();
/** The todo has been modified externally */
void modified (Todo*, int);
signals:
void openCategoryDialog();
void datesChecked();
protected slots:
+ void startDateChanged(QDate newdate);
void completedChanged(int);
void enableDueEdit( bool enable );
void enableStartEdit( bool enable );
void enableTimeEdits( bool enable );
void showAlarm();
protected:
void setCompletedDate();
private:
friend class KOTodoEditor;
KDateEdit *mStartDateEdit;
KOTimeEdit *mStartTimeEdit;
KDateEdit *mCompleteDateEdit;
KOTimeEdit *mCompleteTimeEdit;
QCheckBox *mTimeButton;
QCheckBox *mDueCheck;
KDateEdit *mDueDateEdit;
KOTimeEdit *mDueTimeEdit;
QComboBox *mCompletedCombo;
QLabel *mCompletedLabel;
QLabel *mPriorityLabel;
QComboBox *mPriorityCombo;
QCheckBox *mStartCheck;
QDateTime mCompleted;
};
#endif
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index dea8981..de4e4f7 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -742,327 +742,339 @@ KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
// layoutTimeFrame->setSpacing( KDialog::spacingHint() );
mDateTimeLabel = new QLabel( mTimeGroupBox );
// mDateTimeLabel = new QLabel( timeFrame );
// layoutTimeFrame->addWidget( mDateTimeLabel );
//mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) );
//mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) );
mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this );
topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
mRecurrenceChooser = new RecurrenceChooser( mRuleBox );
connect( mRecurrenceChooser, SIGNAL( chosen( int ) ),
SLOT( showCurrentRule( int ) ) );
mRuleStack = new QWidgetStack( mRuleBox );
mDaily = new RecurDaily( mRuleStack );
mRuleStack->addWidget( mDaily, 0 );
mWeekly = new RecurWeekly( mRuleStack );
mRuleStack->addWidget( mWeekly, 0 );
mMonthly = new RecurMonthly( mRuleStack );
mRuleStack->addWidget( mMonthly, 0 );
mYearly = new RecurYearly( mRuleStack );
mRuleStack->addWidget( mYearly, 0 );
showCurrentRule( mRecurrenceChooser->type() );
mRecurrenceRangeWidget = 0;
mRecurrenceRangeDialog = new RecurrenceRangeDialog( this );
mRecurrenceRange = mRecurrenceRangeDialog;
mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."),
this );
connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
SLOT( showRecurrenceRangeDialog() ) );
mExceptionsWidget = 0;
mExceptionsDialog = new ExceptionsDialog( this );
mExceptions = mExceptionsDialog;
mExceptionsButton = new QPushButton( i18n("Exceptions..."), this );
if ( QApplication::desktop()->width() < 320 ) {
topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 );
topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 );
} else {
topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
topLayout->addWidget( mExceptionsButton, 3, 1 );
}
connect( mExceptionsButton, SIGNAL( clicked() ),
SLOT( showExceptionsDialog() ) );
}
KOEditorRecurrence::~KOEditorRecurrence()
{
}
void KOEditorRecurrence::setEnabled( bool enabled )
{
// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl;
mTimeGroupBox->setEnabled( enabled );
if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
mRuleBox->setEnabled( enabled );
}
void KOEditorRecurrence::showCurrentRule( int current )
{
switch ( current ) {
case Daily:
mRuleStack->raiseWidget( mDaily );
break;
case Weekly:
mRuleStack->raiseWidget( mWeekly );
break;
case Monthly:
mRuleStack->raiseWidget( mMonthly );
break;
default:
case Yearly:
mRuleStack->raiseWidget( mYearly );
break;
}
}
void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end )
{
// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl;
mRecurrenceRange->setDateTimes( start, end );
mExceptions->setDefaults( end );
}
-
-void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
+void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to )
+{
+ setDateTimes( from, to );
+ QBitArray days( 7 );
+ days.fill( 0 );
+ days.setBit( from.date().dayOfWeek()- 1);
+ mWeekly->setDays( days );
+ bool byPos = mMonthly->byPos();
+ if ( byPos )
+ mMonthly->setByDay( from.date().day()-1 );
+ mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 );
+ if ( ! byPos)
+ mMonthly->setByDay( from.date().day()-1 );
+
+ bool byDay = mYearly->byDay();
+ if ( ! byDay )
+ mYearly->setByDay( from.date().dayOfYear() );
+ mYearly->setByMonth( from.date().month(), from.date().day() );
+ if ( byDay )
+ mYearly->setByDay( from.date().dayOfYear() );
+}
+void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to )
{
// qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() );
- setDateTimes( from, to );
+ //setDateTimes( from, to );
bool enabled = false;
mEnabledCheck->setChecked( enabled );
setEnabled( enabled );
mExceptions->setDefaults( to );
mRecurrenceRange->setDefaults( to );
mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
showCurrentRule( mRecurrenceChooser->type() );
mDaily->setFrequency( 1 );
-
mWeekly->setFrequency( 1 );
- QBitArray days( 7 );
- days.fill( 0 );
- days.setBit( from.date().dayOfWeek()- 1);
- mWeekly->setDays( days );
mMonthly->setFrequency( 1 );
- mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 );
- mMonthly->setByDay( from.date().day()-1 );
mYearly->setFrequency( 1 );
- mYearly->setByDay( from.date().dayOfYear() );
- mYearly->setByMonth( from.date().month(), from.date().day() );
+ setDefaultsDates( from, to );
}
void KOEditorRecurrence::readEvent(Incidence *event)
{
QDateTime dtEnd;
if ( event->typeID() == eventID )
dtEnd = ((Event*)event)->dtEnd();
else
dtEnd = ((Todo*)event)->dtDue();
- setDefaults( event->dtStart(), dtEnd, true );
+ setDefaults( event->dtStart(), dtEnd );
QBitArray rDays( 7 );
QPtrList<Recurrence::rMonthPos> rmp;
QPtrList<int> rmd;
int day = 0;
int count = 0;
int month = 0;
setDateTimes( event->dtStart(), dtEnd );
Recurrence *r = event->recurrence();
int f = r->frequency();
int recurs = r->doesRecur();
mEnabledCheck->setChecked( recurs );
setEnabled( recurs );
int recurrenceType = RecurrenceChooser::Weekly;
switch ( recurs ) {
case Recurrence::rNone:
- setDefaults( event->dtStart(), dtEnd, true );
+ setDefaults( event->dtStart(), dtEnd );
break;
case Recurrence::rDaily:
recurrenceType = RecurrenceChooser::Daily;
mDaily->setFrequency( f );
break;
case Recurrence::rWeekly:
recurrenceType = RecurrenceChooser::Weekly;
mWeekly->setFrequency( f );
mWeekly->setDays( r->days() );
break;
case Recurrence::rMonthlyPos:
// we only handle one possibility in the list right now,
// so I have hardcoded calls with first(). If we make the GUI
// more extended, this can be changed.
recurrenceType = RecurrenceChooser::Monthly;
rmp = r->monthPositions();
if ( rmp.first()->negative )
count = 5 - rmp.first()->rPos - 1;
else
count = rmp.first()->rPos - 1;
day = 0;
while ( !rmp.first()->rDays.testBit( day ) ) ++day;
mMonthly->setByPos( count, day );
mMonthly->setFrequency( f );
break;
case Recurrence::rMonthlyDay:
recurrenceType = RecurrenceChooser::Monthly;
rmd = r->monthDays();
day = *rmd.first() - 1;
mMonthly->setByDay( day );
mMonthly->setFrequency( f );
break;
case Recurrence::rYearlyMonth:
{
recurrenceType = RecurrenceChooser::Yearly;
//qDebug("Recurrence::rYearlyMonth: ");
day = event->dtStart().date().day();
rmd = r->yearNums();
if ( rmd.count() > 0 )
month = *rmd.first();
else
month = event->dtStart().date().month() ;
mYearly->setByMonth( month, day );
#if 0
//qDebug("2day = %d ",day );
QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions();
int month;
if ( !monthlist.isEmpty() ) {
month = monthlist.first()->rPos ;
} else {
month = event->dtStart().date().month() ;
}
mYearly->setByMonth( day, month );
#endif
mYearly->setFrequency( f );
}
break;
case Recurrence::rYearlyDay:
//qDebug("Recurrence::rYearlyDay: ");
recurrenceType = RecurrenceChooser::Yearly;
mYearly->setByDay( event->dtStart().date().dayOfYear() );
mYearly->setFrequency( f );
break;
default:
- setDefaults( event->dtStart(), dtEnd, true );
+ setDefaults( event->dtStart(), dtEnd );
break;
}
mRecurrenceChooser->setType( recurrenceType );
showCurrentRule( recurrenceType );
mRecurrenceRange->setDateTimes( event->dtStart() );
if ( r->doesRecur() ) {
mRecurrenceRange->setDuration( r->duration() );
if ( r->duration() == 0 )
{
if ( r->endDate() < event->dtStart().date() )
mRecurrenceRange->setEndDate( event->dtStart().date() );
else
mRecurrenceRange->setEndDate( r->endDate() );
} else
mRecurrenceRange->setEndDate( event->dtStart().date() );
}
mExceptions->setDates( event->exDates() );
}
void KOEditorRecurrence::writeEvent( Incidence *event )
{
Recurrence *r = event->recurrence();
// clear out any old settings;
r->unsetRecurs();
if ( mEnabledCheck->isChecked() ) {
int duration = mRecurrenceRange->duration();
QDate endDate;
if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
int recurrenceType = mRecurrenceChooser->type();
if ( recurrenceType == RecurrenceChooser::Daily ) {
int freq = mDaily->frequency();
if ( duration != 0 ) r->setDaily( freq, duration );
else r->setDaily( freq, endDate );
} else if ( recurrenceType == RecurrenceChooser::Weekly ) {
int freq = mWeekly->frequency();
QBitArray days = mWeekly->days();
int j;
bool found = false;
for (j = 0; j < 7 ; ++j ) {
found |=days.at(j);
}
if ( !found ) {
days.setBit( event->dtStart().date().dayOfWeek()-1);
//qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1);
}
if ( duration != 0 ) r->setWeekly( freq, days, duration );
else r->setWeekly( freq, days, endDate );
} else if ( recurrenceType == RecurrenceChooser::Monthly ) {
int freq = mMonthly->frequency();
if ( mMonthly->byPos() ) {
int pos = mMonthly->count();
QBitArray days( 7 );
days.fill( false );
days.setBit( mMonthly->weekday() );
if ( duration != 0 )
r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
else
r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
r->addMonthlyPos( pos, days );
} else {
// it's by day
int day = mMonthly->day();
if ( duration != 0 ) {
r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
} else {
r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
}
r->addMonthlyDay( day );
}
} else if ( recurrenceType == RecurrenceChooser::Yearly ) {
//qDebug("RecurrenceChooser::Yearly ");
int freq = mYearly->frequency();
if ( mYearly->byDay() ) {
if ( duration != 0 ) {
r->setYearly( Recurrence::rYearlyDay, freq, duration );
} else {
r->setYearly( Recurrence::rYearlyDay, freq, endDate );
}
r->addYearlyNum( event->dtStart().date().dayOfYear() );
} else {
if ( duration != 0 ) {
r->setYearly( Recurrence::rYearlyMonth, freq, duration );
} else {
r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
}
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h
index a15afcb..f398f62 100644
--- a/korganizer/koeditorrecurrence.h
+++ b/korganizer/koeditorrecurrence.h
@@ -178,147 +178,147 @@ class ExceptionsWidget : public QWidget, public ExceptionsBase
void deleteException();
private:
KDateEdit *mExceptionDateEdit;
QListBox *mExceptionList;
DateList mExceptionDates;
};
class ExceptionsDialog : public KDialogBase, public ExceptionsBase
{
public:
ExceptionsDialog( QWidget *parent, const char *name = 0 );
void setDefaults( const QDateTime &from );
void setDates( const DateList & );
DateList dates();
private:
ExceptionsWidget *mExceptions;
};
class RecurrenceRangeBase
{
public:
virtual void setDefaults( const QDateTime &from ) = 0;
virtual void setDuration( int ) = 0;
virtual int duration() = 0;
virtual void setEndDate( const QDate & ) = 0;
virtual QDate endDate() = 0;
virtual void setDateTimes( const QDateTime &start,
const QDateTime &end = QDateTime() ) = 0;
};
class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase
{
Q_OBJECT
public:
RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 );
void setDefaults( const QDateTime &from );
void setDuration( int );
int duration();
void setEndDate( const QDate & );
QDate endDate();
void setDateTimes( const QDateTime &start,
const QDateTime &end = QDateTime() );
protected slots:
void showCurrentRange();
private:
QGroupBox *mRangeGroupBox;
QLabel *mStartDateLabel;
QRadioButton *mNoEndDateButton;
QRadioButton *mEndDurationButton;
QSpinBox *mEndDurationEdit;
QRadioButton *mEndDateButton;
KDateEdit *mEndDateEdit;
};
class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase
{
public:
RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 );
void setDefaults( const QDateTime &from );
void setDuration( int );
int duration();
void setEndDate( const QDate & );
QDate endDate();
void setDateTimes( const QDateTime &start,
const QDateTime &end = QDateTime() );
private:
RecurrenceRangeWidget *mRecurrenceRangeWidget;
};
class KOEditorRecurrence : public QWidget
{
Q_OBJECT
public:
KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 );
virtual ~KOEditorRecurrence();
enum { Daily, Weekly, Monthly, Yearly };
- /** Set widgets to default values */
- void setDefaults( QDateTime from, QDateTime to, bool allday );
/** Read event object and setup widgets accordingly */
void readEvent( Incidence * );
/** Write event settings to event object */
void writeEvent( Incidence * );
/** Check if the input is valid. */
bool validateInput();
public slots:
+ void setDefaultsDates( QDateTime from, QDateTime to );
+ void setDefaults( QDateTime from, QDateTime to );
void setEnabled( bool );
void setDateTimes( QDateTime start, QDateTime end );
void setDateTimeStr( const QString & );
signals:
void dateTimesChanged( QDateTime start, QDateTime end );
protected slots:
void showCurrentRule( int );
void showExceptionsDialog();
void showRecurrenceRangeDialog();
private:
QCheckBox *mEnabledCheck;
QGroupBox *mTimeGroupBox;
QLabel *mDateTimeLabel;
QGroupBox *mRuleBox;
QWidgetStack *mRuleStack;
RecurrenceChooser *mRecurrenceChooser;
RecurDaily *mDaily;
RecurWeekly *mWeekly;
RecurMonthly *mMonthly;
RecurYearly *mYearly;
RecurrenceRangeBase *mRecurrenceRange;
RecurrenceRangeWidget *mRecurrenceRangeWidget;
RecurrenceRangeDialog *mRecurrenceRangeDialog;
QPushButton *mRecurrenceRangeButton;
ExceptionsBase *mExceptions;
ExceptionsDialog *mExceptionsDialog;
ExceptionsWidget *mExceptionsWidget;
QPushButton *mExceptionsButton;
};
#endif
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp
index 02d4a78..75dae34 100644
--- a/korganizer/koeventeditor.cpp
+++ b/korganizer/koeventeditor.cpp
@@ -1,171 +1,171 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qtooltip.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qhbox.h>
#include <qdir.h>
#include <qlayout.h>
#include <qwidgetstack.h>
#include <qapplication.h>
#include <kiconloader.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <klocale.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include <libkcal/calendarresources.h>
#include <libkcal/resourcecalendar.h>
#include <kresources/resourceselectdialog.h>
#include <libkdepim/categoryselectdialog.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/icalformat.h>
#include "koprefs.h"
#include "koeventeditor.h"
extern int globalFlagBlockAgenda;
KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) :
KOIncidenceEditor( i18n("Edit Event"), calendar, parent )
{
mEvent = 0;
init();
if ( QApplication::desktop()->height() <= 240 )
hideButtons();
}
KOEventEditor::~KOEventEditor()
{
//emit dialogClose( mEvent );
}
void KOEventEditor::init()
{
setupGeneral();
setupAttendeesTab();
setupRecurrence();
// Propagate date time settings to recurrence tab
connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
- mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime)));
+ mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime)));
connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)),
mRecurrence,SLOT(setDateTimeStr(const QString &)));
// Category dialog
// connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
//connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)),
// mGeneral,SLOT(setCategories(const QString &)));
}
void KOEventEditor::reload()
{
if ( mEvent ) readEvent( mEvent );
}
void KOEventEditor::setSecrecy( int sec )
{
mGeneral->setSecrecy( sec );
}
void KOEventEditor::setCategories( QString s )
{
mGeneral->setCategories(s);
}
void KOEventEditor::setupGeneral()
{
mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" );
connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
if( KOPrefs::instance()->mCompactDialogs ) {
QFrame *topFrame = addPage(i18n("General"));
QBoxLayout *topLayout = new QVBoxLayout(topFrame);
topLayout->setSpacing(spacingHint()-1);
topLayout->setMargin(marginHint()-1);
mGeneral->initHeader(topFrame,topLayout);
mGeneral->initTime(topFrame,topLayout);
// QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
mGeneral->initAlarm(topFrame,topLayout);
mGeneral->enableAlarm( false );
QBoxLayout *buttonLayout;
if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 )
buttonLayout = new QVBoxLayout( topLayout );
else
buttonLayout = new QHBoxLayout( topLayout );
QHBox* buttonWidget = new QHBox (topFrame);
QIconSet icon;
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("fileexport16");
else
icon = SmallIcon("fileexport");
QPushButton * loadTemplate = new QPushButton( buttonWidget);
QPushButton * saveTemplate = new QPushButton( buttonWidget);
saveTemplate->setIconSet (icon ) ;
int size = saveTemplate->sizeHint().height();
saveTemplate->setFixedSize( size, size );
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("fileimport16");
else
icon = SmallIcon("fileimport");
loadTemplate->setIconSet (icon ) ;
loadTemplate->setFixedSize( size, size );
buttonLayout->addWidget( buttonWidget );
mGeneral->initCategories( topFrame, buttonLayout );
topLayout->addStretch( 1 );
QFrame *topFrame2 = addPage(i18n("Details"));
QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
topLayout2->setSpacing(spacingHint());
mGeneral->initClass(topFrame2,topLayout2);
mGeneral->initSecrecy( topFrame2, topLayout2 );
mGeneral->initDescription(topFrame2,topLayout2);
connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
} else {
QFrame *topFrame = addPage(i18n("General"));
QBoxLayout *topLayout = new QVBoxLayout(topFrame);
topLayout->setSpacing(spacingHint());
mGeneral->initHeader(topFrame,topLayout);
mGeneral->initTime(topFrame,topLayout);
QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
mGeneral->initAlarm(topFrame,alarmLineLayout);
mGeneral->initClass(topFrame,alarmLineLayout);
mGeneral->initDescription(topFrame,topLayout);
QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
mGeneral->initCategories( topFrame, detailsLayout );
mGeneral->initSecrecy( topFrame, detailsLayout );
}
@@ -187,192 +187,192 @@ void KOEventEditor::editEvent(Event *event, bool showDescription)
// init();
mEvent = event;
readEvent(mEvent);
if ( showDescription ) {
showPage( 1 );
mGeneral->setFocusOn( 1 );
} else {
showPage( 0 );
mGeneral->setFocusOn( 2 );
}
}
void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay )
{
// init();
mEvent = 0;
setDefaults(from,to,allDay);
}
void KOEventEditor::loadDefaults()
{
int fmt = KOPrefs::instance()->mStartTime;
QDateTime from(QDate::currentDate(), QTime(fmt,0,0));
QDateTime to(QDate::currentDate(),
QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0));
setDefaults(from,to,false);
}
bool KOEventEditor::processInput( bool emitTime )
{
if (!validateInput()) return false;
Event *event = 0;
if (mEvent) event = mEvent;
else {
event = new Event;
event->setOrganizer(KOPrefs::instance()->email());
}
writeEvent(event);
if ( emitTime ) {
globalFlagBlockAgenda = 1;
emit showAgendaView( false );
emit jumpToTime( event->dtStart().date() );
globalFlagBlockAgenda = 2;
}
if (mEvent) {
event->setRevision(event->revision()+1);
emit eventChanged(event);
} else {
mCalendar->addEvent(event);
mEvent = event;
emit eventAdded(event);
}
return true;
}
void KOEventEditor::deleteEvent()
{
kdDebug() << "Delete event" << endl;
if (mEvent) {
if (KOPrefs::instance()->mConfirm) {
switch (msgItemDelete()) {
case KMessageBox::Continue: // OK
emit eventToBeDeleted(mEvent);
emit dialogClose(mEvent);
mCalendar->deleteEvent(mEvent);
emit eventDeleted();
reject();
break;
}
}
else {
emit eventToBeDeleted(mEvent);
emit dialogClose(mEvent);
mCalendar->deleteEvent(mEvent);
emit eventDeleted();
reject();
}
} else {
reject();
}
}
void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay)
{
mGeneral->setDefaults(from,to,allDay);
mDetails->setDefaults();
- mRecurrence->setDefaults(from,to,allDay);
+ mRecurrence->setDefaults(from,to);
showPage( 0 );
mGeneral->setFocusOn( 2 );
}
void KOEventEditor::readEvent( Event *event, bool tmpl )
{
mGeneral->readEvent( event, tmpl );
mDetails->readEvent( event );
mRecurrence->readEvent( event );
// categories
//mCategoryDialog->setSelected( event->categories() );
}
void KOEventEditor::writeEvent(Event *event)
{
mGeneral->writeEvent( event );
mDetails->writeEvent( event );
if ( event->organizer() == KOPrefs::instance()->email() ) {
Event *ev = new Event( *event );
ev->registerObserver(0);
mDetails->cancelAttendeeEvent( ev );
if ( ev->attendeeCount() > 0 ) {
emit deleteAttendee( ev );
}
delete(ev);
}
mRecurrence->writeEvent(event);
}
bool KOEventEditor::validateInput()
{
if (!mGeneral->validateInput()) return false;
if (!mDetails->validateInput()) return false;
if (!mRecurrence->validateInput()) return false;
return true;
}
int KOEventEditor::msgItemDelete()
{
return KMessageBox::warningContinueCancel(this,
i18n("This item will be permanently deleted."),
i18n("KOrganizer Confirmation"),i18n("Delete"));
}
void KOEventEditor::slotLoadTemplate()
{
QString fileName =locateLocal( "templates", "events" );
QDir t_dir;
if ( !t_dir.exists(fileName) )
t_dir.mkdir ( fileName );
fileName += "/event";
fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this );
if ( fileName.length() == 0 )
return;
CalendarLocal cal;
ICalFormat format;
if ( !format.load( &cal, fileName ) ) {
KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
.arg( fileName ) );
return ;
}
QPtrList<Event> events = cal.events();
Event* event = events.first();
if ( !event ) {
KMessageBox::error( this,
i18n("Template does not contain\na valid Event."));
} else {
kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl;
readEvent( event, true );
}
}
void KOEventEditor::slotSaveTemplate()
{
QString fileName =locateLocal( "templates", "events" );
QDir t_dir;
if ( !t_dir.exists(fileName) )
t_dir.mkdir ( fileName );
fileName += "/event";
fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this );
if ( fileName.length() > 0 )
saveTemplate( fileName );
}
void KOEventEditor::saveTemplate( const QString &templateName )
{
Event *event = new Event;
writeEvent( event );
saveAsTemplate( event, templateName );
}
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 9073bca..8b90ae5 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -1,173 +1,175 @@
/*
This file is part of KOrganizer.
Copyright (c) 1997, 1998 Preston Brown
Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qtooltip.h>
#include <qframe.h>
#include <qpixmap.h>
#include <qlayout.h>
#include <qhbox.h>
#include <qdir.h>
#include <qdatetime.h>
#include <qapplication.h>
#include <qtabwidget.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kfiledialog.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <libkdepim/categoryselectdialog.h>
#include <libkcal/calendarlocal.h>
#include <libkcal/calendarresources.h>
#include <libkcal/resourcecalendar.h>
#include <libkcal/icalformat.h>
#include <kresources/resourceselectdialog.h>
#include <libkdepim/kdateedit.h>
#include "koprefs.h"
#include "kolocationbox.h"
#include "kotodoeditor.h"
extern int globalFlagBlockAgenda;
KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent )
{
mTodo = 0;
mRelatedTodo = 0;
findButton(User1)->hide();
init();
if ( QApplication::desktop()->height() <= 240 )
hideButtons();
}
KOTodoEditor::~KOTodoEditor()
{
emit dialogClose( mTodo );
}
void KOTodoEditor::init()
{
setupGeneral();
setupAttendeesTab();
setupRecurrence();
connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence()));
mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") );
+ connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
+ mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime)));
}
void KOTodoEditor::setupRecurrence()
{
QFrame *topFrame = addPage( i18n("Recurrence") );
QBoxLayout *topLayout = new QVBoxLayout( topFrame );
mRecurrence = new KOEditorRecurrence( topFrame );
topLayout->addWidget( mRecurrence );
}
void KOTodoEditor::setCategories( QString s )
{
mGeneral->setCategories(s);
}
void KOTodoEditor::setSecrecy( int sec )
{
mGeneral->setSecrecy( sec );
}
void KOTodoEditor::reload()
{
if ( mTodo ) readTodo( mTodo );
}
void KOTodoEditor::setupGeneral()
{
mGeneral = new KOEditorGeneralTodo(this);
connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
// connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
//connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
// mGeneral,SLOT(setCategories(const QString &)));
if (KOPrefs::instance()->mCompactDialogs) {
QFrame *topFrame = addPage(i18n("General"));
QBoxLayout *topLayout = new QVBoxLayout(topFrame);
if ( QApplication::desktop()->width() < 480 ) {
topLayout->setMargin(marginHintSmall());
topLayout->setSpacing(spacingHintSmall());
} else {
topLayout->setMargin(marginHint());
topLayout->setSpacing(spacingHint());
}
mGeneral->initHeader(topFrame,topLayout);
mGeneral->initTime(topFrame,topLayout);
mGeneral->initAlarm(topFrame,topLayout);
mGeneral->enableAlarm( false );
QBoxLayout *priorityLayout;
if ( QApplication::desktop()->width() < 500 )
priorityLayout = new QVBoxLayout( topLayout );
else
priorityLayout = new QHBoxLayout( topLayout );
QWidget* prioWidget = new QWidget (topFrame);
priorityLayout->addWidget( prioWidget );
QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget);
QIconSet icon;
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("fileimport16");
else
icon = SmallIcon("fileimport");
QPushButton * loadTemplate = new QPushButton( prioWidget);
loadTemplate->setIconSet (icon ) ;
int size = loadTemplate->sizeHint().height();
loadTemplate->setFixedSize( size, size );
if ( QApplication::desktop()->width() < 321 )
icon = SmallIcon("fileexport16");
else
icon = SmallIcon("fileexport");
QPushButton * saveTemplate = new QPushButton( prioWidget);
saveTemplate->setIconSet (icon ) ;
saveTemplate->setFixedSize( size, size );
priorityLayout2->addWidget(loadTemplate);
priorityLayout2->addWidget(saveTemplate);
mGeneral->initPriority(prioWidget,priorityLayout2);
mGeneral->initCategories( topFrame, priorityLayout );
topLayout->addStretch(1);
QFrame *topFrame2 = addPage(i18n("Details"));
QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
topLayout2->setMargin(marginHint());
topLayout2->setSpacing(spacingHint());
QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 );
mGeneral->initCompletion(topFrame2,completionLayout);
mGeneral->initSecrecy( topFrame2, topLayout2 );
mGeneral->initDescription(topFrame2,topLayout2);
// QHBox * hb = new QHBox ( topFrame2 );
@@ -212,218 +214,218 @@ void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
}
checkRecurrence();
}
void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
{
//init();
mTodo = 0;
setDefaults(due,relatedTodo,allDay);
}
void KOTodoEditor::loadDefaults()
{
setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
}
bool KOTodoEditor::processInput( bool emitTime )
{
if (!validateInput()) return false;
Todo *todo = 0;
if (mTodo) todo = mTodo;
else {
todo = new Todo;
todo->setOrganizer(KOPrefs::instance()->email());
}
writeTodo(todo);
if ( emitTime ) {
globalFlagBlockAgenda = 1;
emit showAgendaView( false );
if ( todo->hasDueDate() )
emit jumpToTime( todo->dtDue().date() );
globalFlagBlockAgenda = 2;
}
if (mTodo) {
todo->setRevision(todo->revision()+1);
emit todoChanged(todo);
} else {
mCalendar->addTodo(todo);
mTodo = todo;
emit todoAdded(todo);
}
return true;
}
void KOTodoEditor::deleteTodo()
{
if (mTodo) {
if (KOPrefs::instance()->mConfirm) {
switch (msgItemDelete()) {
case KMessageBox::Continue: // OK
emit todoToBeDeleted(mTodo);
emit dialogClose(mTodo);
mCalendar->deleteTodo(mTodo);
emit todoDeleted();
reject();
break;
}
}
else {
emit todoToBeDeleted(mTodo);
emit dialogClose(mTodo);
mCalendar->deleteTodo(mTodo);
emit todoDeleted();
reject();
}
} else {
reject();
}
}
void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
{
mRelatedTodo = relatedEvent;
mGeneral->setDefaults(due,allDay);
mDetails->setDefaults();
showPage( 0 );
if ( mRelatedTodo ) {
mGeneral->setCategories (mRelatedTodo->categoriesStr ());
mGeneral->setSecrecy (mRelatedTodo->secrecy ());
if ( mRelatedTodo->priority() < 3 )
mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1);
mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": ");
int len = mRelatedTodo->summary().length();
mGeneral->mSummaryEdit->lineEdit()->setFocus();
mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 );
mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 );
} else
mGeneral->setFocusOn( 2 );
tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
- mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true);
+ mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ));
}
void KOTodoEditor::checkRecurrence()
{
if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true );
if ( mTodo )
mRecurrence->readEvent( mTodo );
else {
bool time = mGeneral->mTimeButton->isChecked();
QDateTime from,to;
if ( time ) {
to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ;
from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ;
} else {
to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ;
from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ;
}
if ( to < from )
to = from;
- mRecurrence->setDefaults(from,to,!time);
+ mRecurrence->setDefaults(from,to);
}
} else {
tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
- mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true);
+ mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ));
}
}
void KOTodoEditor::readTodo(Todo *todo)
{
mGeneral->readTodo(todo);
mDetails->readEvent(todo);
mRelatedTodo = 0;//todo->relatedTo();
// categories
// mCategoryDialog->setSelected(todo->categories());
// We should handle read-only events here.
}
void KOTodoEditor::writeTodo(Todo *event)
{
bool maybeComputeRecurrenceTime = false;
if( event->hasRecurrenceID() && event->percentComplete() < 100)
maybeComputeRecurrenceTime = true;
event->setHasRecurrenceID( false );
mGeneral->writeTodo(event);
mDetails->writeEvent(event);
// set related event, i.e. parent to-do in this case.
if (mRelatedTodo) {
event->setRelatedTo(mRelatedTodo);
}
if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
mRecurrence->writeEvent(event);
if ( event->doesRecur() ) {
int addSec = -1 ;
if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 )
addSec = 1;
event->setRecurrenceID( event->dtStart().addSecs( addSec ) );
event->setRecurDates();
} else {
event->setHasRecurrenceID( false );
}
} else {
event->setHasRecurrenceID( false );
event->recurrence()->unsetRecurs();
}
}
bool KOTodoEditor::validateInput()
{
if (!mGeneral->validateInput()) return false;
if (!mDetails->validateInput()) return false;
return true;
}
int KOTodoEditor::msgItemDelete()
{
return KMessageBox::warningContinueCancel(this,
i18n("This item will be permanently deleted."),
i18n("KOrganizer Confirmation"),i18n("Delete"));
}
void KOTodoEditor::modified (int modification)
{
if (modification == KOGlobals::CATEGORY_MODIFIED ||
KOGlobals::UNKNOWN_MODIFIED == modification )
// mCategoryDialog->setSelected (mTodo->categories ());
mGeneral->modified (mTodo, modification);
}
void KOTodoEditor::slotLoadTemplate()
{
QString fileName =locateLocal( "templates", "todos" );
QDir t_dir;
if ( !t_dir.exists(fileName) )
t_dir.mkdir ( fileName );
fileName += "/todo";
fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
if ( fileName.length() == 0 )
return;
CalendarLocal cal;
ICalFormat format;
if ( !format.load( &cal, fileName ) ) {
KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
.arg( fileName ) );
return ;
}
QPtrList<Todo> todos = cal.todos();
Todo * todo = todos.first();
if ( !todo ) {
KMessageBox::error( this,
i18n("Template does not\ncontain a valid Todo."));
} else {
readTodo( todo );
}
}
void KOTodoEditor::slotSaveTemplate()