Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index fd50b05..aa55d82 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp @@ -358,263 +358,257 @@ QString KOEditorGeneral::getFittingPath( const QString s ) else maxlen = 35; } if ( s.length() > maxlen ) { return "..."+s.right(maxlen -3); } return s; } void KOEditorGeneral::enableAlarmEdit(bool enable) { if ( enable ) { if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { mAlarmSoundButton->setOn( true ); if ( mAlarmSound.isEmpty() ) mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; else { if ( ! QFile::exists( mAlarmSound ) ) mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; } } } ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); mAlarmTimeEdit->setEnabled(enable); mAlarmSoundButton->setEnabled(enable); mAlarmProgramButton->setEnabled(enable); mAlarmIncrCombo->setEnabled(enable); } void KOEditorGeneral::disableAlarmEdit(bool disable) { enableAlarmEdit( !disable ); } void KOEditorGeneral::enableAlarm( bool enable ) { enableAlarmEdit( enable ); } void KOEditorGeneral::alarmDisable(bool disable) { if (!disable) { //mAlarmBell->setEnabled(true); mAlarmButton->setEnabled(true); } else { //mAlarmBell->setEnabled(false); mAlarmButton->setEnabled(false); mAlarmButton->setChecked(false); mAlarmTimeEdit->setEnabled(false); mAlarmSoundButton->setEnabled(false); mAlarmProgramButton->setEnabled(false); mAlarmIncrCombo->setEnabled(false); } } void KOEditorGeneral::setCategories(const QString &str) { QString tt = str; QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); mCategoriesLabel->setText(str); } void KOEditorGeneral::setDefaults(bool allDay) { #if 0 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); #endif mAlarmMessage = i18n("Edit new item"); enableAlarmEdit( !allDay ); // TODO: Implement a KPrefsComboItem to solve this in a clean way. int alarmTime; int a[] = { 1,5,10,15,30,60,180, 1440 }; int index = KOPrefs::instance()->mAlarmTime; if (index < 0 || index > 7) { alarmTime = 15; } else { alarmTime = a[index]; } mAlarmButton ->setChecked( false ); mAlarmTimeEdit->setValue(alarmTime); mAlarmIncrCombo->setCurrentItem(0); enableAlarmEdit( false ); //alarmDisable (false); mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); mCancelBox->setChecked( false ); mSummaryEdit->setEditText(""); mLocationEdit->setEditText(""); mDescriptionEdit->setText(""); mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; setCategories(""); fillCalCombo(); } void KOEditorGeneral::setSecrecy( int num ) { mSecrecyCombo->setCurrentItem(num); } void KOEditorGeneral::fillCalCombo( int setToID ) { mCalendarBox->clear(); KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); int std = 0; int count = 0; while ( kkf ) { if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { if ( setToID ) { if ( kkf->mCalNumber == setToID ) std = count; } else { if ( kkf->isStandard ) { std = count; } } ++count; mCalendarBox->insertItem( kkf->mName ); } kkf = KOPrefs::instance()->mCalendars.next(); } mCalendarBox->setCurrentItem( std ); if ( KOPrefs::instance()->mCalendars.count() == 1 ) mCalendarBox->hide(); else mCalendarBox->show(); } int KOEditorGeneral::getCalendarID() { - KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); - while ( kkf ) { - if ( mCalendarBox->currentText() == kkf->mName) - return kkf->mCalNumber; - kkf = KOPrefs::instance()->mCalendars.next(); - } - return 1; + return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); } void KOEditorGeneral::readIncidence(Incidence *event) { fillCalCombo( event->calID() ); mAlarmMessage = event->summary(); if ( ! event->location().isEmpty() ) mAlarmMessage += " ("+event->location()+")"; mAlarmIncrCombo->setCurrentItem(0); mSummaryEdit->setEditText(event->summary()); mLocationEdit->setEditText(event->location()); mDescriptionEdit->setText(event->description()); #if 0 // organizer information mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); #endif enableAlarmEdit( event->isAlarmEnabled() ); //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); if(!event->isAlarmEnabled()) { // TODO: Implement a KPrefsComboItem to solve this in a clean way. int alarmTime; int a[] = { 1,5,10,15,30,60,180, 1440 }; int index = KOPrefs::instance()->mAlarmTime; if (index < 0 || index > 7) { alarmTime = 15; } else { alarmTime = a[index]; } mAlarmTimeEdit->setValue(alarmTime); } mAlarmButton->setChecked( event->isAlarmEnabled() ); mSecrecyCombo->setCurrentItem(event->secrecy()); mCancelBox->setChecked( event->cancelled() ); mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(false); // set up alarm stuff QPtrList<Alarm> alarms = event->alarms(); Alarm* alarm; mAlarmIncrCombo->setCurrentItem(0); for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { int offset; if ( alarm->hasTime() ) { QDateTime t = alarm->time(); offset = event->dtStart().secsTo( t ); } else { offset = alarm->startOffset().asSeconds(); } if ( offset != 0 ) { offset = offset / -60; // make minutes if (offset % 60 == 0) { // divides evenly into hours? offset = offset / 60; mAlarmIncrCombo->setCurrentItem(1); if (offset % 24 == 0) { // divides evenly into days? offset = offset / 24; mAlarmIncrCombo->setCurrentItem(2); } } } mAlarmTimeEdit->setValue( offset ); if (alarm->type() == Alarm::Procedure) { mAlarmProgram = alarm->programFile(); mAlarmProgramButton->setOn(true); QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); QToolTip::add(mAlarmProgramButton, dispStr); } else if (alarm->type() == Alarm::Audio) { mAlarmSound = alarm->audioFile(); if ( ! QFile::exists( mAlarmSound ) ) mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; mAlarmSoundButton->setOn(true); QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); QToolTip::add(mAlarmSoundButton, dispStr); } mAlarmButton->setChecked(alarm->enabled()); enableAlarmEdit( alarm->enabled() ); //qDebug("nableAlarmEdit( alarm->enabled() )********* "); // TODO: Deal with multiple alarms break; // For now, stop after the first alarm } setCategories(event->categoriesStr()); } void KOEditorGeneral::writeIncidence(Incidence *event) { // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; mLocationEdit->save(KOLocationBox::LOCATION); event->setSummary(mSummaryEdit->currentText()); event->setLocation(mLocationEdit->currentText()); event->setDescription(mDescriptionEdit->text()); event->setCategories(mCategoriesLabel->text()); event->setSecrecy(mSecrecyCombo->currentItem()); event->setCancelled(mCancelBox->isChecked() );; // alarm stuff if (mAlarmButton->isChecked()) { if (event->alarms().count() == 0) event->newAlarm(); QPtrList<Alarm> alarms = event->alarms(); Alarm *alarm; for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { alarm->setEnabled(true); int j = mAlarmTimeEdit->value()* -60; if (mAlarmIncrCombo->currentItem() == 1) j = j * 60; else if (mAlarmIncrCombo->currentItem() == 2) j = j * (60 * 24); alarm->setStartOffset( j ); if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { alarm->setProcedureAlarm(mAlarmProgram); } else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) alarm->setAudioAlarm(mAlarmSound); else alarm->setType(Alarm::Invalid); //alarm->setAudioAlarm("default"); // TODO: Deal with multiple alarms break; // For now, stop after the first alarm } } else { Alarm* alarm = event->alarms().first(); if ( alarm ) { alarm->setEnabled(false); alarm->setType(Alarm::Invalid); |