-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 | |||
@@ -62,12 +62,14 @@ | |||
62 | #include "koprefs.h" | 62 | #include "koprefs.h" |
63 | #include "kfiledialog.h" | 63 | #include "kfiledialog.h" |
64 | 64 | ||
65 | #include "kolistview.h" | 65 | #include "kolistview.h" |
66 | 66 | ||
67 | 67 | ||
68 | |||
69 | |||
68 | class KOListViewWhatsThis :public QWhatsThis | 70 | class KOListViewWhatsThis :public QWhatsThis |
69 | { | 71 | { |
70 | public: | 72 | public: |
71 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 73 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
72 | 74 | ||
73 | protected: | 75 | protected: |
@@ -254,35 +256,39 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, | |||
254 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 256 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
255 | mPopupMenu = eventPopup(); | 257 | mPopupMenu = eventPopup(); |
256 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 258 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
257 | i18n("Select all"),this, | 259 | i18n("Select all"),this, |
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()), |
263 | i18n("Delete all selected"),this, | 265 | i18n("Delete all selected"),this, |
264 | SLOT(deleteAll()),true); | 266 | SLOT(deleteAll()),true); |
265 | mPopupMenu->insertSeparator(); | 267 | mPopupMenu->insertSeparator(); |
266 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 268 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
267 | i18n("Save selected to file..."),this, | 269 | i18n("Save selected to file..."),this, |
268 | SLOT(saveToFile()),true); | 270 | SLOT(saveToFile()),true); |
269 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 271 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
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, |
275 | SLOT(addCat()),true); | 277 | SLOT(addCat()),true); |
276 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 278 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
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, |
285 | SLOT(beamSelected()),true); | 291 | SLOT(beamSelected()),true); |
286 | #endif | 292 | #endif |
287 | /* | 293 | /* |
288 | mPopupMenu = new QPopupMenu; | 294 | mPopupMenu = new QPopupMenu; |
@@ -335,12 +341,79 @@ void KOListView::addCat( ) | |||
335 | setCategories( false ); | 341 | setCategories( false ); |
336 | } | 342 | } |
337 | void KOListView::setCat() | 343 | void KOListView::setCat() |
338 | { | 344 | { |
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 | { |
343 | 416 | ||
344 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 417 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
345 | if (! csd->exec()) { | 418 | if (! csd->exec()) { |
346 | delete csd; | 419 | delete csd; |