Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index 496f125..4ee5292 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp @@ -132,361 +132,368 @@ void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) mCategoriesButton = new QPushButton(parent); mCategoriesButton->setText(i18n("Categories...")); connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); categoriesLayout->addWidget(mCategoriesButton); mCategoriesLabel = new QLabel(parent); mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); categoriesLayout->addWidget(mCategoriesLabel,1); } void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) { QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); secrecyLayout->addWidget(mCancelBox); secrecyLayout->addWidget(secrecyLabel); mSecrecyCombo = new QComboBox(parent); mSecrecyCombo->insertStringList(Incidence::secrecyList()); secrecyLayout->addWidget(mSecrecyCombo); } void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) { mDescriptionEdit = new KTextEdit(parent); mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); mDescriptionEdit->append(""); mDescriptionEdit->setReadOnly(false); mDescriptionEdit->setOverwriteMode(false); mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); topLayout->addWidget(mDescriptionEdit); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); #endif } void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) { QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); //mAlarmBell = new QLabel(parent); //mAlarmBell->setPixmap(SmallIcon("bell")); //alarmLayout->addWidget(mAlarmBell); if ( QApplication::desktop()->width() < 320 ) mAlarmButton = new QCheckBox(i18n("Rem."),parent); else mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); alarmLayout->addWidget(mAlarmButton); mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; alarmLayout->addWidget(mAlarmTimeEdit); mAlarmIncrCombo = new QComboBox(false, parent); if ( QApplication::desktop()->width() < 320 ) { mAlarmIncrCombo->insertItem(i18n("min")); mAlarmIncrCombo->insertItem(i18n("hou")); mAlarmIncrCombo->insertItem(i18n("day")); mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); } else { mAlarmIncrCombo->insertItem(i18n("minute(s)")); mAlarmIncrCombo->insertItem(i18n("hour(s)")); mAlarmIncrCombo->insertItem(i18n("day(s)")); } // mAlarmIncrCombo->setMinimumHeight(20); alarmLayout->addWidget(mAlarmIncrCombo); mAlarmSoundButton = new QPushButton(parent); mAlarmSoundButton->setPixmap(SmallIcon("playsound")); mAlarmSoundButton->setToggleButton(true); QToolTip::add(mAlarmSoundButton, i18n("No sound set")); connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); alarmLayout->addWidget(mAlarmSoundButton); mAlarmProgramButton = new QPushButton(parent); mAlarmProgramButton->setPixmap(SmallIcon("run")); mAlarmProgramButton->setToggleButton(true); QToolTip::add(mAlarmProgramButton, i18n("No program set")); connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); alarmLayout->addWidget(mAlarmProgramButton); mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); // if ( KOPrefs::instance()->mCompactDialogs ) { // mAlarmSoundButton->hide(); // mAlarmProgramButton->hide(); // } } void KOEditorGeneral::pickAlarmSound() { + qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); //QString prefix = mAlarmSound; if (!mAlarmSoundButton->isOn()) { //mAlarmSound = ""; QToolTip::remove(mAlarmSoundButton); QToolTip::add(mAlarmSoundButton, i18n("No sound set")); mAlarmProgramButton->setOn(true); mAlarmSoundButton->setOn(false); + pickAlarmProgram(); } else { QString fileName(KFileDialog::getOpenFileName(mAlarmSound, i18n("*.wav|Wav Files"), 0)); if (!fileName.isEmpty()) { mAlarmSound = fileName; QToolTip::remove(mAlarmSoundButton); QString dispStr = i18n("Playing '%1'").arg(fileName); QToolTip::add(mAlarmSoundButton, dispStr); mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(true); } else { mAlarmProgramButton->setOn(true); mAlarmSoundButton->setOn(false); } } if (mAlarmProgramButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); if ( mAlarmSoundButton->isOn()) - ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + getFittingPath(mAlarmSound) ); + ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); } void KOEditorGeneral::pickAlarmProgram() { if (!mAlarmProgramButton->isOn()) { //mAlarmProgram = ""; QToolTip::remove(mAlarmProgramButton); QToolTip::add(mAlarmProgramButton, i18n("No program set")); mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(true); + pickAlarmSound(); } else { - QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); + QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); if (!fileName.isEmpty()) { mAlarmProgram = fileName; QToolTip::remove(mAlarmProgramButton); QString dispStr = i18n("Running '%1'").arg(fileName); QToolTip::add(mAlarmProgramButton, dispStr); mAlarmSoundButton->setOn(false); mAlarmProgramButton->setOn(true); } else { mAlarmProgramButton->setOn(false); mAlarmSoundButton->setOn(true); } } if (mAlarmProgramButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); if ( mAlarmSoundButton->isOn()) - ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + getFittingPath(mAlarmSound) ); + ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); } QString KOEditorGeneral::getFittingPath( const QString s ) { int maxlen = 50; if ( QApplication::desktop()->width() < 640 ) { if ( QApplication::desktop()->width() < 320 ) maxlen = 22; 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; } } if (mAlarmProgramButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); } else { - ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled for this item")); + ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); + //((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Edit item: ") + mSummaryEdit->currentText()); + } 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) { 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(""); } void KOEditorGeneral::setSecrecy( int num ) { mSecrecyCombo->setCurrentItem(num); } void KOEditorGeneral::readIncidence(Incidence *event) { + mAlarmMessage = i18n("Edit") +" "+event->summary(); 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() ) { |