From 12b4828ddfa8ac2fabbaf7c8841b8d68d16a0262 Mon Sep 17 00:00:00 2001 From: zautrix Date: Thu, 09 Jun 2005 08:27:24 +0000 Subject: select lisz view fixes --- (limited to 'korganizer/kolistview.cpp') diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 5797d1b..1f3b4c6 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -389,6 +389,7 @@ void KOListView::setCat() { setCategories( true ); } + void KOListView::setAlarm() { KOAlarmPrefs kap( this); @@ -514,17 +515,8 @@ void KOListView::setCategories( bool removeOld ) void KOListView::beamSelected() { - int icount = 0; - QPtrList delSel ; - QListViewItem *item = mListView->firstChild (); - while ( item ) { - if ( item->isSelected() ) { - delSel.append(((KOListViewItem *)item)->data()); - ++icount; - } - - item = item->nextSibling(); - } + QPtrList delSel = getSelectedIncidences() ; + int icount = delSel.count(); if ( icount ) { emit beamIncidenceList( delSel ); return; @@ -575,17 +567,8 @@ void KOListView::saveDescriptionToFile() if ( result != 0 ) { return; } - int icount = 0; - QPtrList delSel ; - QListViewItem *item = mListView->firstChild (); - while ( item ) { - if ( item->isSelected() ) { - delSel.append(((KOListViewItem *)item)->data()); - ++icount; - } - - item = item->nextSibling(); - } + QPtrList delSel = getSelectedIncidences() ; + int icount = delSel.count(); if ( icount ) { QString fn = KOPrefs::instance()->mLastSaveFile; fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); @@ -659,37 +642,39 @@ void KOListView::saveToFile() { writeToFile( true ); } -void KOListView::writeToFile( bool iCal ) +QPtrList KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) { - - int icount = 0; QPtrList delSel ; - QListViewItem *item = mListView->firstChild (); - bool journal = iCal; // warn only for vCal bool addSubTodos = false; bool askSubTodos = true; + QListViewItem *item = mListView->firstChild (); while ( item ) { if ( item->isSelected() ) { - if ( !journal ) - if ( ((KOListViewItem *)item)->data()->typeID() == journalID ) - journal = true; Incidence* inc = ((KOListViewItem *)item)->data(); - if ( addSubTodos ) { - if ( delSel.findRef( inc ) == -1 ) - delSel.append( inc ); - } else - delSel.append(inc); + if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { + if ( (inc->typeID() == todoID && includeTodos) || + (inc->typeID() == eventID && includeEvents) || + (inc->typeID() == journalID && includeJournals) ) { + if ( inc->typeID() == todoID && onlyDueTodos ) { + if ( ((Todo*)inc)->hasDueDate() ) + delSel.append( inc ); + } else + delSel.append( inc ); + + } + } if ( inc->typeID() == todoID ) { Todo * todo = (Todo*) inc; if ( todo->relations().count() ) { if ( askSubTodos ) { int result = KMessageBox::warningYesNoCancel(this, - i18n("A selected todo has subtodos!\nDo you want to export\nall subtodos of all\nselected todos as well?"), + i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), i18n("Todo has subtodos"), i18n("Yes"), i18n("No")); - if ( result == KMessageBox::Cancel ) { - return; + if ( result == KMessageBox::Cancel ) { + delSel.clear(); + return delSel; } if (result == KMessageBox::Yes) addSubTodos = true; @@ -700,18 +685,34 @@ void KOListView::writeToFile( bool iCal ) } } } - ++icount; } item = item->nextSibling(); } - if ( !iCal && journal ) { - int result = KMessageBox::warningContinueCancel(this, - i18n("The journal entries can not be\nexported to a vCalendar file."), - i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), - true); - if (result != KMessageBox::Continue) return; + return delSel; +} + +void KOListView::writeToFile( bool iCal ) +{ + QPtrList delSel = getSelectedIncidences(); // all inc allowed; + if ( !iCal ) { + bool journal = false; + Incidence *incidence = delSel.first(); + while ( incidence ) { + if ( incidence->typeID() == journalID ) { + journal = true; + break; + } + incidence = delSel.next(); + } + if ( journal ) { + int result = KMessageBox::warningContinueCancel(this, + i18n("The journal entries can not be\nexported to a vCalendar file."), + i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), + true); + if (result != KMessageBox::Continue) return; + } } - if ( icount ) { + if ( delSel.count() ) { QString fn = KOPrefs::instance()->mLastSaveFile; QString extension; if ( iCal ) { @@ -786,18 +787,9 @@ void KOListView::printList() } void KOListView::deleteAll() { - int icount = 0; - QPtrList delSel ; - QListViewItem *item = mListView->firstChild (); - while ( item ) { - if ( item->isSelected() ) { - delSel.append(((KOListViewItem *)item)->data()); - ++icount; - } - - item = item->nextSibling(); - } - if ( icount ) { + QPtrList delSel = getSelectedIncidences(); // all inc allowed;; + if ( delSel.count() ) { + int icount = delSel.count(); Incidence *incidence = delSel.first(); Incidence *toDelete; KOPrefs *p = KOPrefs::instance(); -- cgit v0.9.0.2