• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kalarm

  • sources
  • kde-4.12
  • kdepim
  • kalarm
undo.cpp
Go to the documentation of this file.
1 /*
2  * undo.cpp - undo/redo facility
3  * Program: kalarm
4  * Copyright © 2005-2013 by David Jarvie <djarvie@kde.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #include "kalarm.h" //krazy:exclude=includes (kalarm.h must be first)
22 #include "undo.h"
23 
24 #include "alarmcalendar.h"
25 #include "functions.h"
26 #include "messagebox.h"
27 
28 #include <kalarmcal/alarmtext.h>
29 #include <kalarmcal/kaevent.h>
30 
31 #include <kapplication.h>
32 #include <klocale.h>
33 #include <kdebug.h>
34 
35 #include <QObject>
36 
37 static int maxCount = 12;
38 
39 #ifdef DELETE
40 #undef DELETE // conflicting Windows macro
41 #endif
42 
43 // Simplify access to Undo::Event struct
44 #ifdef USE_AKONADI
45 #define RESOURCE_PARAM_TYPE const Collection&
46 #define EVENT_RESOURCE collection
47 #else
48 #define RESOURCE_PARAM_TYPE AlarmResource*
49 #define EVENT_RESOURCE resource
50 #endif
51 
52 #ifdef USE_AKONADI
53 using namespace Akonadi;
54 #endif
55 
56 class UndoItem
57 {
58  public:
59  enum Operation { ADD, EDIT, DELETE, REACTIVATE, DEACTIVATE, MULTI };
60  UndoItem(); // needed by QList
61  virtual ~UndoItem();
62  virtual Operation operation() const = 0;
63  virtual QString actionText() const { return !mName.isEmpty() ? mName : defaultActionText(); }
64  virtual QString defaultActionText() const = 0;
65  virtual QString description() const { return QString(); }
66  virtual QString eventID() const { return QString(); }
67  virtual QString oldEventID() const { return QString(); }
68  virtual QString newEventID() const { return QString(); }
69 #ifdef USE_AKONADI
70  virtual Collection collection() const { return Collection(); }
71 #else
72  virtual AlarmResource* resource() const { return 0; }
73 #endif
74  int id() const { return mId; }
75  Undo::Type type() const { return mType; }
76  void setType(Undo::Type t) { mType = t; }
77  CalEvent::Type calendar() const { return mCalendar; }
78  virtual void setCalendar(CalEvent::Type s) { mCalendar = s; }
79  virtual UndoItem* restore() = 0;
80  virtual bool deleteID(const QString& /*id*/) { return false; }
81 
82  enum Error { ERR_NONE, ERR_PROG, ERR_NOT_FOUND, ERR_CREATE, ERR_TEMPLATE, ERR_ARCHIVED };
83  enum Warning { WARN_NONE, WARN_KORG_ADD, WARN_KORG_MODIFY, WARN_KORG_DELETE };
84  static int mLastId;
85  static Error mRestoreError; // error code valid only if restore() returns 0
86  static Warning mRestoreWarning; // warning code set by restore()
87  static KAlarm::UpdateStatus mRestoreWarningKorg; // KOrganizer error status set by restore()
88  static int mRestoreWarningCount; // item count for mRestoreWarning (to allow i18n messages to work correctly)
89 
90  protected:
91  UndoItem(Undo::Type, const QString& name = QString());
92  static QString addDeleteActionText(CalEvent::Type, bool add);
93  QString description(const KAEvent&) const;
94  void replaceWith(UndoItem* item) { Undo::replace(this, item); }
95 
96  QString mName; // specified action name (overrides default)
97  int mId; // unique identifier (only for mType = UNDO, REDO)
98  Undo::Type mType; // which list (if any) the object is in
99  CalEvent::Type mCalendar;
100 };
101 
102 class UndoMultiBase : public UndoItem
103 {
104  public:
105  UndoMultiBase(Undo::Type t, const QString& name)
106  : UndoItem(t, name), mUndos(new Undo::List) { }
107  UndoMultiBase(Undo::Type t, Undo::List* undos, const QString& name)
108  : UndoItem(t, name), mUndos(undos) { }
109  ~UndoMultiBase() { delete mUndos; }
110  const Undo::List* undos() const { return mUndos; }
111  protected:
112  Undo::List* mUndos; // this list must always have >= 2 entries
113 };
114 
115 template <class T> class UndoMulti : public UndoMultiBase
116 {
117  public:
118  UndoMulti(Undo::Type, const Undo::EventList&, const QString& name);
119  UndoMulti(Undo::Type t, Undo::List* undos, const QString& name) : UndoMultiBase(t, undos, name) { }
120  virtual Operation operation() const { return MULTI; }
121  virtual UndoItem* restore();
122  virtual bool deleteID(const QString& id);
123  virtual UndoItem* createRedo(Undo::List*) = 0;
124 };
125 
126 class UndoAdd : public UndoItem
127 {
128  public:
129  UndoAdd(Undo::Type, const Undo::Event&, const QString& name = QString());
130  UndoAdd(Undo::Type, const KAEvent&, RESOURCE_PARAM_TYPE, const QString& name = QString());
131  UndoAdd(Undo::Type, const KAEvent&, RESOURCE_PARAM_TYPE, const QString& name, CalEvent::Type);
132  virtual Operation operation() const { return ADD; }
133  virtual QString defaultActionText() const;
134  virtual QString description() const { return mDescription; }
135 #ifdef USE_AKONADI
136  virtual Collection collection() const { return mResource; }
137 #else
138  virtual AlarmResource* resource() const { return mResource; }
139 #endif
140  virtual QString eventID() const { return mEventId; }
141  virtual QString newEventID() const { return mEventId; }
142  virtual UndoItem* restore() { return doRestore(); }
143  protected:
144  UndoItem* doRestore(bool setArchive = false);
145  virtual UndoItem* createRedo(const KAEvent&, RESOURCE_PARAM_TYPE);
146  private:
147 #ifdef USE_AKONADI
148  Collection mResource; // collection containing the event
149 #else
150  AlarmResource* mResource; // resource calendar containing the event
151 #endif
152  QString mEventId;
153  QString mDescription;
154 };
155 
156 class UndoEdit : public UndoItem
157 {
158  public:
159  UndoEdit(Undo::Type, const KAEvent& oldEvent, const QString& newEventID,
160  RESOURCE_PARAM_TYPE, const QStringList& dontShowErrors, const QString& description);
161  ~UndoEdit();
162  virtual Operation operation() const { return EDIT; }
163  virtual QString defaultActionText() const;
164  virtual QString description() const { return mDescription; }
165 #ifdef USE_AKONADI
166  virtual Collection collection() const { return mResource; }
167 #else
168  virtual AlarmResource* resource() const { return mResource; }
169 #endif
170  virtual QString eventID() const { return mNewEventId; }
171  virtual QString oldEventID() const { return mOldEvent->id(); }
172  virtual QString newEventID() const { return mNewEventId; }
173  virtual UndoItem* restore();
174  private:
175 #ifdef USE_AKONADI
176  Collection mResource; // collection containing the event
177 #else
178  AlarmResource* mResource; // resource calendar containing the event
179 #endif
180  KAEvent* mOldEvent;
181  QString mNewEventId;
182  QString mDescription;
183  QStringList mDontShowErrors;
184 };
185 
186 class UndoDelete : public UndoItem
187 {
188  public:
189  UndoDelete(Undo::Type, const Undo::Event&, const QString& name = QString());
190  UndoDelete(Undo::Type, const KAEvent&, RESOURCE_PARAM_TYPE, const QStringList& dontShowErrors, const QString& name = QString());
191  ~UndoDelete();
192  virtual Operation operation() const { return DELETE; }
193  virtual QString defaultActionText() const;
194  virtual QString description() const { return UndoItem::description(*mEvent); }
195 #ifdef USE_AKONADI
196  virtual Collection collection() const { return mResource; }
197 #else
198  virtual AlarmResource* resource() const { return mResource; }
199 #endif
200  virtual QString eventID() const { return mEvent->id(); }
201  virtual QString oldEventID() const { return mEvent->id(); }
202  virtual UndoItem* restore();
203  KAEvent* event() const { return mEvent; }
204  protected:
205  virtual UndoItem* createRedo(const KAEvent&, RESOURCE_PARAM_TYPE);
206  private:
207 #ifdef USE_AKONADI
208  Collection mResource; // collection containing the event
209 #else
210  AlarmResource* mResource; // resource calendar containing the event
211 #endif
212  KAEvent* mEvent;
213  QStringList mDontShowErrors;
214 };
215 
216 class UndoReactivate : public UndoAdd
217 {
218  public:
219  UndoReactivate(Undo::Type t, const Undo::Event& e, const QString& name = QString())
220  : UndoAdd(t, e.event, e.EVENT_RESOURCE, name, CalEvent::ACTIVE) { }
221  UndoReactivate(Undo::Type t, const KAEvent& e, RESOURCE_PARAM_TYPE r, const QString& name = QString())
222  : UndoAdd(t, e, r, name, CalEvent::ACTIVE) { }
223  virtual Operation operation() const { return REACTIVATE; }
224  virtual QString defaultActionText() const;
225  virtual UndoItem* restore();
226  protected:
227  virtual UndoItem* createRedo(const KAEvent&, RESOURCE_PARAM_TYPE);
228 };
229 
230 class UndoDeactivate : public UndoDelete
231 {
232  public:
233  UndoDeactivate(Undo::Type t, const KAEvent& e, RESOURCE_PARAM_TYPE r, const QString& name = QString())
234  : UndoDelete(t, e, r, QStringList(), name) { }
235  virtual Operation operation() const { return DEACTIVATE; }
236  virtual QString defaultActionText() const;
237  virtual UndoItem* restore();
238  protected:
239  virtual UndoItem* createRedo(const KAEvent&, RESOURCE_PARAM_TYPE);
240 };
241 
242 class UndoAdds : public UndoMulti<UndoAdd>
243 {
244  public:
245  UndoAdds(Undo::Type t, const Undo::EventList& events, const QString& name = QString())
246  : UndoMulti<UndoAdd>(t, events, name) { } // UNDO only
247  UndoAdds(Undo::Type t, Undo::List* undos, const QString& name)
248  : UndoMulti<UndoAdd>(t, undos, name) { }
249  virtual QString defaultActionText() const;
250  virtual UndoItem* createRedo(Undo::List*);
251 };
252 
253 class UndoDeletes : public UndoMulti<UndoDelete>
254 {
255  public:
256  UndoDeletes(Undo::Type t, const Undo::EventList& events, const QString& name = QString())
257  : UndoMulti<UndoDelete>(t, events, name) { } // UNDO only
258  UndoDeletes(Undo::Type t, Undo::List* undos, const QString& name)
259  : UndoMulti<UndoDelete>(t, undos, name) { }
260  virtual QString defaultActionText() const;
261  virtual UndoItem* createRedo(Undo::List*);
262 };
263 
264 class UndoReactivates : public UndoMulti<UndoReactivate>
265 {
266  public:
267  UndoReactivates(Undo::Type t, const Undo::EventList& events, const QString& name = QString())
268  : UndoMulti<UndoReactivate>(t, events, name) { } // UNDO only
269  UndoReactivates(Undo::Type t, Undo::List* undos, const QString& name)
270  : UndoMulti<UndoReactivate>(t, undos, name) { }
271  virtual QString defaultActionText() const;
272  virtual UndoItem* createRedo(Undo::List*);
273 };
274 
275 Undo* Undo::mInstance = 0;
276 Undo::List Undo::mUndoList;
277 Undo::List Undo::mRedoList;
278 
279 
280 /******************************************************************************
281 * Create the one and only instance of the Undo class.
282 */
283 Undo* Undo::instance()
284 {
285  if (!mInstance)
286  mInstance = new Undo(kapp);
287  return mInstance;
288 }
289 
290 /******************************************************************************
291 * Clear the lists of undo and redo items.
292 */
293 void Undo::clear()
294 {
295  if (!mUndoList.isEmpty() || !mRedoList.isEmpty())
296  {
297  mInstance->blockSignals(true);
298  while (!mUndoList.isEmpty())
299  delete mUndoList.first(); // N.B. 'delete' removes the object from the list
300  while (!mRedoList.isEmpty())
301  delete mRedoList.first(); // N.B. 'delete' removes the object from the list
302  mInstance->blockSignals(false);
303  emitChanged();
304  }
305 }
306 
307 /******************************************************************************
308 * Create an undo item and add it to the list of undos.
309 * N.B. The base class constructor adds the object to the undo list.
310 */
311 void Undo::saveAdd(const KAEvent& event, RESOURCE_PARAM_TYPE resource, const QString& name)
312 {
313  new UndoAdd(UNDO, event, resource, name);
314  emitChanged();
315 }
316 
317 void Undo::saveAdds(const Undo::EventList& events, const QString& name)
318 {
319  int count = events.count();
320  if (count == 1)
321  saveAdd(events.first().event, events.first().EVENT_RESOURCE, name);
322  else if (count > 1)
323  {
324  new UndoAdds(UNDO, events, name);
325  emitChanged();
326  }
327 }
328 
329 void Undo::saveEdit(const Undo::Event& oldEvent, const KAEvent& newEvent)
330 {
331  new UndoEdit(UNDO, oldEvent.event, newEvent.id(), oldEvent.EVENT_RESOURCE, oldEvent.dontShowErrors, AlarmText::summary(newEvent));
332  removeRedos(oldEvent.event.id()); // remove any redos which are made invalid by this edit
333  emitChanged();
334 }
335 
336 void Undo::saveDelete(const Undo::Event& event, const QString& name)
337 {
338  new UndoDelete(UNDO, event.event, event.EVENT_RESOURCE, event.dontShowErrors, name);
339  removeRedos(event.event.id()); // remove any redos which are made invalid by this deletion
340  emitChanged();
341 }
342 
343 void Undo::saveDeletes(const Undo::EventList& events, const QString& name)
344 {
345  int count = events.count();
346  if (count == 1)
347  saveDelete(events[0], name);
348  else if (count > 1)
349  {
350  new UndoDeletes(UNDO, events, name);
351  for (int i = 0, end = events.count(); i < end; ++i)
352  removeRedos(events[i].event.id()); // remove any redos which are made invalid by these deletions
353  emitChanged();
354  }
355 }
356 
357 void Undo::saveReactivate(const KAEvent& event, RESOURCE_PARAM_TYPE resource, const QString& name)
358 {
359  new UndoReactivate(UNDO, event, resource, name);
360  emitChanged();
361 }
362 
363 void Undo::saveReactivates(const EventList& events, const QString& name)
364 {
365  int count = events.count();
366  if (count == 1)
367  saveReactivate(events[0].event, events[0].EVENT_RESOURCE, name);
368  else if (count > 1)
369  {
370  new UndoReactivates(UNDO, events, name);
371  emitChanged();
372  }
373 }
374 
375 /******************************************************************************
376 * Remove any redos which are made invalid by a new undo.
377 */
378 void Undo::removeRedos(const QString& eventID)
379 {
380  QString id = eventID;
381  for (int i = 0; i < mRedoList.count(); )
382  {
383  UndoItem* item = mRedoList[i];
384 //kDebug()<<item->eventID()<<" (looking for"<<id<<")";
385  if (item->operation() == UndoItem::MULTI)
386  {
387  if (item->deleteID(id))
388  {
389  // The old multi-redo was replaced with a new single redo
390  delete item; // N.B. 'delete' removes the object from the list
391  }
392  }
393  else if (item->eventID() == id)
394  {
395  if (item->operation() == UndoItem::EDIT)
396  id = item->oldEventID(); // continue looking for its post-edit ID
397  delete item; // N.B. 'delete' removes the object from the list
398  }
399  else
400  ++i;
401  }
402 }
403 
404 /******************************************************************************
405 * Undo or redo a specified item.
406 * Reply = true if success, or if the item no longer exists.
407 */
408 bool Undo::undo(int i, Undo::Type type, QWidget* parent, const QString& action)
409 {
410  UndoItem::mRestoreError = UndoItem::ERR_NONE;
411  UndoItem::mRestoreWarning = UndoItem::WARN_NONE;
412  UndoItem::mRestoreWarningKorg = KAlarm::UPDATE_OK;
413  UndoItem::mRestoreWarningCount = 0;
414  List& list = (type == UNDO) ? mUndoList : mRedoList;
415  if (i < list.count() && list[i]->type() == type)
416  {
417  list[i]->restore();
418  delete list[i]; // N.B. 'delete' removes the object from its list
419  emitChanged();
420  }
421 
422  QString err;
423  switch (UndoItem::mRestoreError)
424  {
425  case UndoItem::ERR_NONE:
426  {
427  KAlarm::UpdateError errcode;
428  switch (UndoItem::mRestoreWarning)
429  {
430  case UndoItem::WARN_KORG_ADD: errcode = KAlarm::ERR_ADD; break;
431  case UndoItem::WARN_KORG_MODIFY: errcode = KAlarm::ERR_MODIFY; break;
432  case UndoItem::WARN_KORG_DELETE: errcode = KAlarm::ERR_DELETE; break;
433  case UndoItem::WARN_NONE:
434  default:
435  return true;
436  }
437  KAlarm::displayKOrgUpdateError(parent, errcode, UndoItem::mRestoreWarningKorg, UndoItem::mRestoreWarningCount);
438  return true;
439  }
440  case UndoItem::ERR_NOT_FOUND: err = i18nc("@info/plain", "Alarm not found"); break;
441  case UndoItem::ERR_CREATE: err = i18nc("@info/plain", "Error recreating alarm"); break;
442  case UndoItem::ERR_TEMPLATE: err = i18nc("@info/plain", "Error recreating alarm template"); break;
443  case UndoItem::ERR_ARCHIVED: err = i18nc("@info/plain", "Cannot reactivate archived alarm"); break;
444  case UndoItem::ERR_PROG: err = i18nc("@info/plain", "Program error"); break;
445  default: err = i18nc("@info/plain", "Unknown error"); break;
446  }
447  KAMessageBox::sorry(parent, i18nc("@info Undo-action: message", "%1: %2", action, err));
448  return false;
449 }
450 
451 /******************************************************************************
452 * Add an undo item to the start of one of the lists.
453 */
454 void Undo::add(UndoItem* item, bool undo)
455 {
456  if (item)
457  {
458  // Limit the number of items stored
459  int undoCount = mUndoList.count();
460  int redoCount = mRedoList.count();
461  if (undoCount + redoCount >= maxCount - 1)
462  {
463  if (undoCount)
464  mUndoList.pop_back();
465  else
466  mRedoList.pop_back();
467  }
468 
469  // Append the new item
470  List* list = undo ? &mUndoList : &mRedoList;
471  list->prepend(item);
472  }
473 }
474 
475 /******************************************************************************
476 * Remove an undo item from one of the lists.
477 */
478 void Undo::remove(UndoItem* item, bool undo)
479 {
480  List* list = undo ? &mUndoList : &mRedoList;
481  if (!list->isEmpty())
482  list->removeAt(list->indexOf(item));
483 }
484 
485 /******************************************************************************
486 * Replace an undo item in one of the lists.
487 */
488 void Undo::replace(UndoItem* old, UndoItem* New)
489 {
490  Type type = old->type();
491  List* list = (type == UNDO) ? &mUndoList : (type == REDO) ? &mRedoList : 0;
492  if (!list)
493  return;
494  int i = list->indexOf(old);
495  if (i >= 0)
496  {
497  New->setType(type); // ensure the item points to the correct list
498  (*list)[i] = New;
499  old->setType(NONE); // mark the old item as no longer being in a list
500  }
501 }
502 
503 /******************************************************************************
504 * Return the action description of the latest undo/redo item.
505 */
506 QString Undo::actionText(Undo::Type type)
507 {
508  List* list = (type == UNDO) ? &mUndoList : (type == REDO) ? &mRedoList : 0;
509  return (list && !list->isEmpty()) ? (*list)[0]->actionText() : QString();
510 }
511 
512 /******************************************************************************
513 * Return the action description of the undo/redo item with the specified ID.
514 */
515 QString Undo::actionText(Undo::Type type, int id)
516 {
517  UndoItem* undo = getItem(id, type);
518  return undo ? undo->actionText() : QString();
519 }
520 
521 /******************************************************************************
522 * Return the alarm description of the undo/redo item with the specified ID.
523 */
524 QString Undo::description(Undo::Type type, int id)
525 {
526  UndoItem* undo = getItem(id, type);
527  return undo ? undo->description() : QString();
528 }
529 
530 /******************************************************************************
531 * Return the descriptions of all undo or redo items, in order latest first.
532 * For alarms which have undergone more than one change, only the first one is
533 * listed, to force dependent undos to be executed in their correct order.
534 * If 'ids' is non-null, also returns a list of their corresponding IDs.
535 */
536 QList<int> Undo::ids(Undo::Type type)
537 {
538  QList<int> ids;
539  QStringList ignoreIDs;
540 //int n=0;
541  List* list = (type == UNDO) ? &mUndoList : (type == REDO) ? &mRedoList : 0;
542  if (!list)
543  return ids;
544  for (int i = 0, end = list->count(); i < end; ++i)
545  {
546  // Check whether this item should be ignored because it is a
547  // dependent undo. If not, add this item's ID to the ignore list.
548  UndoItem* item = (*list)[i];
549  bool omit = false;
550  if (item->operation() == UndoItem::MULTI)
551  {
552  // If any item in a multi-undo is disqualified, omit the whole multi-undo
553  QStringList newIDs;
554  const Undo::List* undos = ((UndoMultiBase*)item)->undos();
555  for (int u = 0, uend = undos->count(); u < uend; ++u)
556  {
557  QString evid = (*undos)[u]->eventID();
558  if (ignoreIDs.contains(evid))
559  omit = true;
560  else if (omit)
561  ignoreIDs.append(evid);
562  else
563  newIDs.append(evid);
564  }
565  if (omit)
566  {
567  for (int i = 0, iend = newIDs.count(); i < iend; ++i)
568  ignoreIDs.append(newIDs[i]);
569  }
570  }
571  else
572  {
573  omit = ignoreIDs.contains(item->eventID());
574  if (!omit)
575  ignoreIDs.append(item->eventID());
576  if (item->operation() == UndoItem::EDIT)
577  ignoreIDs.append(item->oldEventID()); // continue looking for its post-edit ID
578  }
579  if (!omit)
580  ids.append(item->id());
581 //else kDebug()<<"Undo::ids(): omit"<<item->actionText()<<":"<<item->description();
582  }
583 //kDebug()<<"Undo::ids():"<<n<<" ->"<<ids.count();
584  return ids;
585 }
586 
587 /******************************************************************************
588 * Emit the appropriate 'changed' signal.
589 */
590 void Undo::emitChanged()
591 {
592  if (mInstance)
593  mInstance->emitChanged(actionText(UNDO), actionText(REDO));
594 }
595 
596 /******************************************************************************
597 * Return the item with the specified ID.
598 */
599 UndoItem* Undo::getItem(int id, Undo::Type type)
600 {
601  List* list = (type == UNDO) ? &mUndoList : (type == REDO) ? &mRedoList : 0;
602  if (list)
603  {
604  for (int i = 0, end = list->count(); i < end; ++i)
605  {
606  if ((*list)[i]->id() == id)
607  return (*list)[i];
608  }
609  }
610  return 0;
611 }
612 
613 /******************************************************************************
614 * Find an item with the specified ID.
615 */
616 int Undo::findItem(int id, Undo::Type type)
617 {
618  List& list = (type == UNDO) ? mUndoList : mRedoList;
619  int i = 0;
620  for (int end = list.count(); i < end; ++i)
621  {
622  if (list[i]->id() == id)
623  break;
624  }
625  return i;
626 }
627 
628 
629 /*=============================================================================
630 = Class: UndoItem
631 = A single undo action.
632 =============================================================================*/
633 int UndoItem::mLastId = 0;
634 UndoItem::Error UndoItem::mRestoreError;
635 UndoItem::Warning UndoItem::mRestoreWarning;
636 KAlarm::UpdateStatus UndoItem::mRestoreWarningKorg;
637 int UndoItem::mRestoreWarningCount;
638 
639 /******************************************************************************
640 * Constructor.
641 * Optionally appends the undo to the list of undos.
642 */
643 UndoItem::UndoItem(Undo::Type type, const QString& name)
644  : mName(name),
645  mId(0),
646  mType(type),
647  mCalendar(CalEvent::EMPTY)
648 {
649  if (type != Undo::NONE)
650  {
651  mId = ++mLastId;
652  if (mId < 0)
653  mId = mLastId = 1; // wrap round if we reach a negative number
654  Undo::add(this, (mType == Undo::UNDO));
655  }
656 }
657 
658 /******************************************************************************
659 * Destructor.
660 * Removes the undo from the list (if it's in the list).
661 */
662 UndoItem::~UndoItem()
663 {
664  if (mType != Undo::NONE)
665  Undo::remove(this, (mType == Undo::UNDO));
666 }
667 
668 /******************************************************************************
669 * Return the description of an event.
670 */
671 QString UndoItem::description(const KAEvent& event) const
672 {
673  return (mCalendar == CalEvent::TEMPLATE) ? event.templateName() : AlarmText::summary(event);
674 }
675 
676 /******************************************************************************
677 * Return the action description of an add or delete Undo/Redo item for displaying.
678 */
679 QString UndoItem::addDeleteActionText(CalEvent::Type calendar, bool add)
680 {
681  switch (calendar)
682  {
683  case CalEvent::ACTIVE:
684  if (add)
685  return i18nc("@info/plain Action to create a new alarm", "New alarm");
686  else
687  return i18nc("@info/plain Action to delete an alarm", "Delete alarm");
688  case CalEvent::TEMPLATE:
689  if (add)
690  return i18nc("@info/plain Action to create a new alarm template", "New template");
691  else
692  return i18nc("@info/plain Action to delete an alarm template", "Delete template");
693  case CalEvent::ARCHIVED:
694  return i18nc("@info/plain", "Delete archived alarm");
695  default:
696  break;
697  }
698  return QString();
699 }
700 
701 
702 /*=============================================================================
703 = Class: UndoMultiBase
704 = Undo item for multiple alarms.
705 =============================================================================*/
706 
707 template <class T>
708 UndoMulti<T>::UndoMulti(Undo::Type type, const Undo::EventList& events, const QString& name)
709  : UndoMultiBase(type, name) // UNDO only
710 {
711  for (int i = 0, end = events.count(); i < end; ++i)
712  mUndos->append(new T(Undo::NONE, events[i]));
713 }
714 
715 /******************************************************************************
716 * Undo the item, i.e. restore multiple alarms which were deleted (or delete
717 * alarms which were restored).
718 * Create a redo item to delete (or restore) the alarms again.
719 * Reply = redo item.
720 */
721 template <class T>
722 UndoItem* UndoMulti<T>::restore()
723 {
724  Undo::List* newUndos = new Undo::List;
725  for (int i = 0, end = mUndos->count(); i < end; ++i)
726  {
727  UndoItem* undo = (*mUndos)[i]->restore();
728  if (undo)
729  newUndos->append(undo);
730  }
731  if (newUndos->isEmpty())
732  {
733  delete newUndos;
734  return 0;
735  }
736 
737  // Create a redo item to delete the alarm again
738  return createRedo(newUndos);
739 }
740 
741 /******************************************************************************
742 * If one of the multiple items has the specified ID, delete it.
743 * If an item is deleted and there is only one item left, the UndoMulti
744 * instance is removed from its list and replaced by the remaining UndoItem instead.
745 * Reply = true if this instance was replaced. The caller must delete it.
746 * = false otherwise.
747 */
748 template <class T>
749 bool UndoMulti<T>::deleteID(const QString& id)
750 {
751  for (int i = 0, end = mUndos->count(); i < end; ++i)
752  {
753  UndoItem* item = (*mUndos)[i];
754  if (item->eventID() == id)
755  {
756  // Found a matching entry - remove it
757  mUndos->removeAt(i);
758  if (mUndos->count() == 1)
759  {
760  // There is only one entry left after removal.
761  // Replace 'this' multi instance with the remaining single entry.
762  replaceWith(item);
763  return true;
764  }
765  else
766  {
767  delete item;
768  return false;
769  }
770  }
771  }
772  return false;
773 }
774 
775 
776 /*=============================================================================
777 = Class: UndoAdd
778 = Undo item for alarm creation.
779 =============================================================================*/
780 
781 UndoAdd::UndoAdd(Undo::Type type, const Undo::Event& undo, const QString& name)
782  : UndoItem(type, name),
783  mResource(undo.EVENT_RESOURCE),
784  mEventId(undo.event.id())
785 {
786  setCalendar(undo.event.category());
787  mDescription = UndoItem::description(undo.event); // calendar must be set before calling this
788 }
789 
790 UndoAdd::UndoAdd(Undo::Type type, const KAEvent& event, RESOURCE_PARAM_TYPE resource, const QString& name)
791  : UndoItem(type, name),
792  mResource(resource),
793  mEventId(event.id())
794 {
795  setCalendar(event.category());
796  mDescription = UndoItem::description(event); // calendar must be set before calling this
797 }
798 
799 UndoAdd::UndoAdd(Undo::Type type, const KAEvent& event, RESOURCE_PARAM_TYPE resource, const QString& name, CalEvent::Type cal)
800  : UndoItem(type, name),
801  mResource(resource),
802  mEventId(CalEvent::uid(event.id(), cal)) // convert if old-style event ID
803 {
804  setCalendar(cal);
805  mDescription = UndoItem::description(event); // calendar must be set before calling this
806 }
807 
808 /******************************************************************************
809 * Undo the item, i.e. delete the alarm which was added.
810 * Create a redo item to add the alarm back again.
811 * Reply = redo item.
812 */
813 UndoItem* UndoAdd::doRestore(bool setArchive)
814 {
815  // Retrieve the current state of the alarm
816  kDebug() << mEventId;
817 #ifdef USE_AKONADI
818  const KAEvent* ev = AlarmCalendar::getEvent(EventId(mResource.id(), mEventId));
819 #else
820  const KAEvent* ev = AlarmCalendar::getEvent(mEventId);
821 #endif
822  if (!ev)
823  {
824  mRestoreError = ERR_NOT_FOUND; // alarm is no longer in calendar
825  return 0;
826  }
827  KAEvent event(*ev);
828 
829  // Create a redo item to recreate the alarm.
830  // Do it now, since 'event' gets modified by KAlarm::deleteEvent()
831  UndoItem* undo = createRedo(event, mResource);
832 
833  switch (calendar())
834  {
835  case CalEvent::ACTIVE:
836  {
837  if (setArchive)
838  event.setArchive();
839  // Archive it if it has already triggered
840  KAlarm::UpdateStatus status = KAlarm::deleteEvent(event, true);
841  switch (status)
842  {
843  case KAlarm::UPDATE_ERROR:
844  case KAlarm::UPDATE_FAILED:
845  case KAlarm::SAVE_FAILED:
846  mRestoreError = ERR_CREATE;
847  break;
848  case KAlarm::UPDATE_KORG_FUNCERR:
849  case KAlarm::UPDATE_KORG_ERRSTART:
850  case KAlarm::UPDATE_KORG_ERR:
851  mRestoreWarning = WARN_KORG_DELETE;
852  ++mRestoreWarningCount;
853  if (status > mRestoreWarningKorg)
854  mRestoreWarningKorg = status;
855  break;
856  default:
857  break;
858  }
859  break;
860  }
861  case CalEvent::TEMPLATE:
862 #ifdef USE_AKONADI
863  if (KAlarm::deleteTemplate(event) != KAlarm::UPDATE_OK)
864 #else
865  if (KAlarm::deleteTemplate(event.id()) != KAlarm::UPDATE_OK)
866 #endif
867  mRestoreError = ERR_TEMPLATE;
868  break;
869  case CalEvent::ARCHIVED: // redoing the deletion of an archived alarm
870  KAlarm::deleteEvent(event);
871  break;
872  default:
873  delete undo;
874  mRestoreError = ERR_PROG;
875  return 0;
876  }
877  return undo;
878 }
879 
880 /******************************************************************************
881 * Create a redo item to add the alarm back again.
882 */
883 UndoItem* UndoAdd::createRedo(const KAEvent& event, RESOURCE_PARAM_TYPE resource)
884 {
885  Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
886  return new UndoDelete(t, event, resource, QStringList(), mName);
887 }
888 
889 /******************************************************************************
890 * Return the action description of the Undo item for displaying.
891 */
892 QString UndoAdd::defaultActionText() const
893 {
894  return addDeleteActionText(calendar(), (type() == Undo::UNDO));
895 }
896 
897 
898 /*=============================================================================
899 = Class: UndoAdds
900 = Undo item for multiple alarm creation.
901 =============================================================================*/
902 
903 /******************************************************************************
904 * Create a redo item to add the alarms again.
905 */
906 UndoItem* UndoAdds::createRedo(Undo::List* undos)
907 {
908  Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
909  return new UndoAdds(t, undos, mName);
910 }
911 
912 /******************************************************************************
913 * Return the action description of the Undo item for displaying.
914 */
915 QString UndoAdds::defaultActionText() const
916 {
917  return i18nc("@info/plain", "Create multiple alarms");
918 }
919 
920 
921 /*=============================================================================
922 = Class: UndoEdit
923 = Undo item for alarm edit.
924 =============================================================================*/
925 
926 UndoEdit::UndoEdit(Undo::Type type, const KAEvent& oldEvent, const QString& newEventID,
927  RESOURCE_PARAM_TYPE resource, const QStringList& dontShowErrors, const QString& description)
928  : UndoItem(type),
929  mResource(resource),
930  mOldEvent(new KAEvent(oldEvent)),
931  mNewEventId(newEventID),
932  mDescription(description),
933  mDontShowErrors(dontShowErrors)
934 {
935  setCalendar(oldEvent.category());
936 }
937 
938 UndoEdit::~UndoEdit()
939 {
940  delete mOldEvent;
941 }
942 
943 /******************************************************************************
944 * Undo the item, i.e. undo an edit to a previously existing alarm.
945 * Create a redo item to reapply the edit.
946 * Reply = redo item.
947 */
948 UndoItem* UndoEdit::restore()
949 {
950  kDebug() << mNewEventId;
951  // Retrieve the current state of the alarm
952 #ifdef USE_AKONADI
953  const KAEvent* event = AlarmCalendar::getEvent(EventId(mResource.id(), mNewEventId));
954 #else
955  const KAEvent* event = AlarmCalendar::getEvent(mNewEventId);
956 #endif
957  if (!event)
958  {
959  mRestoreError = ERR_NOT_FOUND; // alarm is no longer in calendar
960  return 0;
961  }
962  KAEvent newEvent(*event);
963 
964  // Create a redo item to restore the edit
965  Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
966 #ifdef USE_AKONADI
967  UndoItem* undo = new UndoEdit(t, newEvent, mOldEvent->id(), mResource, KAlarm::dontShowErrors(EventId(newEvent)), mDescription);
968 #else
969  UndoItem* undo = new UndoEdit(t, newEvent, mOldEvent->id(), mResource, KAlarm::dontShowErrors(mNewEventId), mDescription);
970 #endif
971 
972  switch (calendar())
973  {
974  case CalEvent::ACTIVE:
975  {
976  KAlarm::UpdateStatus status = KAlarm::modifyEvent(newEvent, *mOldEvent);
977  switch (status)
978  {
979  case KAlarm::UPDATE_ERROR:
980  case KAlarm::UPDATE_FAILED:
981  case KAlarm::SAVE_FAILED:
982  mRestoreError = ERR_CREATE;
983  break;
984  case KAlarm::UPDATE_KORG_FUNCERR:
985  case KAlarm::UPDATE_KORG_ERRSTART:
986  case KAlarm::UPDATE_KORG_ERR:
987  mRestoreWarning = WARN_KORG_MODIFY;
988  ++mRestoreWarningCount;
989  if (status > mRestoreWarningKorg)
990  mRestoreWarningKorg = status;
991  // fall through to default
992  default:
993 #ifdef USE_AKONADI
994  KAlarm::setDontShowErrors(EventId(*mOldEvent), mDontShowErrors);
995 #else
996  KAlarm::setDontShowErrors(mOldEvent->id(), mDontShowErrors);
997 #endif
998  break;
999  }
1000  break;
1001  }
1002  case CalEvent::TEMPLATE:
1003  if (KAlarm::updateTemplate(*mOldEvent) != KAlarm::UPDATE_OK)
1004  mRestoreError = ERR_TEMPLATE;
1005  break;
1006  case CalEvent::ARCHIVED: // editing of archived events is not allowed
1007  default:
1008  delete undo;
1009  mRestoreError = ERR_PROG;
1010  return 0;
1011  }
1012  return undo;
1013 }
1014 
1015 /******************************************************************************
1016 * Return the action description of the Undo item for displaying.
1017 */
1018 QString UndoEdit::defaultActionText() const
1019 {
1020  switch (calendar())
1021  {
1022  case CalEvent::ACTIVE:
1023  return i18nc("@info/plain Action to edit an alarm", "Edit alarm");
1024  case CalEvent::TEMPLATE:
1025  return i18nc("@info/plain Action to edit an alarm template", "Edit template");
1026  default:
1027  break;
1028  }
1029  return QString();
1030 }
1031 
1032 
1033 /*=============================================================================
1034 = Class: UndoDelete
1035 = Undo item for alarm deletion.
1036 =============================================================================*/
1037 
1038 UndoDelete::UndoDelete(Undo::Type type, const Undo::Event& undo, const QString& name)
1039  : UndoItem(type, name),
1040  mResource(undo.EVENT_RESOURCE),
1041  mEvent(new KAEvent(undo.event)),
1042  mDontShowErrors(undo.dontShowErrors)
1043 {
1044  setCalendar(mEvent->category());
1045 }
1046 
1047 UndoDelete::UndoDelete(Undo::Type type, const KAEvent& event, RESOURCE_PARAM_TYPE resource, const QStringList& dontShowErrors, const QString& name)
1048  : UndoItem(type, name),
1049  mResource(resource),
1050  mEvent(new KAEvent(event)),
1051  mDontShowErrors(dontShowErrors)
1052 {
1053  setCalendar(mEvent->category());
1054 }
1055 
1056 UndoDelete::~UndoDelete()
1057 {
1058  delete mEvent;
1059 }
1060 
1061 /******************************************************************************
1062 * Undo the item, i.e. restore an alarm which was deleted.
1063 * Create a redo item to delete the alarm again.
1064 * Reply = redo item.
1065 */
1066 UndoItem* UndoDelete::restore()
1067 {
1068  kDebug() << mEvent->id();
1069  // Restore the original event
1070  switch (calendar())
1071  {
1072  case CalEvent::ACTIVE:
1073  if (mEvent->toBeArchived())
1074  {
1075  // It was archived when it was deleted
1076  mEvent->setCategory(CalEvent::ARCHIVED);
1077 #ifdef USE_AKONADI
1078  KAlarm::UpdateStatus status = KAlarm::reactivateEvent(*mEvent, &mResource);
1079 #else
1080  KAlarm::UpdateStatus status = KAlarm::reactivateEvent(*mEvent, mResource);
1081 #endif
1082  switch (status)
1083  {
1084  case KAlarm::UPDATE_KORG_FUNCERR:
1085  case KAlarm::UPDATE_KORG_ERRSTART:
1086  case KAlarm::UPDATE_KORG_ERR:
1087  mRestoreWarning = WARN_KORG_ADD;
1088  ++mRestoreWarningCount;
1089  if (status > mRestoreWarningKorg)
1090  mRestoreWarningKorg = status;
1091  break;
1092  case KAlarm::UPDATE_ERROR:
1093  case KAlarm::UPDATE_FAILED:
1094  case KAlarm::SAVE_FAILED:
1095  mRestoreError = ERR_ARCHIVED;
1096  return 0;
1097  case KAlarm::UPDATE_OK:
1098  break;
1099  }
1100  }
1101  else
1102  {
1103 #ifdef USE_AKONADI
1104  KAlarm::UpdateStatus status = KAlarm::addEvent(*mEvent, &mResource, 0, true);
1105 #else
1106  KAlarm::UpdateStatus status = KAlarm::addEvent(*mEvent, mResource, 0, true);
1107 #endif
1108  switch (status)
1109  {
1110  case KAlarm::UPDATE_KORG_FUNCERR:
1111  case KAlarm::UPDATE_KORG_ERRSTART:
1112  case KAlarm::UPDATE_KORG_ERR:
1113  mRestoreWarning = WARN_KORG_ADD;
1114  ++mRestoreWarningCount;
1115  if (status > mRestoreWarningKorg)
1116  mRestoreWarningKorg = status;
1117  break;
1118  case KAlarm::UPDATE_ERROR:
1119  case KAlarm::UPDATE_FAILED:
1120  case KAlarm::SAVE_FAILED:
1121  mRestoreError = ERR_CREATE;
1122  return 0;
1123  case KAlarm::UPDATE_OK:
1124  break;
1125  }
1126  }
1127 #ifdef USE_AKONADI
1128  KAlarm::setDontShowErrors(EventId(*mEvent), mDontShowErrors);
1129 #else
1130  KAlarm::setDontShowErrors(mEvent->id(), mDontShowErrors);
1131 #endif
1132  break;
1133  case CalEvent::TEMPLATE:
1134 #ifdef USE_AKONADI
1135  if (KAlarm::addTemplate(*mEvent, &mResource) != KAlarm::UPDATE_OK)
1136 #else
1137  if (KAlarm::addTemplate(*mEvent, mResource) != KAlarm::UPDATE_OK)
1138 #endif
1139  {
1140  mRestoreError = ERR_CREATE;
1141  return 0;
1142  }
1143  break;
1144  case CalEvent::ARCHIVED:
1145 #ifdef USE_AKONADI
1146  if (!KAlarm::addArchivedEvent(*mEvent, &mResource))
1147 #else
1148  if (!KAlarm::addArchivedEvent(*mEvent, mResource))
1149 #endif
1150  {
1151  mRestoreError = ERR_CREATE;
1152  return 0;
1153  }
1154  break;
1155  default:
1156  mRestoreError = ERR_PROG;
1157  return 0;
1158  }
1159 
1160  // Create a redo item to delete the alarm again
1161  return createRedo(*mEvent, mResource);
1162 }
1163 
1164 /******************************************************************************
1165 * Create a redo item to archive the alarm again.
1166 */
1167 UndoItem* UndoDelete::createRedo(const KAEvent& event, RESOURCE_PARAM_TYPE resource)
1168 {
1169  Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
1170  return new UndoAdd(t, event, resource, mName);
1171 }
1172 
1173 /******************************************************************************
1174 * Return the action description of the Undo item for displaying.
1175 */
1176 QString UndoDelete::defaultActionText() const
1177 {
1178  return addDeleteActionText(calendar(), (type() == Undo::REDO));
1179 }
1180 
1181 
1182 /*=============================================================================
1183 = Class: UndoDeletes
1184 = Undo item for multiple alarm deletion.
1185 =============================================================================*/
1186 
1187 /******************************************************************************
1188 * Create a redo item to delete the alarms again.
1189 */
1190 UndoItem* UndoDeletes::createRedo(Undo::List* undos)
1191 {
1192  Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
1193  return new UndoDeletes(t, undos, mName);
1194 }
1195 
1196 /******************************************************************************
1197 * Return the action description of the Undo item for displaying.
1198 */
1199 QString UndoDeletes::defaultActionText() const
1200 {
1201  if (mUndos->isEmpty())
1202  return QString();
1203  for (int i = 0, end = mUndos->count(); i < end; ++i)
1204  {
1205  switch ((*mUndos)[i]->calendar())
1206  {
1207  case CalEvent::ACTIVE:
1208  return i18nc("@info/plain", "Delete multiple alarms");
1209  case CalEvent::TEMPLATE:
1210  return i18nc("@info/plain", "Delete multiple templates");
1211  case CalEvent::ARCHIVED:
1212  break; // check if they are ALL archived
1213  default:
1214  return QString();
1215  }
1216  }
1217  return i18nc("@info/plain", "Delete multiple archived alarms");
1218 }
1219 
1220 
1221 /*=============================================================================
1222 = Class: UndoReactivate
1223 = Undo item for alarm reactivation.
1224 =============================================================================*/
1225 
1226 /******************************************************************************
1227 * Undo the item, i.e. re-archive the alarm which was reactivated.
1228 * Create a redo item to reactivate the alarm back again.
1229 * Reply = redo item.
1230 */
1231 UndoItem* UndoReactivate::restore()
1232 {
1233  kDebug();
1234  // Validate the alarm's calendar
1235  switch (calendar())
1236  {
1237  case CalEvent::ACTIVE:
1238  break;
1239  default:
1240  mRestoreError = ERR_PROG;
1241  return 0;
1242  }
1243  return UndoAdd::doRestore(true); // restore alarm, ensuring that it is re-archived
1244 }
1245 
1246 /******************************************************************************
1247 * Create a redo item to add the alarm back again.
1248 */
1249 UndoItem* UndoReactivate::createRedo(const KAEvent& event, RESOURCE_PARAM_TYPE resource)
1250 {
1251  Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
1252  return new UndoDeactivate(t, event, resource, mName);
1253 }
1254 
1255 /******************************************************************************
1256 * Return the action description of the Undo item for displaying.
1257 */
1258 QString UndoReactivate::defaultActionText() const
1259 {
1260  return i18nc("@info/plain", "Reactivate alarm");
1261 }
1262 
1263 
1264 /*=============================================================================
1265 = Class: UndoDeactivate
1266 = Redo item for alarm reactivation.
1267 =============================================================================*/
1268 
1269 /******************************************************************************
1270 * Undo the item, i.e. reactivate an alarm which was archived.
1271 * Create a redo item to archive the alarm again.
1272 * Reply = redo item.
1273 */
1274 UndoItem* UndoDeactivate::restore()
1275 {
1276  kDebug();
1277  // Validate the alarm's calendar
1278  switch (calendar())
1279  {
1280  case CalEvent::ACTIVE:
1281  break;
1282  default:
1283  mRestoreError = ERR_PROG;
1284  return 0;
1285  }
1286 
1287  return UndoDelete::restore();
1288 }
1289 
1290 /******************************************************************************
1291 * Create a redo item to archive the alarm again.
1292 */
1293 UndoItem* UndoDeactivate::createRedo(const KAEvent& event, RESOURCE_PARAM_TYPE resource)
1294 {
1295  Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
1296  return new UndoReactivate(t, event, resource, mName);
1297 }
1298 
1299 /******************************************************************************
1300 * Return the action description of the Undo item for displaying.
1301 */
1302 QString UndoDeactivate::defaultActionText() const
1303 {
1304  return i18nc("@info/plain", "Reactivate alarm");
1305 }
1306 
1307 
1308 /*=============================================================================
1309 = Class: UndoReactivates
1310 = Undo item for multiple alarm reactivation.
1311 =============================================================================*/
1312 
1313 /******************************************************************************
1314 * Create a redo item to reactivate the alarms again.
1315 */
1316 UndoItem* UndoReactivates::createRedo(Undo::List* undos)
1317 {
1318  Undo::Type t = (type() == Undo::UNDO) ? Undo::REDO : (type() == Undo::REDO) ? Undo::UNDO : Undo::NONE;
1319  return new UndoReactivates(t, undos, mName);
1320 }
1321 
1322 /******************************************************************************
1323 * Return the action description of the Undo item for displaying.
1324 */
1325 QString UndoReactivates::defaultActionText() const
1326 {
1327  return i18nc("@info/plain", "Reactivate multiple alarms");
1328 }
1329 
1330 
1331 /*=============================================================================
1332 = Class: Event
1333 = Event details for external calls.
1334 =============================================================================*/
1335 Undo::Event::Event(const KAEvent& e, RESOURCE_PARAM_TYPE r)
1336  : event(e),
1337  EVENT_RESOURCE(r)
1338 {
1339  if (e.category() == CalEvent::ACTIVE)
1340 #ifdef USE_AKONADI
1341  dontShowErrors = KAlarm::dontShowErrors(EventId(e));
1342 #else
1343  dontShowErrors = KAlarm::dontShowErrors(e.id());
1344 #endif
1345 }
1346 
1347 // vim: et sw=4:
Undo::emitChanged
static void emitChanged()
Definition: undo.cpp:590
Undo::Event::dontShowErrors
QStringList dontShowErrors
Definition: undo.h:65
maxCount
static int maxCount
Definition: undo.cpp:37
Undo::NONE
Definition: undo.h:47
Undo::UNDO
Definition: undo.h:47
undo.h
undo/redo facility
QWidget
Undo::description
static QString description(Type, int id)
Definition: undo.cpp:524
Undo::saveEdit
static void saveEdit(const Event &oldEvent, const KAEvent &newEvent)
Definition: undo.cpp:329
alarmcalendar.h
Undo::Event
Definition: undo.h:51
Undo::saveDeletes
static void saveDeletes(const EventList &, const QString &name=QString())
Definition: undo.cpp:343
AlarmCalendar::getEvent
static KAEvent * getEvent(const QString &uniqueId)
Definition: alarmcalendar.cpp:150
Undo::Type
Type
Definition: undo.h:47
Undo::saveAdds
static void saveAdds(const EventList &, const QString &name=QString())
Definition: undo.cpp:317
Undo::EventList
Definition: undo.h:67
Undo
Definition: undo.h:43
Undo::ids
static QList< int > ids(Type)
Definition: undo.cpp:536
Undo::Event::Event
Event()
Definition: undo.h:53
RESOURCE_PARAM_TYPE
#define RESOURCE_PARAM_TYPE
Definition: undo.cpp:48
EVENT_RESOURCE
#define EVENT_RESOURCE
Definition: undo.cpp:49
Undo::saveReactivate
static void saveReactivate(const KAEvent &, AlarmResource *, const QString &name=QString())
Definition: undo.cpp:357
messagebox.h
T
Undo::undo
static bool undo(QWidget *parent, const QString &action)
Definition: undo.h:93
Undo::remove
static void remove(UndoItem *, bool undo)
Definition: undo.cpp:478
Undo::saveAdd
static void saveAdd(const KAEvent &, AlarmResource *, const QString &name=QString())
Definition: undo.cpp:311
EventId
Unique event identifier for Akonadi.
Definition: eventid.h:38
Undo::REDO
Definition: undo.h:47
Undo::saveReactivates
static void saveReactivates(const EventList &, const QString &name=QString())
Definition: undo.cpp:363
Undo::replace
static void replace(UndoItem *old, UndoItem *New)
Definition: undo.cpp:488
Undo::saveDelete
static void saveDelete(const Event &, const QString &name=QString())
Definition: undo.cpp:336
functions.h
miscellaneous functions
KAMessageBox::sorry
static void sorry(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Options(Notify|WindowModal))
kalarm.h
Undo::clear
static void clear()
Definition: undo.cpp:293
Undo::add
static void add(UndoItem *, bool undo)
Definition: undo.cpp:454
Undo::actionText
static QString actionText(Type)
Definition: undo.cpp:506
Undo::List
AutoDeleteList< UndoItem > List
Definition: undo.h:111
AutoDeleteList
Undo::instance
static Undo * instance()
Definition: undo.cpp:283
Undo::Event::event
KAEvent event
Definition: undo.h:59
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:59:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalarm

Skip menu "kalarm"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal