koeditorgeneral.cpp
00001 /* 00002 This file is part of KOrganizer. 00003 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00004 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of TQt, and distribute the resulting executable, 00022 without including the source code for TQt in the source distribution. 00023 */ 00024 00025 00026 #include <tqwidget.h> 00027 #include <tqtooltip.h> 00028 #include <tqlayout.h> 00029 #include <tqvbox.h> 00030 #include <tqhbox.h> 00031 #include <tqbuttongroup.h> 00032 #include <tqvgroupbox.h> 00033 #include <tqdatetime.h> 00034 #include <tqlineedit.h> 00035 #include <tqlabel.h> 00036 #include <tqcheckbox.h> 00037 #include <tqpushbutton.h> 00038 #include <tqcombobox.h> 00039 #include <tqspinbox.h> 00040 #include <tqwhatsthis.h> 00041 00042 #include <tdeglobal.h> 00043 #include <kdialog.h> 00044 #include <kdebug.h> 00045 #include <tdelocale.h> 00046 #include <kiconloader.h> 00047 #include <tdemessagebox.h> 00048 #include <tdefiledialog.h> 00049 #include <ksqueezedtextlabel.h> 00050 #include <kstandarddirs.h> 00051 #include <ktextedit.h> 00052 #include <krestrictedline.h> 00053 00054 #include <libkcal/todo.h> 00055 #include <libkcal/event.h> 00056 #include <libkcal/incidenceformatter.h> 00057 #include <libkcal/resourcecached.h> 00058 00059 #include <libtdepim/kdateedit.h> 00060 #include <libtdepim/categoryselectdialog.h> 00061 00062 #include "koprefs.h" 00063 #include "koglobals.h" 00064 00065 #include "koeditorgeneral.h" 00066 #include "koeditoralarms.h" 00067 #include "koeditorattachments.h" 00068 #include "koeditorgeneral.moc" 00069 #include "kohelper.h" 00070 00071 KOEditorGeneral::KOEditorGeneral( TQObject *parent, const char* name) : 00072 TQObject( parent, name ), mAttachments(0) 00073 { 00074 mType = "Event"; 00075 ResourceCached::setEditorWindowOpen(true); 00076 mAlarmList.setAutoDelete( true ); 00077 } 00078 00079 KOEditorGeneral::~KOEditorGeneral() 00080 { 00081 ResourceCached::setEditorWindowOpen(false); 00082 } 00083 00084 00085 FocusLineEdit::FocusLineEdit( TQWidget *parent ) 00086 : TQLineEdit( parent ), mSkipFirst( true ) 00087 { 00088 } 00089 00090 void FocusLineEdit::focusInEvent ( TQFocusEvent *e ) 00091 { 00092 if ( !mSkipFirst ) { 00093 emit focusReceivedSignal(); 00094 } else { 00095 mSkipFirst = false; 00096 } 00097 TQLineEdit::focusInEvent( e ); 00098 } 00099 00100 00101 void KOEditorGeneral::initHeader( TQWidget *parent,TQBoxLayout *topLayout) 00102 { 00103 TQGridLayout *headerLayout = new TQGridLayout(); 00104 headerLayout->setSpacing( topLayout->spacing() ); 00105 topLayout->addLayout( headerLayout ); 00106 00107 TQString whatsThis = i18n("Sets the Title of this event or to-do."); 00108 TQLabel *summaryLabel = new TQLabel( i18n("T&itle:"), parent ); 00109 TQWhatsThis::add( summaryLabel, whatsThis ); 00110 TQFont f = summaryLabel->font(); 00111 f.setBold( true ); 00112 summaryLabel->setFont(f); 00113 headerLayout->addWidget(summaryLabel,1,0); 00114 00115 mSummaryEdit = new FocusLineEdit( parent ); 00116 TQWhatsThis::add( mSummaryEdit, whatsThis ); 00117 connect( mSummaryEdit, TQT_SIGNAL( focusReceivedSignal() ), 00118 TQT_SIGNAL( focusReceivedSignal() ) ); 00119 headerLayout->addWidget(mSummaryEdit,1,1); 00120 summaryLabel->setBuddy( mSummaryEdit ); 00121 00122 mAttendeeSummaryLabel = new TQLabel( parent ); 00123 updateAttendeeSummary( 0 ); 00124 headerLayout->addWidget( mAttendeeSummaryLabel, 1, 2 ); 00125 00126 whatsThis = i18n("Sets where the event or to-do will take place."); 00127 TQLabel *locationLabel = new TQLabel( i18n("&Location:"), parent ); 00128 TQWhatsThis::add( locationLabel, whatsThis ); 00129 headerLayout->addWidget(locationLabel,2,0); 00130 00131 mLocationEdit = new TQLineEdit( parent ); 00132 TQWhatsThis::add( mLocationEdit, whatsThis ); 00133 headerLayout->addMultiCellWidget( mLocationEdit, 2, 2, 1, 2 ); 00134 locationLabel->setBuddy( mLocationEdit ); 00135 00136 TQBoxLayout *thirdLineLayout = new TQHBoxLayout(); 00137 headerLayout->addMultiCellLayout( thirdLineLayout, 3, 3, 0, 2 ); 00138 00139 mResourceLabel = new TQLabel( parent ); 00140 mResourceLabel->hide(); 00141 thirdLineLayout->addWidget( mResourceLabel ); 00142 00143 whatsThis = i18n("Allows you to select the categories that this event or to-do belongs to."); 00144 TQLabel *categoriesLabel = new TQLabel( i18n("Categories:"), parent ); 00145 TQWhatsThis::add( categoriesLabel, whatsThis ); 00146 thirdLineLayout->addWidget( categoriesLabel ); 00147 mCategoriesLabel = new KSqueezedTextLabel( parent ); 00148 TQWhatsThis::add( mCategoriesLabel, whatsThis ); 00149 mCategoriesLabel->setFrameStyle(TQFrame::Panel|TQFrame::Sunken); 00150 thirdLineLayout->addWidget( mCategoriesLabel ); 00151 00152 mCategoriesButton = new TQPushButton( parent ); 00153 mCategoriesButton->setText(i18n("Select...")); 00154 TQWhatsThis::add( mCategoriesButton, whatsThis ); 00155 connect(mCategoriesButton,TQT_SIGNAL(clicked()),TQT_SLOT(selectCategories())); 00156 thirdLineLayout->addWidget( mCategoriesButton ); 00157 } 00158 00159 void KOEditorGeneral::initSecrecy(TQWidget *parent, TQBoxLayout *topLayout) 00160 { 00161 TQBoxLayout *secrecyLayout = new TQHBoxLayout( topLayout ); 00162 00163 TQLabel *secrecyLabel = new TQLabel(i18n("Acc&ess:"),parent); 00164 TQString whatsThis = i18n("Sets whether the access to this event or to-do " 00165 "is restricted. Please note that KOrganizer " 00166 "currently does not use this setting, so the " 00167 "implementation of the restrictions will depend " 00168 "on the groupware server. This means that events " 00169 "or to-dos marked as private or confidential may " 00170 "be visible to others."); 00171 TQWhatsThis::add( secrecyLabel, whatsThis ); 00172 secrecyLayout->addWidget(secrecyLabel); 00173 00174 mSecrecyCombo = new TQComboBox(parent); 00175 TQWhatsThis::add( mSecrecyCombo, whatsThis ); 00176 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 00177 secrecyLayout->addWidget(mSecrecyCombo); 00178 secrecyLabel->setBuddy( mSecrecyCombo ); 00179 } 00180 00181 void KOEditorGeneral::initDescription(TQWidget *parent,TQBoxLayout *topLayout) 00182 { 00183 mDescriptionEdit = new KTextEdit(parent); 00184 TQWhatsThis::add( mDescriptionEdit, 00185 i18n("Sets the description for this event or to-do. This " 00186 "will be displayed in a reminder if one is set, " 00187 "as well as in a tooltip when you hover over the " 00188 "event.") ); 00189 mDescriptionEdit->append(""); 00190 mDescriptionEdit->setReadOnly(false); 00191 mDescriptionEdit->setOverwriteMode(false); 00192 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 00193 mDescriptionEdit->setTabChangesFocus( true );; 00194 topLayout->addWidget(mDescriptionEdit, 4); 00195 } 00196 00197 void KOEditorGeneral::initAlarm( TQWidget *parent, TQBoxLayout *topLayout ) 00198 { 00199 TQBoxLayout *alarmLayout = new TQHBoxLayout( topLayout ); 00200 00201 mAlarmButton = new TQCheckBox( parent ); 00202 TQWhatsThis::add( mAlarmButton, i18n( "Enable reminders for this event or to-do." ) ); 00203 TQToolTip::add( mAlarmButton, i18n( "Enable reminders" ) ); 00204 alarmLayout->addWidget( mAlarmButton ); 00205 00206 mAlarmAdvancedButton = new TQPushButton( parent ); 00207 mAlarmAdvancedButton->setIconSet( KOGlobals::self()->smallIconSet( "bell", 16 ) ); 00208 TQWhatsThis::add( mAlarmAdvancedButton, 00209 i18n( "Push this button to create an advanced set of reminders " 00210 "for this event or to-do." ) ); 00211 TQToolTip::add( mAlarmAdvancedButton, i18n( "Set an advanced reminder" ) ); 00212 connect( mAlarmAdvancedButton, TQT_SIGNAL(clicked()), TQT_SLOT(editAlarms()) ); 00213 alarmLayout->addWidget( mAlarmAdvancedButton ); 00214 00215 mSimpleAlarmBox = new TQHBox( parent ); 00216 alarmLayout->addWidget( mSimpleAlarmBox ); 00217 00218 TQString whatsThis, toolTip; 00219 if ( mType == "Event" ) { 00220 whatsThis = i18n( "Set the time before the event starts when the reminder will be triggered." ); 00221 toolTip = i18n( "Set the start time trigger offset" ); 00222 } else { 00223 whatsThis = i18n( "Set the time before the to-do is due when the reminder will be triggered." ); 00224 toolTip = i18n( "Set the due time trigger offset" ); 00225 } 00226 mAlarmTimeEdit = new TQSpinBox( 0, 99999, 1, mSimpleAlarmBox, "alarmTimeEdit" ); 00227 mAlarmTimeEdit->setValue( 0 ); 00228 TQWhatsThis::add( mAlarmTimeEdit, whatsThis ); 00229 TQToolTip::add( mAlarmTimeEdit, toolTip ); 00230 00231 mAlarmIncrCombo = new TQComboBox( false, mSimpleAlarmBox ); 00232 mAlarmIncrCombo->insertItem( i18n("minute(s)") ); 00233 mAlarmIncrCombo->insertItem( i18n("hour(s)") ); 00234 mAlarmIncrCombo->insertItem( i18n("day(s)") ); 00235 TQWhatsThis::add( mAlarmIncrCombo, whatsThis ); 00236 TQToolTip::add( mAlarmIncrCombo, toolTip ); 00237 00238 mAlarmInfoLabel = new TQLabel( parent ); 00239 if ( mType == "Event" ) { 00240 mAlarmInfoLabel->setText( i18n( "before the start" ) ); 00241 } else { 00242 mAlarmInfoLabel->setText( i18n( "before the due time" ) ); 00243 } 00244 alarmLayout->addWidget( mAlarmInfoLabel ); 00245 00246 mAlarmAdvancedButton->setEnabled( false ); 00247 mAlarmTimeEdit->setEnabled( false ); 00248 mAlarmIncrCombo->setEnabled( false ); 00249 mAlarmInfoLabel->setEnabled( false ); 00250 connect( mAlarmButton, TQT_SIGNAL(toggled(bool)), mAlarmAdvancedButton, TQT_SLOT(setEnabled(bool)) ); 00251 connect( mAlarmButton, TQT_SIGNAL(toggled(bool)), mAlarmTimeEdit, TQT_SLOT(setEnabled(bool)) ); 00252 connect( mAlarmButton, TQT_SIGNAL(toggled(bool)), mAlarmIncrCombo, TQT_SLOT(setEnabled(bool)) ); 00253 connect( mAlarmButton, TQT_SIGNAL(toggled(bool)), mAlarmInfoLabel, TQT_SLOT(setEnabled(bool)) ); 00254 } 00255 00256 void KOEditorGeneral::initAttachments(TQWidget *parent,TQBoxLayout *topLayout) 00257 { 00258 mAttachments = new KOEditorAttachments( KDialog::spacingHint(), parent ); 00259 connect( mAttachments, TQT_SIGNAL( openURL( const KURL & ) ) , 00260 this, TQT_SIGNAL( openURL( const KURL & ) ) ); 00261 topLayout->addWidget( mAttachments, 1 ); 00262 } 00263 00264 void KOEditorGeneral::setType( const TQCString &type ) 00265 { 00266 // must be "Event", "Todo", "Journal", etc. 00267 mType = type; 00268 } 00269 00270 void KOEditorGeneral::addAttachments( const TQStringList &attachments, 00271 const TQStringList &mimeTypes, 00272 bool inlineAttachments ) 00273 { 00274 TQStringList::ConstIterator it; 00275 uint i = 0; 00276 for ( it = attachments.begin(); it != attachments.end(); ++it, ++i ) { 00277 if ( !(*it).isEmpty() ) { 00278 TQString mimeType; 00279 if ( mimeTypes.count() > i ) { 00280 mimeType = mimeTypes[ i ]; 00281 } 00282 mAttachments->addUriAttachment( *it, mimeType, TQString(), inlineAttachments ); 00283 } 00284 } 00285 } 00286 00287 void KOEditorGeneral::selectCategories() 00288 { 00289 KPIM::CategorySelectDialog *categoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), mCategoriesButton ); 00290 KOGlobals::fitDialogToScreen( categoryDialog ); 00291 categoryDialog->setSelected( mCategories ); 00292 00293 connect(categoryDialog, TQT_SIGNAL(editCategories()), this, TQT_SIGNAL(openCategoryDialog())); 00294 connect(this, TQT_SIGNAL(updateCategoryConfig()), categoryDialog, TQT_SLOT(updateCategoryConfig())); 00295 00296 if ( categoryDialog->exec() ) { 00297 setCategories( categoryDialog->selectedCategories() ); 00298 } 00299 delete categoryDialog; 00300 } 00301 00302 00303 void KOEditorGeneral::editAlarms() 00304 { 00305 if ( mAlarmIsSimple ) { 00306 mAlarmList.clear(); 00307 Alarm *al = alarmFromSimplePage( 0 ); 00308 if ( al ) { 00309 mAlarmList.append( al ); 00310 } 00311 } 00312 00313 KOEditorAlarms *dlg = new KOEditorAlarms( mType, &mAlarmList, mAlarmAdvancedButton ); 00314 if ( dlg->exec() != KDialogBase::Cancel ) { 00315 if ( mType == "Event" ) { 00316 Event *e = new Event; 00317 Alarm::List::ConstIterator it; 00318 for( it = mAlarmList.begin(); it != mAlarmList.end(); ++it ) { 00319 Alarm *a = (*it)->clone(); 00320 a->setParent( e ); 00321 e->addAlarm( a ); 00322 } 00323 updateAlarmWidgets( e ); 00324 delete e; 00325 } else { 00326 Todo *t = new Todo; 00327 Alarm::List::ConstIterator it; 00328 for( it = mAlarmList.begin(); it != mAlarmList.end(); ++it ) { 00329 Alarm *a = (*it)->clone(); 00330 a->setParent( t ); 00331 t->addAlarm( a ); 00332 } 00333 updateAlarmWidgets( t ); 00334 delete t; 00335 } 00336 } 00337 } 00338 00339 void KOEditorGeneral::enableAlarm( bool enable ) 00340 { 00341 mAlarmAdvancedButton->setEnabled( enable ); 00342 } 00343 00344 void KOEditorGeneral::toggleAlarm( bool on ) 00345 { 00346 mAlarmButton->setChecked( on ); 00347 } 00348 00349 void KOEditorGeneral::setCategories( const TQStringList &categories ) 00350 { 00351 mCategoriesLabel->setText( categories.join(",") ); 00352 mCategories = categories; 00353 } 00354 00355 void KOEditorGeneral::setDefaults(bool /*allDay*/) 00356 { 00357 mAlarmList.clear(); 00358 updateDefaultAlarmTime(); 00359 updateAlarmWidgets( 0 ); 00360 00361 mSecrecyCombo->setCurrentItem( Incidence::SecrecyPublic ); 00362 mAttachments->setDefaults(); 00363 } 00364 00365 void KOEditorGeneral::updateDefaultAlarmTime() 00366 { 00367 int reminderTime = KOPrefs::instance()->mReminderTime; 00368 int index = KOPrefs::instance()->mReminderTimeUnits; 00369 if ( index < 0 || index > 2 ) { 00370 index = 0; 00371 } 00372 mAlarmTimeEdit->setValue( reminderTime ); 00373 mAlarmIncrCombo->setCurrentItem( index ); 00374 } 00375 00376 bool KOEditorGeneral::isSimpleAlarm( Alarm *alarm ) const 00377 { 00378 // Check if its the trivial type of alarm, which can be 00379 // configured with a simply spin box... 00380 00381 bool simple = false; 00382 if ( alarm->type() == Alarm::Display && alarm->text().isEmpty() && 00383 alarm->repeatCount() == 0 && !alarm->hasTime() ) { 00384 if ( mType == "Event" && 00385 alarm->hasStartOffset() && alarm->startOffset().asSeconds() <= 0 ) { 00386 simple = true; 00387 } 00388 if ( mType == "Todo" && 00389 alarm->hasEndOffset() && alarm->endOffset().asSeconds() <= 0 ) { 00390 simple = true; 00391 } 00392 } 00393 return simple; 00394 } 00395 00396 static TQString etc = i18n( "elipsis", "..." ); 00397 void KOEditorGeneral::updateAlarmWidgets( Incidence *incidence ) 00398 { 00399 uint maxLen = 75; //TODO: compute from the font and dialog width 00400 00401 if ( incidence ) { 00402 mAlarmButton->setChecked( incidence->isAlarmEnabled() ); 00403 } 00404 00405 if ( mAlarmList.isEmpty() ) { 00406 mAlarmIsSimple = true; 00407 mSimpleAlarmBox->show(); 00408 bool on; 00409 if ( mType == "Event" ) { 00410 on = KOPrefs::instance()->defaultEventReminders(); 00411 } else if ( mType == "Todo" ) { 00412 on = KOPrefs::instance()->defaultTodoReminders(); 00413 } else { 00414 on = false; 00415 } 00416 mAlarmButton->setChecked( on ); 00417 mAlarmAdvancedButton->setEnabled( on ); 00418 } else if ( mAlarmList.count() > 1 ) { 00419 mAlarmIsSimple = false; 00420 mAlarmAdvancedButton->setEnabled( true ); 00421 mSimpleAlarmBox->hide(); 00422 if ( incidence ) { 00423 TQString remStr = IncidenceFormatter::reminderStringList( incidence ).join( ", " ); 00424 if ( remStr.length() > maxLen ) { 00425 maxLen -= etc.length(); 00426 remStr = remStr.left( maxLen ); 00427 remStr += etc; 00428 } 00429 mAlarmInfoLabel->setText( i18n( "Triggers %1" ).arg( remStr ) ); 00430 } 00431 } else { // alarm count is 1 00432 Alarm *alarm = mAlarmList.first(); 00433 if ( isSimpleAlarm( alarm ) ) { 00434 mAlarmIsSimple = true; 00435 mSimpleAlarmBox->show(); 00436 int offset; 00437 if ( mType == "Event" ) { 00438 offset = alarm->startOffset().asSeconds(); 00439 mAlarmInfoLabel->setText( i18n( "before the start" ) ); 00440 } 00441 if ( mType == "Todo" ) { 00442 if ( alarm->hasStartOffset() ) { 00443 offset = alarm->startOffset().asSeconds(); 00444 mAlarmInfoLabel->setText( i18n( "before the start" ) ); 00445 } else { 00446 offset = alarm->endOffset().asSeconds(); 00447 mAlarmInfoLabel->setText( i18n( "before the due time" ) ); 00448 } 00449 } 00450 offset = offset / -60; // make minutes 00451 int useoffset = offset; 00452 if ( offset == 0 ) { 00453 mAlarmIncrCombo->setCurrentItem( 0 ); // use minute units for 0 offset 00454 } else if (offset % (24*60) == 0) { // divides evenly into days? 00455 useoffset = offset / (24*60); 00456 mAlarmIncrCombo->setCurrentItem(2); 00457 } else if (offset % 60 == 0) { // divides evenly into hours? 00458 useoffset = offset / 60; 00459 mAlarmIncrCombo->setCurrentItem(1); 00460 } 00461 mAlarmTimeEdit->setValue( useoffset ); 00462 } else { 00463 mAlarmIsSimple = false; 00464 mAlarmAdvancedButton->setEnabled( true ); 00465 mSimpleAlarmBox->hide(); 00466 if ( incidence ) { 00467 TQString remStr = IncidenceFormatter::reminderStringList( incidence ).first(); 00468 mAlarmInfoLabel->setText( i18n( "Triggers %1" ).arg( remStr ) ); 00469 } 00470 } 00471 } 00472 } 00473 00474 void KOEditorGeneral::readIncidence( Incidence *incidence, Calendar *calendar ) 00475 { 00476 mSummaryEdit->setText( incidence->summary() ); 00477 mLocationEdit->setText( incidence->location() ); 00478 mDescriptionEdit->setText( incidence->description() ); 00479 00480 mSecrecyCombo->setCurrentItem( incidence->secrecy() ); 00481 00482 // set up alarm stuff 00483 mAlarmList.clear(); 00484 Alarm::List::ConstIterator it; 00485 Alarm::List alarms = incidence->alarms(); 00486 for( it = alarms.begin(); it != alarms.end(); ++it ) { 00487 Alarm *al = new Alarm( *(*it) ); 00488 al->setParent( 0 ); 00489 mAlarmList.append( al ); 00490 } 00491 updateDefaultAlarmTime(); 00492 updateAlarmWidgets( incidence ); 00493 00494 setCategories( incidence->categories() ); 00495 00496 mAttachments->readIncidence( incidence ); 00497 00498 TQString resLabel = IncidenceFormatter::resourceString( calendar, incidence ); 00499 if ( !resLabel.isEmpty() ) { 00500 mResourceLabel->setText( i18n( "Calendar: %1" ).arg( resLabel ) ); 00501 mResourceLabel->show(); 00502 } 00503 } 00504 00505 Alarm *KOEditorGeneral::alarmFromSimplePage( Incidence *incidence ) const 00506 { 00507 if ( mAlarmButton->isChecked() ) { 00508 Alarm *alarm = new Alarm( 0 ); 00509 alarm->setDisplayAlarm( "" ); 00510 alarm->setEnabled(true); 00511 TQString tmpStr = mAlarmTimeEdit->text(); 00512 int j = mAlarmTimeEdit->value() * -60; 00513 if ( mAlarmIncrCombo->currentItem() == 1 ) { 00514 j = j * 60; 00515 } else if ( mAlarmIncrCombo->currentItem() == 2 ) { 00516 j = j * (60 * 24); 00517 } 00518 if ( mType == "Event" ) { 00519 alarm->setStartOffset( j ); 00520 } 00521 if ( mType == "Todo" ) { 00522 Todo *todo = static_cast<Todo *>( incidence ); 00523 if ( todo && todo->hasStartDate() && !todo->hasDueDate() ) { 00524 alarm->setStartOffset( j ); 00525 } else { 00526 alarm->setEndOffset( j ); 00527 } 00528 } 00529 return alarm; 00530 } else { 00531 return 0; 00532 } 00533 } 00534 void KOEditorGeneral::writeIncidence( Incidence *incidence ) 00535 { 00536 incidence->setSummary(mSummaryEdit->text()); 00537 incidence->setLocation(mLocationEdit->text()); 00538 incidence->setDescription(mDescriptionEdit->text()); 00539 incidence->setCategories(mCategories); 00540 incidence->setSecrecy(mSecrecyCombo->currentItem()); 00541 00542 // alarm stuff 00543 incidence->clearAlarms(); 00544 if ( mAlarmIsSimple ) { 00545 Alarm *al = alarmFromSimplePage( incidence ); 00546 if ( al ) { 00547 al->setParent( incidence ); 00548 al->setEnabled( mAlarmButton->isChecked() ); 00549 incidence->addAlarm( al ); 00550 } 00551 } else { 00552 // simply assign the list of alarms 00553 Alarm::List::ConstIterator it; 00554 for( it = mAlarmList.begin(); it != mAlarmList.end(); ++it ) { 00555 Alarm *al = new Alarm( *(*it) ); 00556 al->setParent( incidence ); 00557 al->setEnabled( mAlarmButton->isChecked() ); 00558 incidence->addAlarm( al ); 00559 } 00560 } 00561 mAttachments->writeIncidence( incidence ); 00562 } 00563 00564 void KOEditorGeneral::setSummary( const TQString &text ) 00565 { 00566 mSummaryEdit->setText( text ); 00567 } 00568 00569 void KOEditorGeneral::setDescription( const TQString &text ) 00570 { 00571 mDescriptionEdit->setText( text ); 00572 } 00573 00574 TQObject *KOEditorGeneral::typeAheadReceiver() const 00575 { 00576 return TQT_TQOBJECT(mSummaryEdit); 00577 } 00578 00579 void KOEditorGeneral::updateAttendeeSummary(int count) 00580 { 00581 if ( count <= 0 ) 00582 mAttendeeSummaryLabel->setText( i18n("No attendees") ); 00583 else 00584 mAttendeeSummaryLabel->setText( i18n( "One attendee", "%n attendees", count ) ); 00585 }