-rw-r--r-- | korganizer/kolistview.cpp | 79 |
1 files changed, 76 insertions, 3 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 732fc46..d4d9c0f 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -66,4 +66,6 @@ | |||
66 | 66 | ||
67 | 67 | ||
68 | |||
69 | |||
68 | class KOListViewWhatsThis :public QWhatsThis | 70 | class KOListViewWhatsThis :public QWhatsThis |
69 | { | 71 | { |
@@ -258,5 +260,5 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, | |||
258 | SLOT(allSelection()),true); | 260 | SLOT(allSelection()),true); |
259 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 261 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
260 | i18n("Deselect All"),this, | 262 | i18n("Deselect all"),this, |
261 | SLOT(clearSelection()),true); | 263 | SLOT(clearSelection()),true); |
262 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 264 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
@@ -270,5 +272,5 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, | |||
270 | i18n("Save Journal/Description..."),this, | 272 | i18n("Save Journal/Description..."),this, |
271 | SLOT(saveDescriptionToFile()),true); | 273 | SLOT(saveDescriptionToFile()),true); |
272 | mPopupMenu->insertSeparator(); | 274 | // mPopupMenu->insertSeparator(); |
273 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 275 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
274 | i18n("Add Categ. to selected..."),this, | 276 | i18n("Add Categ. to selected..."),this, |
@@ -277,8 +279,12 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, | |||
277 | i18n("Set Categ. for selected..."),this, | 279 | i18n("Set Categ. for selected..."),this, |
278 | SLOT(setCat()),true); | 280 | SLOT(setCat()),true); |
279 | mPopupMenu->insertSeparator(); | 281 | //mPopupMenu->insertSeparator(); |
282 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | ||
283 | i18n("Set alarm for selected..."),this, | ||
284 | SLOT(setAlarm()),true); | ||
280 | 285 | ||
281 | 286 | ||
282 | #ifndef DESKTOP_VERSION | 287 | #ifndef DESKTOP_VERSION |
288 | mPopupMenu->insertSeparator(); | ||
283 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 289 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
284 | i18n("Beam selected via IR"),this, | 290 | i18n("Beam selected via IR"),this, |
@@ -339,4 +345,71 @@ void KOListView::setCat() | |||
339 | setCategories( true ); | 345 | setCategories( true ); |
340 | } | 346 | } |
347 | void KOListView::setAlarm() | ||
348 | { | ||
349 | KOAlarmPrefs kap( this); | ||
350 | if ( !kap.exec() ) | ||
351 | return; | ||
352 | |||
353 | |||
354 | QStringList itemList; | ||
355 | QPtrList<KOListViewItem> sel ; | ||
356 | QListViewItem *qitem = mListView->firstChild (); | ||
357 | while ( qitem ) { | ||
358 | if ( qitem->isSelected() ) { | ||
359 | sel.append(((KOListViewItem *)qitem)); | ||
360 | } | ||
361 | qitem = qitem->nextSibling(); | ||
362 | } | ||
363 | int count = 0; | ||
364 | KOListViewItem * item, *temp; | ||
365 | item = sel.first(); | ||
366 | Incidence* inc; | ||
367 | while ( item ) { | ||
368 | inc = item->data(); | ||
369 | if ( inc->type() != "Journal" ) { | ||
370 | ++count; | ||
371 | if (kap.mAlarmButton->isChecked()) { | ||
372 | if (inc->alarms().count() == 0) | ||
373 | inc->newAlarm(); | ||
374 | QPtrList<Alarm> alarms = inc->alarms(); | ||
375 | Alarm *alarm; | ||
376 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | ||
377 | alarm->setEnabled(true); | ||
378 | int j = kap.mAlarmTimeEdit->value()* -60; | ||
379 | if (kap.mAlarmIncrCombo->currentItem() == 1) | ||
380 | j = j * 60; | ||
381 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | ||
382 | j = j * (60 * 24); | ||
383 | alarm->setStartOffset( j ); | ||
384 | |||
385 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | ||
386 | alarm->setProcedureAlarm(kap.mAlarmProgram); | ||
387 | } | ||
388 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | ||
389 | alarm->setAudioAlarm(kap.mAlarmSound); | ||
390 | else | ||
391 | alarm->setType(Alarm::Invalid); | ||
392 | //alarm->setAudioAlarm("default"); | ||
393 | // TODO: Deal with multiple alarms | ||
394 | break; // For now, stop after the first alarm | ||
395 | } | ||
396 | } else { | ||
397 | Alarm* alarm = inc->alarms().first(); | ||
398 | if ( alarm ) { | ||
399 | alarm->setEnabled(false); | ||
400 | alarm->setType(Alarm::Invalid); | ||
401 | } | ||
402 | } | ||
403 | } | ||
404 | temp = item; | ||
405 | item = sel.next(); | ||
406 | mUidDict.remove( inc->uid() ); | ||
407 | delete temp;; | ||
408 | addIncidence( inc ); | ||
409 | } | ||
410 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); | ||
411 | qDebug("KO: Set alarm for %d items", count); | ||
412 | calendar()->reInitAlarmSettings(); | ||
413 | } | ||
341 | void KOListView::setCategories( bool removeOld ) | 414 | void KOListView::setCategories( bool removeOld ) |
342 | { | 415 | { |