summaryrefslogtreecommitdiffabout
path: root/korganizer/kolistview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kolistview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kolistview.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 4c815d8..1b4397f 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -450,105 +450,91 @@ void KOListView::updateList()
void KOListView::clearList()
{
clear ();
}
void KOListView::setCat()
{
bool set = true;
int result = KMessageBox::warningYesNoCancel(this,
i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"),
i18n("Set categories"),
i18n("Add"),
i18n("Reset"));
if (result == KMessageBox::Cancel) return;
if (result == KMessageBox::Yes) set = false;
setCategories( set );
}
void KOListView::setAlarm()
{
KOAlarmPrefs kap( this);
if ( !kap.exec() )
return;
- QPtrList<KOListViewItem> sel ;
- QListViewItem *qitem = mListView->firstChild ();
- while ( qitem ) {
- if ( qitem->isSelected() ) {
- Incidence* inc = ((KOListViewItem *) qitem)->data();
- if ( inc->typeID() != journalID ) {
- if ( inc->typeID() == todoID ) {
- if ( ((Todo*)inc)->hasDueDate() )
- sel.append(((KOListViewItem *)qitem));
- } else
- sel.append(((KOListViewItem *)qitem));
- }
- }
- qitem = qitem->nextSibling();
- }
+ QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos
+ Incidence* inc = delSel.first();
int count = 0;
- KOListViewItem * item, *temp;
- item = sel.first();
- Incidence* inc;
- while ( item ) {
- inc = item->data();
+ while ( inc ) {
++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);
}
}
+ KOListViewItem* item = getItemForEvent(inc);
+ if (item) {
ListItemVisitor v(item, mStartDate );
inc->accept(v);
- item = sel.next();
+ }
+ inc = delSel.next();
}
topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
qDebug("KO: Set alarm for %d items", count);
calendar()->reInitAlarmSettings();
QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
}
void KOListView::setCategories( bool removeOld )
{
KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
csd->setColorEnabled();
if (! csd->exec()) {
delete csd;
return;
}
QStringList catList = csd->selectedCategories();
delete csd;
QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
Incidence* inc = delSel.first();
while ( inc ) {
if ( removeOld ) {
inc->setCategories( catList, false );
} else {
inc->addCategories( catList, false );
@@ -678,49 +664,61 @@ QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool
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("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 ) {
delSel.clear();
return delSel;
}
if (result == KMessageBox::Yes)
addSubTodos = true;
askSubTodos = false;
}
if ( addSubTodos ) {
- inc->addRelationsToList( &delSel );
+ QPtrList<Incidence> tempSel ;
+ inc->addRelationsToList( &tempSel );
+ Incidence* tempinc = tempSel.first();
+ while ( tempinc ) {
+ if ( delSel.findRef( tempinc ) == -1 ) {
+ if ( tempinc->typeID() == todoID && onlyDueTodos ) {
+ if ( ((Todo*)tempinc)->hasDueDate() )
+ delSel.append( tempinc );
+ } else
+ delSel.append( tempinc );
+ }
+ tempinc = tempSel.next();
+ }
}
}
}
}
item = item->nextSibling();
}
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,