summaryrefslogtreecommitdiffstats
path: root/korganizer/koeditorgeneral.cpp
blob: 8e4cb166cec701ea1fb37a7079d09370b7bfb06c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
/*
    This file is part of KOrganizer.
    Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
    Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

    As a special exception, permission is given to link this program
    with any edition of TQt, and distribute the resulting executable,
    without including the source code for TQt in the source distribution.
*/


#include <tqwidget.h>
#include <tqtooltip.h>
#include <tqlayout.h>
#include <tqvbox.h>
#include <tqhbox.h>
#include <tqbuttongroup.h>
#include <tqvgroupbox.h>
#include <tqdatetime.h>
#include <tqlineedit.h>
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <tqpushbutton.h>
#include <tqcombobox.h>
#include <tqspinbox.h>
#include <tqwhatsthis.h>

#include <kglobal.h>
#include <kdialog.h>
#include <kdebug.h>
#include <klocale.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <ksqueezedtextlabel.h>
#include <kstandarddirs.h>
#include <ktextedit.h>
#include <krestrictedline.h>

#include <libkcal/todo.h>
#include <libkcal/event.h>
#include <libkcal/incidenceformatter.h>
#include <libkcal/resourcecached.h>

#include <libtdepim/kdateedit.h>
#include <libtdepim/categoryselectdialog.h>

#include "koprefs.h"
#include "koglobals.h"

#include "koeditorgeneral.h"
#include "koeditoralarms.h"
#include "koeditorattachments.h"
#include "koeditorgeneral.moc"
#include "kohelper.h"

KOEditorGeneral::KOEditorGeneral( TQObject *parent, const char* name) :
  TQObject( parent, name ), mAttachments(0)
{
  mType = "Event";
  ResourceCached::setEditorWindowOpen(true);
  mAlarmList.setAutoDelete( true );
}

KOEditorGeneral::~KOEditorGeneral()
{
  ResourceCached::setEditorWindowOpen(false);
}


FocusLineEdit::FocusLineEdit( TQWidget *parent )
  : TQLineEdit( parent ), mSkipFirst( true )
{
}

void FocusLineEdit::focusInEvent ( TQFocusEvent *e )
{
  if ( !mSkipFirst ) {
    emit focusReceivedSignal();
  } else {
    mSkipFirst = false;
  }
  TQLineEdit::focusInEvent( e );
}


void KOEditorGeneral::initHeader( TQWidget *parent,TQBoxLayout *topLayout)
{
  TQGridLayout *headerLayout = new TQGridLayout();
  headerLayout->setSpacing( topLayout->spacing() );
  topLayout->addLayout( headerLayout );

  TQString whatsThis = i18n("Sets the Title of this event or to-do.");
  TQLabel *summaryLabel = new TQLabel( i18n("T&itle:"), parent );
  TQWhatsThis::add( summaryLabel, whatsThis );
  TQFont f = summaryLabel->font();
  f.setBold( true );
  summaryLabel->setFont(f);
  headerLayout->addWidget(summaryLabel,1,0);

  mSummaryEdit = new FocusLineEdit( parent );
  TQWhatsThis::add( mSummaryEdit, whatsThis );
  connect( mSummaryEdit, TQT_SIGNAL( focusReceivedSignal() ),
           TQT_SIGNAL( focusReceivedSignal() ) );
  headerLayout->addWidget(mSummaryEdit,1,1);
  summaryLabel->setBuddy( mSummaryEdit );

  mAttendeeSummaryLabel = new TQLabel( parent );
  updateAttendeeSummary( 0 );
  headerLayout->addWidget( mAttendeeSummaryLabel, 1, 2 );

  whatsThis = i18n("Sets where the event or to-do will take place.");
  TQLabel *locationLabel = new TQLabel( i18n("&Location:"), parent );
  TQWhatsThis::add( locationLabel, whatsThis );
  headerLayout->addWidget(locationLabel,2,0);

  mLocationEdit = new TQLineEdit( parent );
  TQWhatsThis::add( mLocationEdit, whatsThis );
  headerLayout->addMultiCellWidget( mLocationEdit, 2, 2, 1, 2 );
  locationLabel->setBuddy( mLocationEdit );

  TQBoxLayout *thirdLineLayout = new TQHBoxLayout();
  headerLayout->addMultiCellLayout( thirdLineLayout, 3, 3, 0, 2 );

  mResourceLabel = new TQLabel( parent );
  mResourceLabel->hide();
  thirdLineLayout->addWidget( mResourceLabel );

  whatsThis = i18n("Allows you to select the categories that this event or to-do belongs to.");
  TQLabel *categoriesLabel = new TQLabel( i18n("Categories:"), parent );
  TQWhatsThis::add( categoriesLabel, whatsThis );
  thirdLineLayout->addWidget( categoriesLabel );
  mCategoriesLabel = new KSqueezedTextLabel( parent );
  TQWhatsThis::add( mCategoriesLabel, whatsThis );
  mCategoriesLabel->setFrameStyle(TQFrame::Panel|TQFrame::Sunken);
  thirdLineLayout->addWidget( mCategoriesLabel );

  mCategoriesButton = new TQPushButton( parent );
  mCategoriesButton->setText(i18n("Select..."));
  TQWhatsThis::add( mCategoriesButton, whatsThis );
  connect(mCategoriesButton,TQT_SIGNAL(clicked()),TQT_SLOT(selectCategories()));
  thirdLineLayout->addWidget( mCategoriesButton );
}

void KOEditorGeneral::initSecrecy(TQWidget *parent, TQBoxLayout *topLayout)
{
  TQBoxLayout *secrecyLayout = new TQHBoxLayout( topLayout );

  TQLabel *secrecyLabel = new TQLabel(i18n("Acc&ess:"),parent);
  TQString whatsThis = i18n("Sets whether the access to this event or to-do "
  			   "is restricted. Please note that KOrganizer "
			   "currently does not use this setting, so the "
			   "implementation of the restrictions will depend "
			   "on the groupware server. This means that events "
			   "or to-dos marked as private or confidential may "
			   "be visible to others.");
  TQWhatsThis::add( secrecyLabel, whatsThis );
  secrecyLayout->addWidget(secrecyLabel);

  mSecrecyCombo = new TQComboBox(parent);
  TQWhatsThis::add( mSecrecyCombo, whatsThis );
  mSecrecyCombo->insertStringList(Incidence::secrecyList());
  secrecyLayout->addWidget(mSecrecyCombo);
  secrecyLabel->setBuddy( mSecrecyCombo );
}

void KOEditorGeneral::initDescription(TQWidget *parent,TQBoxLayout *topLayout)
{
  mDescriptionEdit = new KTextEdit(parent);
  TQWhatsThis::add( mDescriptionEdit,
		   i18n("Sets the description for this event or to-do. This "
			"will be displayed in a reminder if one is set, "
			"as well as in a tooltip when you hover over the "
			"event.") );
  mDescriptionEdit->append("");
  mDescriptionEdit->setReadOnly(false);
  mDescriptionEdit->setOverwriteMode(false);
  mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
  mDescriptionEdit->setTabChangesFocus( true );;
  topLayout->addWidget(mDescriptionEdit, 4);
}

void KOEditorGeneral::initAlarm( TQWidget *parent, TQBoxLayout *topLayout )
{
  TQBoxLayout *alarmLayout = new TQHBoxLayout( topLayout );

  mAlarmButton = new TQCheckBox( parent );
  TQWhatsThis::add( mAlarmButton, i18n( "Enable reminders for this event or to-do." ) );
  TQToolTip::add( mAlarmButton, i18n( "Enable reminders" ) );
  alarmLayout->addWidget( mAlarmButton );

  mAlarmAdvancedButton = new TQPushButton( parent );
  mAlarmAdvancedButton->setIconSet( KOGlobals::self()->smallIconSet( "bell", 16 ) );
  TQWhatsThis::add( mAlarmAdvancedButton,
                   i18n( "Push this button to create an advanced set of reminders "
                         "for this event or to-do." ) );
  TQToolTip::add( mAlarmAdvancedButton, i18n( "Set an advanced reminder" ) );
  connect( mAlarmAdvancedButton, TQT_SIGNAL(clicked()), TQT_SLOT(editAlarms()) );
  alarmLayout->addWidget( mAlarmAdvancedButton );

  mSimpleAlarmBox = new TQHBox( parent );
  alarmLayout->addWidget( mSimpleAlarmBox );

  TQString whatsThis, toolTip;
  if ( mType == "Event" ) {
    whatsThis = i18n( "Set the time before the event starts when the reminder will be triggered." );
    toolTip = i18n( "Set the start time trigger offset" );
  } else {
    whatsThis = i18n( "Set the time before the to-do is due when the reminder will be triggered." );
    toolTip = i18n( "Set the due time trigger offset" );
  }
  mAlarmTimeEdit = new TQSpinBox( 0, 99999, 1, mSimpleAlarmBox, "alarmTimeEdit" );
  mAlarmTimeEdit->setValue( 0 );
  TQWhatsThis::add( mAlarmTimeEdit, whatsThis );
  TQToolTip::add( mAlarmTimeEdit, toolTip );

  mAlarmIncrCombo = new TQComboBox( false, mSimpleAlarmBox );
  mAlarmIncrCombo->insertItem( i18n("minute(s)") );
  mAlarmIncrCombo->insertItem( i18n("hour(s)") );
  mAlarmIncrCombo->insertItem( i18n("day(s)") );
  TQWhatsThis::add( mAlarmIncrCombo, whatsThis );
  TQToolTip::add( mAlarmIncrCombo, toolTip );

  mAlarmInfoLabel = new TQLabel( parent );
  if ( mType == "Event" ) {
    mAlarmInfoLabel->setText( i18n( "before the start" ) );
  } else {
    mAlarmInfoLabel->setText( i18n( "before the due time" ) );
  }
  alarmLayout->addWidget( mAlarmInfoLabel );

  mAlarmAdvancedButton->setEnabled( false );
  mAlarmTimeEdit->setEnabled( false );
  mAlarmIncrCombo->setEnabled( false );
  mAlarmInfoLabel->setEnabled( false );
  connect( mAlarmButton, TQT_SIGNAL(toggled(bool)), mAlarmAdvancedButton, TQT_SLOT(setEnabled(bool)) );
  connect( mAlarmButton, TQT_SIGNAL(toggled(bool)), mAlarmTimeEdit, TQT_SLOT(setEnabled(bool)) );
  connect( mAlarmButton, TQT_SIGNAL(toggled(bool)), mAlarmIncrCombo, TQT_SLOT(setEnabled(bool)) );
  connect( mAlarmButton, TQT_SIGNAL(toggled(bool)), mAlarmInfoLabel, TQT_SLOT(setEnabled(bool)) );
}

void KOEditorGeneral::initAttachments(TQWidget *parent,TQBoxLayout *topLayout)
{
  mAttachments = new KOEditorAttachments( KDialog::spacingHint(), parent );
  connect( mAttachments, TQT_SIGNAL( openURL( const KURL & ) ) ,
           this, TQT_SIGNAL( openURL( const KURL & ) ) );
  topLayout->addWidget( mAttachments, 1 );
}

void KOEditorGeneral::setType( const TQCString &type )
{
  // must be "Event", "Todo", "Journal", etc.
  mType = type;
}

void KOEditorGeneral::addAttachments( const TQStringList &attachments,
                                      const TQStringList &mimeTypes,
                                      bool inlineAttachments )
{
  TQStringList::ConstIterator it;
  uint i = 0;
  for ( it = attachments.begin(); it != attachments.end(); ++it, ++i ) {
    if ( !(*it).isEmpty() ) {
      TQString mimeType;
      if ( mimeTypes.count() > i ) {
        mimeType = mimeTypes[ i ];
      }
      mAttachments->addUriAttachment( *it, mimeType, TQString(), inlineAttachments );
    }
  }
}

void KOEditorGeneral::selectCategories()
{
  KPIM::CategorySelectDialog *categoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), mCategoriesButton	 );
  KOGlobals::fitDialogToScreen( categoryDialog );
  categoryDialog->setSelected( mCategories );

  connect(categoryDialog, TQT_SIGNAL(editCategories()), this, TQT_SIGNAL(openCategoryDialog()));
  connect(this, TQT_SIGNAL(updateCategoryConfig()), categoryDialog, TQT_SLOT(updateCategoryConfig()));

  if ( categoryDialog->exec() ) {
    setCategories( categoryDialog->selectedCategories() );
  }
  delete categoryDialog;
}


void KOEditorGeneral::editAlarms()
{
  if ( mAlarmIsSimple ) {
    mAlarmList.clear();
    Alarm *al = alarmFromSimplePage( 0 );
    if ( al ) {
      mAlarmList.append( al );
    }
  }

  KOEditorAlarms *dlg = new KOEditorAlarms( mType, &mAlarmList, mAlarmAdvancedButton );
  if ( dlg->exec() != KDialogBase::Cancel ) {
    if ( mType == "Event" ) {
      Event *e = new Event;
      Alarm::List::ConstIterator it;
      for( it = mAlarmList.begin(); it != mAlarmList.end(); ++it ) {
        Alarm *a = (*it)->clone();
        a->setParent( e );
        e->addAlarm( a );
      }
      updateAlarmWidgets( e );
      delete e;
    } else {
      Todo *t = new Todo;
      Alarm::List::ConstIterator it;
      for( it = mAlarmList.begin(); it != mAlarmList.end(); ++it ) {
        Alarm *a = (*it)->clone();
        a->setParent( t );
        t->addAlarm( a );
      }
      updateAlarmWidgets( t );
      delete t;
    }
  }
}

void KOEditorGeneral::enableAlarm( bool enable )
{
  mAlarmAdvancedButton->setEnabled( enable );
}

void KOEditorGeneral::toggleAlarm( bool on )
{
  mAlarmButton->setChecked( on );
}

void KOEditorGeneral::setCategories( const TQStringList &categories )
{
  mCategoriesLabel->setText( categories.join(",") );
  mCategories = categories;
}

void KOEditorGeneral::setDefaults(bool /*allDay*/)
{
  mAlarmList.clear();
  updateDefaultAlarmTime();
  updateAlarmWidgets( 0 );

  mSecrecyCombo->setCurrentItem( Incidence::SecrecyPublic );
  mAttachments->setDefaults();
}

void KOEditorGeneral::updateDefaultAlarmTime()
{
  int reminderTime = KOPrefs::instance()->mReminderTime;
  int index = KOPrefs::instance()->mReminderTimeUnits;
  if ( index < 0 || index > 2 ) {
    index = 0;
  }
  mAlarmTimeEdit->setValue( reminderTime );
  mAlarmIncrCombo->setCurrentItem( index );
}

bool KOEditorGeneral::isSimpleAlarm( Alarm *alarm ) const
{
  // Check if its the trivial type of alarm, which can be
  // configured with a simply spin box...

  bool simple = false;
  if ( alarm->type() == Alarm::Display && alarm->text().isEmpty() &&
       alarm->repeatCount() == 0 && !alarm->hasTime() ) {
    if ( mType == "Event" &&
         alarm->hasStartOffset() && alarm->startOffset().asSeconds() <= 0 ) {
      simple = true;
    }
    if ( mType == "Todo" &&
         alarm->hasEndOffset() && alarm->endOffset().asSeconds() <= 0 ) {
      simple = true;
    }
  }
  return simple;
}

static TQString etc = i18n( "elipsis", "..." );
void KOEditorGeneral::updateAlarmWidgets( Incidence *incidence )
{
  uint maxLen = 75; //TODO: compute from the font and dialog width

  if ( incidence ) {
    mAlarmButton->setChecked( incidence->isAlarmEnabled() );
  }

  if ( mAlarmList.isEmpty() ) {
    mAlarmIsSimple = true;
    mSimpleAlarmBox->show();
    bool on;
    if ( mType == "Event" ) {
      on = KOPrefs::instance()->defaultEventReminders();
    } else if ( mType == "Todo" ) {
      on = KOPrefs::instance()->defaultTodoReminders();
    } else {
      on = false;
    }
    mAlarmButton->setChecked( on );
    mAlarmAdvancedButton->setEnabled( on );
  } else if ( mAlarmList.count() > 1 ) {
    mAlarmIsSimple = false;
    mAlarmAdvancedButton->setEnabled( true );
    mSimpleAlarmBox->hide();
    if ( incidence ) {
      TQString remStr = IncidenceFormatter::reminderStringList( incidence ).join( ", " );
      if ( remStr.length() > maxLen ) {
        maxLen -= etc.length();
        remStr = remStr.left( maxLen );
        remStr += etc;
      }
      mAlarmInfoLabel->setText( i18n( "Triggers %1" ).tqarg( remStr ) );
    }
  } else {  // alarm count is 1
    Alarm *alarm = mAlarmList.first();
    if ( isSimpleAlarm( alarm ) ) {
      mAlarmIsSimple = true;
      mSimpleAlarmBox->show();
      int offset;
      if ( mType == "Event" ) {
        offset = alarm->startOffset().asSeconds();
        mAlarmInfoLabel->setText( i18n( "before the start" ) );
      }
      if ( mType == "Todo" ) {
        if ( alarm->hasStartOffset() ) {
          offset = alarm->startOffset().asSeconds();
          mAlarmInfoLabel->setText( i18n( "before the start" ) );
        } else {
          offset = alarm->endOffset().asSeconds();
          mAlarmInfoLabel->setText( i18n( "before the due time" ) );
        }
      }
      offset = offset / -60; // make minutes
      int useoffset = offset;
      if ( offset == 0 ) {
        mAlarmIncrCombo->setCurrentItem( 0 ); // use minute units for 0 offset
      } else if (offset % (24*60) == 0) { // divides evenly into days?
        useoffset = offset / (24*60);
        mAlarmIncrCombo->setCurrentItem(2);
      } else if (offset % 60 == 0) { // divides evenly into hours?
        useoffset = offset / 60;
        mAlarmIncrCombo->setCurrentItem(1);
      }
      mAlarmTimeEdit->setValue( useoffset );
    } else {
      mAlarmIsSimple = false;
      mAlarmAdvancedButton->setEnabled( true );
      mSimpleAlarmBox->hide();
      if ( incidence ) {
        TQString remStr = IncidenceFormatter::reminderStringList( incidence ).first();
        mAlarmInfoLabel->setText( i18n( "Triggers %1" ).tqarg( remStr ) );
      }
    }
  }
}

void KOEditorGeneral::readIncidence( Incidence *incidence, Calendar *calendar )
{
  mSummaryEdit->setText( incidence->summary() );
  mLocationEdit->setText( incidence->location() );
  mDescriptionEdit->setText( incidence->description() );

  mSecrecyCombo->setCurrentItem( incidence->secrecy() );

  // set up alarm stuff
  mAlarmList.clear();
  Alarm::List::ConstIterator it;
  Alarm::List alarms = incidence->alarms();
  for( it = alarms.begin(); it != alarms.end(); ++it ) {
    Alarm *al = new Alarm( *(*it) );
    al->setParent( 0 );
    mAlarmList.append( al );
  }
  updateDefaultAlarmTime();
  updateAlarmWidgets( incidence );

  setCategories( incidence->categories() );

  mAttachments->readIncidence( incidence );

  TQString resLabel = IncidenceFormatter::resourceString( calendar, incidence );
  if ( !resLabel.isEmpty() ) {
    mResourceLabel->setText( i18n( "Calendar: %1" ).tqarg( resLabel ) );
    mResourceLabel->show();
  }
}

Alarm *KOEditorGeneral::alarmFromSimplePage( Incidence *incidence ) const
{
  if ( mAlarmButton->isChecked() ) {
    Alarm *alarm = new Alarm( 0 );
    alarm->setDisplayAlarm( "" );
    alarm->setEnabled(true);
    TQString tmpStr = mAlarmTimeEdit->text();
    int j = mAlarmTimeEdit->value() * -60;
    if ( mAlarmIncrCombo->currentItem() == 1 ) {
      j = j * 60;
    } else if ( mAlarmIncrCombo->currentItem() == 2 ) {
      j = j * (60 * 24);
    }
    if ( mType == "Event" ) {
      alarm->setStartOffset( j );
    }
    if ( mType == "Todo" ) {
      Todo *todo = static_cast<Todo *>( incidence );
      if ( todo && todo->hasStartDate() && !todo->hasDueDate() ) {
        alarm->setStartOffset( j );
      } else {
        alarm->setEndOffset( j );
      }
    }
    return alarm;
  } else {
    return 0;
  }
}
void KOEditorGeneral::writeIncidence( Incidence *incidence )
{
  incidence->setSummary(mSummaryEdit->text());
  incidence->setLocation(mLocationEdit->text());
  incidence->setDescription(mDescriptionEdit->text());
  incidence->setCategories(mCategories);
  incidence->setSecrecy(mSecrecyCombo->currentItem());

  // alarm stuff
  incidence->clearAlarms();
  if ( mAlarmIsSimple ) {
    Alarm *al = alarmFromSimplePage( incidence );
    if ( al ) {
      al->setParent( incidence );
      al->setEnabled( mAlarmButton->isChecked() );
      incidence->addAlarm( al );
    }
  } else {
    // simply assign the list of alarms
    Alarm::List::ConstIterator it;
    for( it = mAlarmList.begin(); it != mAlarmList.end(); ++it ) {
      Alarm *al = new Alarm( *(*it) );
      al->setParent( incidence );
      al->setEnabled( mAlarmButton->isChecked() );
      incidence->addAlarm( al );
    }
  }
  mAttachments->writeIncidence( incidence );
}

void KOEditorGeneral::setSummary( const TQString &text )
{
  mSummaryEdit->setText( text );
}

void KOEditorGeneral::setDescription( const TQString &text )
{
  mDescriptionEdit->setText( text );
}

TQObject *KOEditorGeneral::typeAheadReceiver() const
{
  return TQT_TQOBJECT(mSummaryEdit);
}

void KOEditorGeneral::updateAttendeeSummary(int count)
{
  if ( count <= 0 )
    mAttendeeSummaryLabel->setText( i18n("No attendees") );
  else
    mAttendeeSummaryLabel->setText( i18n( "One attendee", "%n attendees", count ) );
}