-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 24 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.h | 1 |
2 files changed, 14 insertions, 11 deletions
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index 42c3df1..fc5be71 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp @@ -29,48 +29,49 @@ #include <qwidgetstack.h> #include <qdatetime.h> #include <kdebug.h> #include <kglobal.h> #include <klocale.h> #include <kiconloader.h> #include <kmessagebox.h> #include <kfiledialog.h> #include <kstandarddirs.h> #include <libkcal/event.h> #include <libkdepim/kdateedit.h> #include "koprefs.h" #include "koeditorgeneralevent.h" #include "kolocationbox.h" KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, const char* name) : KOEditorGeneral( parent, name) { + mTemplate = false; connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), SLOT(setDuration())); connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), SLOT(emitDateTimeStr())); } KOEditorGeneralEvent::~KOEditorGeneralEvent() { } void KOEditorGeneralEvent::finishSetup() { //disabled // QWidget::setTabOrder( mSummaryEdit, mLocationEdit ); // QWidget::setTabOrder( mLocationEdit, mStartDateEdit ); // QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit ); // QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit ); // QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit ); // QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton ); // QWidget::setTabOrder( mNoTimeButton, mAlarmButton ); // QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit ); // QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton ); // QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo ); @@ -154,55 +155,56 @@ void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) 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; - - mStartDateEdit->setDate(start.date()); + 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 ); - mEndDateEdit->setDate(end.date()); + if ( !mTemplate ) + mEndDateEdit->setDate(end.date()); mEndTimeEdit->setTime(end.time()); mCurrStartDateTime = start; mCurrEndDateTime = end; setDuration(); emitDateTimeStr(); } void KOEditorGeneralEvent::startTimeChanged(QTime newtime) { kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl; int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); mCurrStartDateTime.setTime(newtime); // adjust end time so that the event has the same duration as before. mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); mEndTimeEdit->setTime(mCurrEndDateTime.time()); mEndDateEdit->setDate(mCurrEndDateTime.date()); emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); } @@ -240,56 +242,56 @@ void KOEditorGeneralEvent::endDateChanged(QDate newdate) 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; - if ( !tmpl ) { - // the rest is for the events only - mNoTimeButton->setChecked(event->doesFloat()); - timeStuffDisable(event->doesFloat()); - - setDateTimes(event->dtStart(),event->dtEnd()); - } - + 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; diff --git a/korganizer/koeditorgeneralevent.h b/korganizer/koeditorgeneralevent.h index 188dc93..0174788 100644 --- a/korganizer/koeditorgeneralevent.h +++ b/korganizer/koeditorgeneralevent.h @@ -69,40 +69,41 @@ class KOEditorGeneralEvent : public KOEditorGeneral /** 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(); 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 |