summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-02-13 11:55:52 (UTC)
committer zautrix <zautrix>2005-02-13 11:55:52 (UTC)
commit0a33f91e166747406ca2ccb5819881feeecfdb40 (patch) (side-by-side diff)
treee9130a16aaa6365e106d6733c3e1adeca01f72ac /korganizer
parent00ec9899a4727a4c9100d320935dde7da4803801 (diff)
downloadkdepimpi-0a33f91e166747406ca2ccb5819881feeecfdb40.zip
kdepimpi-0a33f91e166747406ca2ccb5819881feeecfdb40.tar.gz
kdepimpi-0a33f91e166747406ca2ccb5819881feeecfdb40.tar.bz2
todo recurchanges
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeditorgeneraltodo.cpp2
-rw-r--r--korganizer/koeditorgeneraltodo.h1
-rw-r--r--korganizer/koeditorrecurrence.cpp20
-rw-r--r--korganizer/koeditorrecurrence.h4
-rw-r--r--korganizer/kotodoeditor.cpp43
-rw-r--r--korganizer/kotodoeditor.h4
6 files changed, 66 insertions, 8 deletions
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index 6370b54..a9d1ed3 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -324,115 +324,117 @@ void KOEditorGeneralTodo::writeTodo(Todo *todo)
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(0);
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::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) {
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h
index 98f43dd..b198539 100644
--- a/korganizer/koeditorgeneraltodo.h
+++ b/korganizer/koeditorgeneraltodo.h
@@ -27,82 +27,83 @@
#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 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 4209e10..bedc75a 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -1,92 +1,93 @@
/*
This file is part of KOrganizer.
Copyright (c) 2000-2003 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 <qfiledialog.h>
#include <qlayout.h>
#include <qvbox.h>
#include <qbuttongroup.h>
#include <qvgroupbox.h>
#include <qwidgetstack.h>
#include <qdatetime.h>
#include <qlistbox.h>
#include <qspinbox.h>
#include <qcheckbox.h>
#include <qapplication.h>
#include <kdialog.h>
#include <kglobal.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <knumvalidator.h>
#include <libkcal/event.h>
+#include <libkcal/todo.h>
#include <libkdepim/kdateedit.h>
#include "koprefs.h"
#include "koeditorrecurrence.h"
/////////////////////////// RecurBase ///////////////////////////////
RecurBase::RecurBase( QWidget *parent, const char *name ) :
QWidget( parent, name )
{
mFrequencyEdit = new QSpinBox( 1, 9999, 1, this );
mFrequencyEdit->setValue( 1 );
}
QWidget *RecurBase::frequencyEdit()
{
return mFrequencyEdit;
}
void RecurBase::setFrequency( int f )
{
if ( f < 1 ) f = 1;
mFrequencyEdit->setValue( f );
}
int RecurBase::frequency()
{
return mFrequencyEdit->value();
}
/////////////////////////// RecurDaily ///////////////////////////////
RecurDaily::RecurDaily( QWidget *parent, const char *name ) :
RecurBase( parent, name )
{
QBoxLayout *topLayout = new QHBoxLayout( this );
topLayout->setSpacing( KDialog::spacingHint() );
QLabel *preLabel = new QLabel( i18n("Recur every"), this );
topLayout->addWidget( preLabel );
topLayout->addWidget( frequencyEdit() );
QLabel *postLabel = new QLabel( i18n("day(s)"), this );
topLayout->addWidget( postLabel );
@@ -860,216 +861,223 @@ void KOEditorRecurrence::showCurrentRule( int current )
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 )
{
// qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() );
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() );
}
-void KOEditorRecurrence::readEvent(Event *event)
+void KOEditorRecurrence::readEvent(Incidence *event)
{
- setDefaults( event->dtStart(), event->dtEnd(), true );
+
+ QDateTime dtEnd;
+ if ( event->type() == "Event" )
+ dtEnd = ((Event*)event)->dtEnd();
+ else
+ dtEnd = ((Todo*)event)->dtDue();
+
+ setDefaults( event->dtStart(), dtEnd, true );
QBitArray rDays( 7 );
QPtrList<Recurrence::rMonthPos> rmp;
QPtrList<int> rmd;
int day = 0;
int count = 0;
int month = 0;
- setDateTimes( event->dtStart(), event->dtEnd() );
+ 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(), event->dtEnd(), true );
+ setDefaults( event->dtStart(), dtEnd, true );
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(), event->dtEnd(), true );
+ setDefaults( event->dtStart(), dtEnd, true );
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( Event *event )
+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();
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h
index 2b59085..a15afcb 100644
--- a/korganizer/koeditorrecurrence.h
+++ b/korganizer/koeditorrecurrence.h
@@ -229,96 +229,96 @@ class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase
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( Event * );
+ void readEvent( Incidence * );
/** Write event settings to event object */
- void writeEvent( Event * );
+ void writeEvent( Incidence * );
/** Check if the input is valid. */
bool validateInput();
public slots:
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/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 70dfbd1..069dda8 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -1,119 +1,132 @@
/*
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();
}
KOTodoEditor::~KOTodoEditor()
{
emit dialogClose( mTodo );
}
void KOTodoEditor::init()
{
setupGeneral();
setupAttendeesTab();
+ setupRecurrence();
+ connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence()));
}
+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(1);
topLayout->setSpacing(1);
} else {
topLayout->setMargin(marginHint()-1);
topLayout->setSpacing(spacingHint()-1);
}
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);
@@ -149,211 +162,241 @@ void KOTodoEditor::setupGeneral()
QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 );
mGeneral->initCompletion(topFrame2,completionLayout);
mGeneral->initSecrecy( topFrame2, topLayout2 );
mGeneral->initDescription(topFrame2,topLayout2);
// QHBox * hb = new QHBox ( topFrame2 );
// topLayout2->addWidget(hb);
// hb->setSpacing( 3 );
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);
mGeneral->initStatus(topFrame,topLayout);
QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
mGeneral->initAlarm(topFrame,alarmLineLayout);
mGeneral->initDescription(topFrame,topLayout);
QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
mGeneral->initCategories( topFrame, detailsLayout );
mGeneral->initSecrecy( topFrame, detailsLayout );
}
mGeneral->finishSetup();
}
void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
{
//init();
mTodo = todo;
readTodo(mTodo);
if ( editDescription ) {
showPage( 1 );
mGeneral->setFocusOn( 1 );
} else {
showPage( 0 );
mGeneral->setFocusOn( 2 );
}
+ 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);
}
+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) ) ;
+ }
+ mRecurrence->setDefaults(from,to,!time);
+ }
+ } else {
+ tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
+ mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true);
+ }
+}
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)
{
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);
+ } else
+ 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."));
diff --git a/korganizer/kotodoeditor.h b/korganizer/kotodoeditor.h
index 2657bd8..1b5e3b4 100644
--- a/korganizer/kotodoeditor.h
+++ b/korganizer/kotodoeditor.h
@@ -1,102 +1,106 @@
/*
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.
*/
#ifndef _KOTODOEDITOR_H
#define _KOTODOEDITOR_H
#include <libkcal/calendar.h>
#include "koeditorgeneraltodo.h"
#include "koeditordetails.h"
#include "koincidenceeditor.h"
+#include "koeditorrecurrence.h"
class QDateTime;
/**
This class provides a dialog for editing a Todo.
*/
class KOTodoEditor : public KOIncidenceEditor
{
Q_OBJECT
public:
/**
Constructs a new todo editor.
*/
KOTodoEditor( Calendar *calendar, QWidget *parent );
virtual ~KOTodoEditor();
void init();
void reload();
void setSecrecy( int sec );
/**
Clear editor for new todo, and preset the dates and times with hint.
*/
void newTodo(QDateTime due,Todo *relatedTodo=0,bool allDay=false);
/** Edit an existing todo. */
void editTodo(Todo * ,bool editDescription = false );
/** Set widgets to default values */
void setDefaults(QDateTime due,Todo *relatedTodo,bool allDay);
/** Read event object and setup widgets accordingly */
void readTodo(Todo *);
/** Write event settings to event object */
void writeTodo(Todo *);
/** Check if the input is valid. */
bool validateInput();
/** Process user input and create or update event. Returns false if input
* is not valid */
bool processInput( bool );
/** This todo has been modified externally */
void modified (int);
void setCategories( QString s );
signals:
void todoChanged(Todo *);
void todoAdded(Todo *);
void todoToBeDeleted(Todo *);
void todoDeleted();
protected slots:
void loadDefaults();
void deleteTodo();
+ void checkRecurrence();
void slotLoadTemplate();
void slotSaveTemplate();
void saveTemplate( const QString & );
protected:
void setupGeneral();
int msgItemDelete();
+ void setupRecurrence();
private:
Todo *mTodo;
Incidence *mRelatedTodo;
KOEditorGeneralTodo *mGeneral;
+ KOEditorRecurrence *mRecurrence;
};
#endif