-rw-r--r-- | korganizer/koeditorgeneral.h | 1 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.h | 1 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 9 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.h | 1 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 40 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.h | 4 | ||||
-rw-r--r-- | korganizer/koeventeditor.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 8 |
9 files changed, 45 insertions, 25 deletions
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h index 2069e9c..a8f6443 100644 --- a/korganizer/koeditorgeneral.h +++ b/korganizer/koeditorgeneral.h @@ -80,16 +80,17 @@ class KOEditorGeneral : public QObject 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; diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index af97ee9..3dd7f5c 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp @@ -232,17 +232,17 @@ 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) { diff --git a/korganizer/koeditorgeneralevent.h b/korganizer/koeditorgeneralevent.h index 9649806..d798905 100644 --- a/korganizer/koeditorgeneralevent.h +++ b/korganizer/koeditorgeneralevent.h @@ -82,17 +82,16 @@ class KOEditorGeneralEvent : public KOEditorGeneral 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; diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index e86b4d0..0a734ee 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp @@ -122,17 +122,18 @@ void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) 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); @@ -390,17 +391,21 @@ void KOEditorGeneralTodo::enableStartEdit( bool enable ) 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 ); } diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h index b198539..2e56a7a 100644 --- a/korganizer/koeditorgeneraltodo.h +++ b/korganizer/koeditorgeneraltodo.h @@ -70,16 +70,17 @@ class KOEditorGeneralTodo : public KOEditorGeneral /** 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: diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index dea8981..de4e4f7 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp @@ -830,58 +830,70 @@ void KOEditorRecurrence::showCurrentRule( int current ) void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) { // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; mRecurrenceRange->setDateTimes( start, end ); mExceptions->setDefaults( end ); } +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 ); -void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) + 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 ); @@ -892,17 +904,17 @@ void KOEditorRecurrence::readEvent(Incidence *event) 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 ); @@ -964,17 +976,17 @@ void KOEditorRecurrence::readEvent(Incidence *event) 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() ); diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h index a15afcb..f398f62 100644 --- a/korganizer/koeditorrecurrence.h +++ b/korganizer/koeditorrecurrence.h @@ -266,27 +266,27 @@ 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: diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp index 02d4a78..75dae34 100644 --- a/korganizer/koeventeditor.cpp +++ b/korganizer/koeventeditor.cpp @@ -67,17 +67,17 @@ 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 &))); @@ -275,17 +275,17 @@ void KOEventEditor::deleteEvent() 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 ); diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 9073bca..8b90ae5 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp @@ -70,16 +70,18 @@ KOTodoEditor::~KOTodoEditor() 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 ); @@ -300,17 +302,17 @@ void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) 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 ); @@ -321,21 +323,21 @@ void KOTodoEditor::checkRecurrence() 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 |