author | zautrix <zautrix> | 2005-02-03 21:18:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-03 21:18:40 (UTC) |
commit | c8369569b3c5bc7cbec3b56ddca27847f57ca72f (patch) (side-by-side diff) | |
tree | 43faa47d14dac1b307e955e2ebfa7b0582452b6a /korganizer/kolistview.cpp | |
parent | e9c27558f7127b4a003b435ce09f33b788bf98d1 (diff) | |
download | kdepimpi-c8369569b3c5bc7cbec3b56ddca27847f57ca72f.zip kdepimpi-c8369569b3c5bc7cbec3b56ddca27847f57ca72f.tar.gz kdepimpi-c8369569b3c5bc7cbec3b56ddca27847f57ca72f.tar.bz2 |
alarm fixes
-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 @@ #include "koprefs.h" #include "kfiledialog.h" #include "kolistview.h" + + class KOListViewWhatsThis :public QWhatsThis { public: KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; protected: @@ -254,35 +256,39 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, mListView->setFont ( KOPrefs::instance()->mListViewFont ); mPopupMenu = eventPopup(); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Select all"),this, SLOT(allSelection()),true); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), - i18n("Deselect All"),this, + i18n("Deselect all"),this, SLOT(clearSelection()),true); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Delete all selected"),this, SLOT(deleteAll()),true); mPopupMenu->insertSeparator(); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Save selected to file..."),this, SLOT(saveToFile()),true); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Save Journal/Description..."),this, SLOT(saveDescriptionToFile()),true); - mPopupMenu->insertSeparator(); + // mPopupMenu->insertSeparator(); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Add Categ. to selected..."),this, SLOT(addCat()),true); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Set Categ. for selected..."),this, SLOT(setCat()),true); - mPopupMenu->insertSeparator(); + //mPopupMenu->insertSeparator(); + mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), + i18n("Set alarm for selected..."),this, + SLOT(setAlarm()),true); #ifndef DESKTOP_VERSION + mPopupMenu->insertSeparator(); mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), i18n("Beam selected via IR"),this, SLOT(beamSelected()),true); #endif /* mPopupMenu = new QPopupMenu; @@ -335,12 +341,79 @@ void KOListView::addCat( ) setCategories( false ); } void KOListView::setCat() { setCategories( true ); } +void KOListView::setAlarm() +{ + KOAlarmPrefs kap( this); + if ( !kap.exec() ) + return; + + + QStringList itemList; + QPtrList<KOListViewItem> sel ; + QListViewItem *qitem = mListView->firstChild (); + while ( qitem ) { + if ( qitem->isSelected() ) { + sel.append(((KOListViewItem *)qitem)); + } + qitem = qitem->nextSibling(); + } + int count = 0; + KOListViewItem * item, *temp; + item = sel.first(); + Incidence* inc; + while ( item ) { + inc = item->data(); + if ( inc->type() != "Journal" ) { + ++count; + if (kap.mAlarmButton->isChecked()) { + if (inc->alarms().count() == 0) + inc->newAlarm(); + QPtrList<Alarm> alarms = inc->alarms(); + Alarm *alarm; + for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { + alarm->setEnabled(true); + int j = kap.mAlarmTimeEdit->value()* -60; + if (kap.mAlarmIncrCombo->currentItem() == 1) + j = j * 60; + else if (kap.mAlarmIncrCombo->currentItem() == 2) + j = j * (60 * 24); + alarm->setStartOffset( j ); + + if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { + alarm->setProcedureAlarm(kap.mAlarmProgram); + } + else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) + alarm->setAudioAlarm(kap.mAlarmSound); + else + alarm->setType(Alarm::Invalid); + //alarm->setAudioAlarm("default"); + // TODO: Deal with multiple alarms + break; // For now, stop after the first alarm + } + } else { + Alarm* alarm = inc->alarms().first(); + if ( alarm ) { + alarm->setEnabled(false); + alarm->setType(Alarm::Invalid); + } + } + } + temp = item; + item = sel.next(); + mUidDict.remove( inc->uid() ); + delete temp;; + addIncidence( inc ); + } + topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); + qDebug("KO: Set alarm for %d items", count); + calendar()->reInitAlarmSettings(); +} void KOListView::setCategories( bool removeOld ) { KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); if (! csd->exec()) { delete csd; |