-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 @@ -56,24 +56,26 @@ #endif #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "koglobals.h" #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: virtual QString text( const QPoint& p) { return _view->getWhatsThisText(p) ; } private: QWidget* _wid; @@ -248,47 +250,51 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent, int iii = 0; for ( iii = 0; iii< 10 ; ++iii ) mListView->setColumnWidthMode( iii, QListView::Manual ); QBoxLayout *layoutTop = new QVBoxLayout(this); layoutTop->addWidget(mListView); 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; mPopupMenu->insertItem(i18n("Edit Event"), this, SLOT (editEvent())); mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, SLOT (deleteEvent())); mPopupMenu->insertSeparator(); mPopupMenu->insertItem(i18n("Show Dates"), this, @@ -329,24 +335,91 @@ void KOListView::updateList() // qDebug(" KOListView::updateList() "); } 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; return; } QStringList catList = csd->selectedCategories(); delete csd; // if ( catList.count() == 0 ) // return; |