summaryrefslogtreecommitdiffabout
path: root/korganizer/koeditorgeneral.cpp
Unidiff
Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeditorgeneral.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 92e5a0f..21f220c 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -98,97 +98,96 @@ void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
98 else 98 else
99 headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2); 99 headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2);
100 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 100 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
101 101
102 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 102 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
103 if ( QApplication::desktop()->height() < 320 ) 103 if ( QApplication::desktop()->height() < 320 )
104 headerLayout->addWidget(locationLabel,0,2); 104 headerLayout->addWidget(locationLabel,0,2);
105 else 105 else
106 headerLayout->addWidget(locationLabel,1,0); 106 headerLayout->addWidget(locationLabel,1,0);
107 107
108 mLocationEdit = new KOLocationBox(TRUE,parent,30); 108 mLocationEdit = new KOLocationBox(TRUE,parent,30);
109 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 109 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
110 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) 110 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 )
111 mLocationEdit->setMaximumHeight( hei + 6); 111 mLocationEdit->setMaximumHeight( hei + 6);
112 112
113 // mLocationEdit = new QLineEdit(parent); 113 // mLocationEdit = new QLineEdit(parent);
114 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 114 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
115 115
116 mCalendarBox = new QComboBox ( parent ); 116 mCalendarBox = new QComboBox ( parent );
117 mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 117 mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
118 if ( QApplication::desktop()->height() < 320 ) { 118 if ( QApplication::desktop()->height() < 320 ) {
119 headerLayout->addWidget(mLocationEdit,0,3); 119 headerLayout->addWidget(mLocationEdit,0,3);
120 headerLayout->addWidget(mCalendarBox,0,4); 120 headerLayout->addWidget(mCalendarBox,0,4);
121 headerLayout->setColStretch( 1, 10); 121 headerLayout->setColStretch( 1, 10);
122 headerLayout->setColStretch( 3, 10); 122 headerLayout->setColStretch( 3, 10);
123 mCalendarBox->setMaximumWidth( 64 ); 123 mCalendarBox->setMaximumWidth( 64 );
124 } 124 }
125 else { 125 else {
126 headerLayout->addWidget(mLocationEdit,1,1); 126 headerLayout->addWidget(mLocationEdit,1,1);
127 headerLayout->addWidget(mCalendarBox,1,2); 127 headerLayout->addWidget(mCalendarBox,1,2);
128 int str = 3; 128 int str = 3;
129 if ( QApplication::desktop()->width() < 640 ) { 129 if ( QApplication::desktop()->width() < 640 ) {
130 --str; 130 --str;
131 if ( QApplication::desktop()->width() < 320 ) 131 if ( QApplication::desktop()->width() < 320 )
132 --str; 132 --str;
133 } 133 }
134 headerLayout->setColStretch( 1, str); 134 headerLayout->setColStretch( 1, str);
135 headerLayout->setColStretch( 2, 1); 135 headerLayout->setColStretch( 2, 1);
136 } 136 }
137 137
138} 138}
139void KOEditorGeneral::setFocusOn( int i ) 139void KOEditorGeneral::setFocusOn( int i )
140{ 140{
141 mNextFocus = i; 141 mNextFocus = i;
142 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 142 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
143} 143}
144void KOEditorGeneral::slotSetFocusOn() 144void KOEditorGeneral::slotSetFocusOn()
145{ 145{
146 mNextFocus;
147 if ( mNextFocus == 1 ) { 146 if ( mNextFocus == 1 ) {
148 mDescriptionEdit->setFocus(); 147 mDescriptionEdit->setFocus();
149 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 148 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
150 } 149 }
151 if ( mNextFocus == 2 ) { 150 if ( mNextFocus == 2 ) {
152 mSummaryEdit->setFocus(); 151 mSummaryEdit->setFocus();
153 } 152 }
154} 153}
155void KOEditorGeneral::editCategories() 154void KOEditorGeneral::editCategories()
156{ 155{
157 // qDebug("KOEditorGeneral::editCategories() "); 156 // qDebug("KOEditorGeneral::editCategories() ");
158 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 157 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
159 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 158 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
160 //KOGlobals::fitDialogToScreen( csd ); 159 //KOGlobals::fitDialogToScreen( csd );
161 csd->setColorEnabled(); 160 csd->setColorEnabled();
162 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 161 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
163 csd->exec(); 162 csd->exec();
164 delete csd; 163 delete csd;
165} 164}
166 165
167void KOEditorGeneral::showCatPopup() 166void KOEditorGeneral::showCatPopup()
168{ 167{
169 mCatPopup->clear(); 168 mCatPopup->clear();
170 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); 169 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
171 int index = 0; 170 int index = 0;
172 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 171 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
173 it != KOPrefs::instance()->mCustomCategories.end (); 172 it != KOPrefs::instance()->mCustomCategories.end ();
174 ++it) { 173 ++it) {
175 mCatPopup->insertItem (*it, index ); 174 mCatPopup->insertItem (*it, index );
176 //mCategory[index] = *it; 175 //mCategory[index] = *it;
177 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); 176 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
178 ++index; 177 ++index;
179 } 178 }
180} 179}
181void KOEditorGeneral::selectedCatPopup( int index ) 180void KOEditorGeneral::selectedCatPopup( int index )
182{ 181{
183 QStringList categories = QStringList::split (",", mCategoriesLabel->text()); 182 QStringList categories = QStringList::split (",", mCategoriesLabel->text());
184 QString colcat = categories.first(); 183 QString colcat = categories.first();
185 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 184 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
186 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 185 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
187 else 186 else
188 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 187 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
189 categories.sort (); 188 categories.sort ();
190 if ( !colcat.isEmpty() ) { 189 if ( !colcat.isEmpty() ) {
191 if ( categories.find ( colcat ) != categories.end () ) { 190 if ( categories.find ( colcat ) != categories.end () ) {
192 categories.remove( colcat ); 191 categories.remove( colcat );
193 categories.prepend( colcat ); 192 categories.prepend( colcat );
194 } 193 }
@@ -310,97 +309,97 @@ void KOEditorGeneral::pickAlarmSound()
310 if (!fileName.isEmpty()) { 309 if (!fileName.isEmpty()) {
311 mAlarmSound = fileName; 310 mAlarmSound = fileName;
312 QToolTip::remove(mAlarmSoundButton); 311 QToolTip::remove(mAlarmSoundButton);
313 QString dispStr = i18n("Playing '%1'").arg(fileName); 312 QString dispStr = i18n("Playing '%1'").arg(fileName);
314 QToolTip::add(mAlarmSoundButton, dispStr); 313 QToolTip::add(mAlarmSoundButton, dispStr);
315 mAlarmProgramButton->setOn(false); 314 mAlarmProgramButton->setOn(false);
316 mAlarmSoundButton->setOn(true); 315 mAlarmSoundButton->setOn(true);
317 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 316 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
318 } else { 317 } else {
319 mAlarmProgramButton->setOn(oldState); 318 mAlarmProgramButton->setOn(oldState);
320 mAlarmSoundButton->setOn(!oldState); 319 mAlarmSoundButton->setOn(!oldState);
321 320
322 321
323 } 322 }
324 323
325 if (mAlarmProgramButton->isOn()) 324 if (mAlarmProgramButton->isOn())
326 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 325 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
327 if ( mAlarmSoundButton->isOn()) 326 if ( mAlarmSoundButton->isOn())
328 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 327 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
329 328
330} 329}
331 330
332void KOEditorGeneral::pickAlarmProgram() 331void KOEditorGeneral::pickAlarmProgram()
333{ 332{
334 bool oldState = mAlarmProgramButton->isOn(); 333 bool oldState = mAlarmProgramButton->isOn();
335 334
336 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 335 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
337 if (!fileName.isEmpty()) { 336 if (!fileName.isEmpty()) {
338 mAlarmProgram = fileName; 337 mAlarmProgram = fileName;
339 QToolTip::remove(mAlarmProgramButton); 338 QToolTip::remove(mAlarmProgramButton);
340 QString dispStr = i18n("Running '%1'").arg(fileName); 339 QString dispStr = i18n("Running '%1'").arg(fileName);
341 QToolTip::add(mAlarmProgramButton, dispStr); 340 QToolTip::add(mAlarmProgramButton, dispStr);
342 mAlarmSoundButton->setOn(false); 341 mAlarmSoundButton->setOn(false);
343 mAlarmProgramButton->setOn(true); 342 mAlarmProgramButton->setOn(true);
344 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 343 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
345 } else { 344 } else {
346 mAlarmProgramButton->setOn(!oldState); 345 mAlarmProgramButton->setOn(!oldState);
347 mAlarmSoundButton->setOn(oldState); 346 mAlarmSoundButton->setOn(oldState);
348 } 347 }
349 348
350 if (mAlarmProgramButton->isOn()) 349 if (mAlarmProgramButton->isOn())
351 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 350 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
352 if ( mAlarmSoundButton->isOn()) 351 if ( mAlarmSoundButton->isOn())
353 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 352 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
354 353
355} 354}
356 355
357 356
358QString KOEditorGeneral::getFittingPath( const QString s ) 357QString KOEditorGeneral::getFittingPath( const QString & s )
359{ 358{
360 int maxlen = 50; 359 int maxlen = 50;
361 if ( QApplication::desktop()->width() < 640 ) { 360 if ( QApplication::desktop()->width() < 640 ) {
362 if ( QApplication::desktop()->width() < 320 ) 361 if ( QApplication::desktop()->width() < 320 )
363 maxlen = 22; 362 maxlen = 22;
364 else 363 else
365 maxlen = 35; 364 maxlen = 35;
366 } 365 }
367 if ( s.length() > maxlen ) { 366 if ( s.length() > maxlen ) {
368 return "..."+s.right(maxlen -3); 367 return "..."+s.right(maxlen -3);
369 } 368 }
370 return s; 369 return s;
371} 370}
372 371
373void KOEditorGeneral::enableAlarmEdit(bool enable) 372void KOEditorGeneral::enableAlarmEdit(bool enable)
374{ 373{
375 if ( enable ) { 374 if ( enable ) {
376 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 375 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
377 mAlarmSoundButton->setOn( true ); 376 mAlarmSoundButton->setOn( true );
378 if ( mAlarmSound.isEmpty() ) 377 if ( mAlarmSound.isEmpty() )
379 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 378 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
380 else { 379 else {
381 if ( ! QFile::exists( mAlarmSound ) ) 380 if ( ! QFile::exists( mAlarmSound ) )
382 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 381 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
383 } 382 }
384 } 383 }
385 } 384 }
386 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 385 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
387 mAlarmTimeEdit->setEnabled(enable); 386 mAlarmTimeEdit->setEnabled(enable);
388 mAlarmSoundButton->setEnabled(enable); 387 mAlarmSoundButton->setEnabled(enable);
389 mAlarmProgramButton->setEnabled(enable); 388 mAlarmProgramButton->setEnabled(enable);
390 mAlarmIncrCombo->setEnabled(enable); 389 mAlarmIncrCombo->setEnabled(enable);
391} 390}
392 391
393void KOEditorGeneral::disableAlarmEdit(bool disable) 392void KOEditorGeneral::disableAlarmEdit(bool disable)
394{ 393{
395 enableAlarmEdit( !disable ); 394 enableAlarmEdit( !disable );
396} 395}
397 396
398void KOEditorGeneral::enableAlarm( bool enable ) 397void KOEditorGeneral::enableAlarm( bool enable )
399{ 398{
400 enableAlarmEdit( enable ); 399 enableAlarmEdit( enable );
401} 400}
402 401
403void KOEditorGeneral::alarmDisable(bool disable) 402void KOEditorGeneral::alarmDisable(bool disable)
404{ 403{
405 if (!disable) { 404 if (!disable) {
406 //mAlarmBell->setEnabled(true); 405 //mAlarmBell->setEnabled(true);
@@ -575,50 +574,52 @@ void KOEditorGeneral::readIncidence(Incidence *event)
575 } 574 }
576 575
577 setCategories(event->categoriesStr()); 576 setCategories(event->categoriesStr());
578} 577}
579 578
580void KOEditorGeneral::writeIncidence(Incidence *event) 579void KOEditorGeneral::writeIncidence(Incidence *event)
581{ 580{
582 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 581 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
583 mLocationEdit->save(KOLocationBox::LOCATION); 582 mLocationEdit->save(KOLocationBox::LOCATION);
584 event->setSummary(mSummaryEdit->currentText()); 583 event->setSummary(mSummaryEdit->currentText());
585 event->setLocation(mLocationEdit->currentText()); 584 event->setLocation(mLocationEdit->currentText());
586 event->setDescription(mDescriptionEdit->text()); 585 event->setDescription(mDescriptionEdit->text());
587 event->setCategories(mCategoriesLabel->text()); 586 event->setCategories(mCategoriesLabel->text());
588 event->setSecrecy(mSecrecyCombo->currentItem()); 587 event->setSecrecy(mSecrecyCombo->currentItem());
589 event->setCancelled(mCancelBox->isChecked() );; 588 event->setCancelled(mCancelBox->isChecked() );;
590 // alarm stuff 589 // alarm stuff
591 if (mAlarmButton->isChecked()) { 590 if (mAlarmButton->isChecked()) {
592 if (event->alarms().count() == 0) 591 if (event->alarms().count() == 0)
593 event->newAlarm(); 592 event->newAlarm();
594 QPtrList<Alarm> alarms = event->alarms(); 593 QPtrList<Alarm> alarms = event->alarms();
595 Alarm *alarm; 594 Alarm *alarm;
596 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 595 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
597 alarm->setEnabled(true); 596 alarm->setEnabled(true);
598 int j = mAlarmTimeEdit->value()* -60; 597 int j = mAlarmTimeEdit->value()* -60;
599 if (mAlarmIncrCombo->currentItem() == 1) 598 if (mAlarmIncrCombo->currentItem() == 1)
600 j = j * 60; 599 j = j * 60;
601 else if (mAlarmIncrCombo->currentItem() == 2) 600 else if (mAlarmIncrCombo->currentItem() == 2)
602 j = j * (60 * 24); 601 j = j * (60 * 24);
603 alarm->setStartOffset( j ); 602 alarm->setStartOffset( j );
604 603
605 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 604 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
606 alarm->setProcedureAlarm(mAlarmProgram); 605 alarm->setProcedureAlarm(mAlarmProgram);
607 } 606 }
608 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 607 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
609 alarm->setAudioAlarm(mAlarmSound); 608 alarm->setAudioAlarm(mAlarmSound);
610 else 609 else
611 alarm->setType(Alarm::Invalid); 610 alarm->setType(Alarm::Invalid);
612 //alarm->setAudioAlarm("default"); 611 //alarm->setAudioAlarm("default");
613 // TODO: Deal with multiple alarms 612 // TODO: Deal with multiple alarms
614 break; // For now, stop after the first alarm 613 break; // For now, stop after the first alarm
615 } 614 }
616 } else { 615 } else {
617 Alarm* alarm = event->alarms().first(); 616 Alarm* alarm = event->alarms().first();
618 if ( alarm ) { 617 if ( alarm ) {
619 alarm->setEnabled(false); 618 alarm->setEnabled(false);
620 alarm->setType(Alarm::Invalid); 619 alarm->setType(Alarm::Invalid);
621 } 620 }
622 } 621 }
623 event->setCalID( getCalendarID() ); 622 int id = getCalendarID();
623 event->setCalID( id );
624 event->setAlarmEnabled( KOPrefs::instance()->getCalendar( id )->isAlarmEnabled );
624} 625}