summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp108
-rw-r--r--korganizer/kolistview.h1
2 files changed, 51 insertions, 58 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 5797d1b..1f3b4c6 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -391,2 +391,3 @@ void KOListView::setCat()
}
+
void KOListView::setAlarm()
@@ -516,13 +517,4 @@ void KOListView::beamSelected()
{
- int icount = 0;
- QPtrList<Incidence> delSel ;
- QListViewItem *item = mListView->firstChild ();
- while ( item ) {
- if ( item->isSelected() ) {
- delSel.append(((KOListViewItem *)item)->data());
- ++icount;
- }
-
- item = item->nextSibling();
- }
+ QPtrList<Incidence> delSel = getSelectedIncidences() ;
+ int icount = delSel.count();
if ( icount ) {
@@ -577,13 +569,4 @@ void KOListView::saveDescriptionToFile()
}
- int icount = 0;
- QPtrList<Incidence> delSel ;
- QListViewItem *item = mListView->firstChild ();
- while ( item ) {
- if ( item->isSelected() ) {
- delSel.append(((KOListViewItem *)item)->data());
- ++icount;
- }
-
- item = item->nextSibling();
- }
+ QPtrList<Incidence> delSel = getSelectedIncidences() ;
+ int icount = delSel.count();
if ( icount ) {
@@ -661,22 +644,23 @@ void KOListView::saveToFile()
}
-void KOListView::writeToFile( bool iCal )
+QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
{
-
- int icount = 0;
QPtrList<Incidence> 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 ) {
@@ -686,3 +670,3 @@ void KOListView::writeToFile( bool iCal )
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"),
@@ -690,4 +674,5 @@ void KOListView::writeToFile( bool iCal )
i18n("No"));
- if ( result == KMessageBox::Cancel ) {
- return;
+ if ( result == KMessageBox::Cancel ) {
+ delSel.clear();
+ return delSel;
}
@@ -702,3 +687,2 @@ void KOListView::writeToFile( bool iCal )
}
- ++icount;
}
@@ -706,10 +690,27 @@ void KOListView::writeToFile( bool iCal )
}
- 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<Incidence> 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;
@@ -788,14 +789,5 @@ void KOListView::deleteAll()
{
- int icount = 0;
- QPtrList<Incidence> delSel ;
- QListViewItem *item = mListView->firstChild ();
- while ( item ) {
- if ( item->isSelected() ) {
- delSel.append(((KOListViewItem *)item)->data());
- ++icount;
- }
-
- item = item->nextSibling();
- }
- if ( icount ) {
+ QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
+ if ( delSel.count() ) {
+ int icount = delSel.count();
Incidence *incidence = delSel.first();
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index c25592d..9da5497 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -264,2 +264,3 @@ class KOListView : public KOEventView
QString getWhatsThisText(QPoint p);
+ QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false );
signals: