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

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
  • calendar
calendarbase.cpp
1 /*
2  Copyright (C) 2011 Sérgio Martins <sergio.martins@kdab.com>
3  Copyright (C) 2012 Sérgio Martins <iamsergio@gmail.com>
4 
5  This library is free software; you can redistribute it and/or modify it
6  under the terms of the GNU Library General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or (at your
8  option) any later version.
9 
10  This library is distributed in the hope that it will be useful, but WITHOUT
11  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13  License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to the
17  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  02110-1301, USA.
19 */
20 
21 #include "calendarbase.h"
22 #include "calendarbase_p.h"
23 #include "incidencechanger.h"
24 #include "utils_p.h"
25 
26 #include <akonadi/item.h>
27 #include <akonadi/collection.h>
28 
29 #include <KSystemTimeZones>
30 #include <KLocale>
31 
32 using namespace Akonadi;
33 using namespace KCalCore;
34 
35 static QString itemToString(const Akonadi::Item &item)
36 {
37  const KCalCore::Incidence::Ptr &incidence = CalendarUtils::incidence(item);
38  QString str;
39  QTextStream stream(&str);
40  stream << item.id()
41  << "; summary=" << incidence->summary() << "; uid=" << incidence->uid() << "; type="
42  << incidence->type() << "; recurs=" << incidence->recurs() << "; recurrenceId="
43  << incidence->recurrenceId().toString() << "; dtStart=" << incidence->dtStart().toString()
44  << "; dtEnd=" << incidence->dateTime(Incidence::RoleEnd).toString()
45  << "; parentCollection=" << item.storageCollectionId() << item.parentCollection().displayName();
46 
47  return str;
48 }
49 
50 CalendarBasePrivate::CalendarBasePrivate(CalendarBase *qq) : QObject()
51  , mIncidenceChanger(new IncidenceChanger())
52  , mBatchInsertionCancelled(false)
53  , mListensForNewItems(false)
54  , mLastCreationCancelled(false)
55  , q(qq)
56 {
57  connect(mIncidenceChanger,
58  SIGNAL(createFinished(int,Akonadi::Item,Akonadi::IncidenceChanger::ResultCode,QString)),
59  SLOT(slotCreateFinished(int,Akonadi::Item,Akonadi::IncidenceChanger::ResultCode,QString)));
60 
61  connect(mIncidenceChanger,
62  SIGNAL(deleteFinished(int,QVector<Akonadi::Item::Id>,Akonadi::IncidenceChanger::ResultCode,QString)),
63  SLOT(slotDeleteFinished(int,QVector<Akonadi::Item::Id>,Akonadi::IncidenceChanger::ResultCode,QString)));
64 
65  connect(mIncidenceChanger,
66  SIGNAL(modifyFinished(int,Akonadi::Item,Akonadi::IncidenceChanger::ResultCode,QString)),
67  SLOT(slotModifyFinished(int,Akonadi::Item,Akonadi::IncidenceChanger::ResultCode,QString)));
68 
69  mIncidenceChanger->setDestinationPolicy(IncidenceChanger::DestinationPolicyAsk);
70  mIncidenceChanger->setGroupwareCommunication(false);
71  mIncidenceChanger->setHistoryEnabled(false);
72 }
73 
74 CalendarBasePrivate::~CalendarBasePrivate()
75 {
76  delete mIncidenceChanger;
77  mIncidenceChanger = 0;
78 }
79 
80 void CalendarBasePrivate::internalInsert(const Akonadi::Item &item)
81 {
82  Q_ASSERT(item.isValid());
83  Q_ASSERT(item.hasPayload<KCalCore::Incidence::Ptr>());
84  KCalCore::Incidence::Ptr incidence = CalendarUtils::incidence(item);
85 
86  if (!incidence) {
87  kError() << "Incidence is null. id=" << item.id()
88  << "; hasPayload()=" << item.hasPayload()
89  << "; has incidence=" << item.hasPayload<KCalCore::Incidence::Ptr>()
90  << "; mime type=" << item.mimeType();
91  Q_ASSERT(false);
92  return;
93  }
94 
95  //kDebug() << "Inserting incidence in calendar. id=" << item.id() << "uid=" << incidence->uid();
96  const QString uid = incidence->instanceIdentifier();
97 
98  if (uid.isEmpty()) {
99  // This code path should never happen
100  kError() << "Incidence has empty UID. id=" << item.id()
101  << "; summary=" << incidence->summary()
102  << "Please fix it. Ignoring this incidence.";
103  return;
104  }
105 
106  if (mItemIdByUid.contains(uid) && mItemIdByUid[uid] != item.id()) {
107  // We only allow duplicate UIDs if they have the same item id, for example
108  // when using virtual folders.
109  kWarning() << "Discarding duplicate incidence with instanceIdentifier=" << uid
110  << "and summary " << incidence->summary()
111  << "; recurrenceId() =" << incidence->recurrenceId()
112  << "; new id=" << item.id()
113  << "; existing id=" << mItemIdByUid[uid];
114  return;
115  }
116 
117  if (incidence->type() == KCalCore::Incidence::TypeEvent && !incidence->dtStart().isValid()) {
118  // TODO: make the parser discard them would also be a good idea
119  kWarning() << "Discarding event with invalid DTSTART. identifier="
120  << incidence->instanceIdentifier() << "; summary=" << incidence->summary();
121  return;
122  }
123 
124  Akonadi::Collection collection = item.parentCollection();
125  if (collection.isValid()) {
126  // Some items don't have collection set
127  incidence->setReadOnly(!(collection.rights() & Akonadi::Collection::CanChangeItem));
128  }
129 
130  mItemById.insert(item.id(), item);
131  mItemIdByUid.insert(uid, item.id());
132  mItemsByCollection.insert(item.storageCollectionId(), item);
133 
134  if (!incidence->hasRecurrenceId()) {
135  // Insert parent relationships
136  const QString parentUid = incidence->relatedTo();
137  if (!parentUid.isEmpty()) {
138  mParentUidToChildrenUid[parentUid].append(incidence->uid());
139  mUidToParent.insert(uid, parentUid);
140  }
141  }
142 
143  incidence->setCustomProperty("VOLATILE", "AKONADI-ID", QString::number(item.id()));
144  // Must be the last one due to re-entrancy
145  const bool result = q->MemoryCalendar::addIncidence(incidence);
146  if (!result) {
147  kError() << "Error adding incidence " << itemToString(item);
148  Q_ASSERT(false);
149  }
150 }
151 
152 void CalendarBasePrivate::internalRemove(const Akonadi::Item &item)
153 {
154  Q_ASSERT(item.isValid());
155 
156  Incidence::Ptr tmp = CalendarUtils::incidence(item);
157  if (!tmp) {
158  kError() << "CalendarBase::internalRemove1: incidence is null, item.id=" << item.id();
159  return;
160  }
161 
162  // We want the one stored in the calendar
163  Incidence::Ptr incidence = q->incidence(tmp->uid(), tmp->recurrenceId());
164 
165  // Null incidence means it was deleted via CalendarBase::deleteIncidence(), but then
166  // the ETMCalendar received the monitor notification and tried to delete it again.
167  if (incidence) {
168  mItemById.remove(item.id());
169  // kDebug() << "Deleting incidence from calendar .id=" << item.id() << "uid=" << incidence->uid();
170  mItemIdByUid.remove(incidence->instanceIdentifier());
171 
172  mItemsByCollection.remove(item.storageCollectionId(), item);
173 
174  if (!incidence->hasRecurrenceId()) {
175  const QString uid = incidence->uid();
176  const QString parentUid = incidence->relatedTo();
177  mParentUidToChildrenUid.remove(uid);
178  if (!parentUid.isEmpty()) {
179  mParentUidToChildrenUid[parentUid].removeAll(uid);
180  mUidToParent.remove(uid);
181  }
182  }
183  // Must be the last one due to re-entrancy
184  const bool result = q->MemoryCalendar::deleteIncidence(incidence);
185  if (!result) {
186  kError() << "Error removing incidence " << itemToString(item);
187  Q_ASSERT(false);
188  }
189  } else {
190  kWarning() << "CalendarBase::internalRemove2: incidence is null, item.id=" << itemToString(item);
191  }
192 }
193 
194 void CalendarBasePrivate::deleteAllIncidencesOfType(const QString &mimeType)
195 {
196  kWarning() << "Refusing to delete your Incidences.";
197  Q_UNUSED(mimeType);
198  /*
199  QHash<Item::Id, Item>::iterator i;
200  Item::List incidences;
201  for ( i = mItemById.begin(); i != mItemById.end(); ++i ) {
202  if ( i.value().payload<KCalCore::Incidence::Ptr>()->mimeType() == mimeType )
203  incidences.append( i.value() );
204  }
205 
206  mIncidenceChanger->deleteIncidences( incidences );
207  */
208 }
209 
210 void CalendarBasePrivate::slotDeleteFinished(int changeId,
211  const QVector<Akonadi::Item::Id> &itemIds,
212  IncidenceChanger::ResultCode resultCode,
213  const QString &errorMessage)
214 {
215  Q_UNUSED(changeId);
216  if (resultCode == IncidenceChanger::ResultCodeSuccess) {
217  foreach(const Akonadi::Item::Id &id, itemIds) {
218  if (mItemById.contains(id))
219  internalRemove(mItemById.value(id));
220  }
221  }
222 
223  emit q->deleteFinished(resultCode == IncidenceChanger::ResultCodeSuccess, errorMessage);
224 }
225 
226 void CalendarBasePrivate::slotCreateFinished(int changeId,
227  const Akonadi::Item &item,
228  IncidenceChanger::ResultCode resultCode,
229  const QString &errorMessage)
230 {
231  Q_UNUSED(changeId);
232  Q_UNUSED(item);
233  if (resultCode == IncidenceChanger::ResultCodeSuccess && !mListensForNewItems) {
234  Q_ASSERT(item.isValid());
235  Q_ASSERT(item.hasPayload<KCalCore::Incidence::Ptr>());
236  internalInsert(item);
237  }
238 
239  mLastCreationCancelled = (resultCode == IncidenceChanger::ResultCodeUserCanceled);
240 
241  emit q->createFinished(resultCode == IncidenceChanger::ResultCodeSuccess, errorMessage);
242 }
243 
244 void CalendarBasePrivate::slotModifyFinished(int changeId,
245  const Akonadi::Item &item,
246  IncidenceChanger::ResultCode resultCode,
247  const QString &errorMessage)
248 {
249  Q_UNUSED(changeId);
250  Q_UNUSED(item);
251  QString message = errorMessage;
252  if (resultCode == IncidenceChanger::ResultCodeSuccess) {
253  KCalCore::Incidence::Ptr incidence = CalendarUtils::incidence(item);
254  Q_ASSERT(incidence);
255  KCalCore::Incidence::Ptr localIncidence = q->incidence(incidence->instanceIdentifier());
256 
257  if (localIncidence) {
258  //update our local one
259  *(static_cast<KCalCore::IncidenceBase*>(localIncidence.data())) = *(incidence.data());
260  } else {
261  // This shouldn't happen, unless the incidence gets deleted between event loops
262  kWarning() << "CalendarBasePrivate::slotModifyFinished() Incidence was deleted already probably? id=" << item.id();
263  message = i18n("Could not find incidence to update, it probably was deleted recently.");
264  resultCode = IncidenceChanger::ResultCodeAlreadyDeleted;
265  }
266  }
267  emit q->modifyFinished(resultCode == IncidenceChanger::ResultCodeSuccess, message);
268 }
269 
270 void CalendarBasePrivate::handleUidChange(const Akonadi::Item &oldItem,
271  const Akonadi::Item &newItem, const QString &newIdentifier)
272 {
273  Q_ASSERT(oldItem.isValid());
274  Incidence::Ptr newIncidence = CalendarUtils::incidence(newItem);
275  Q_ASSERT(newIncidence);
276  Incidence::Ptr oldIncidence = CalendarUtils::incidence(oldItem);
277  Q_ASSERT(oldIncidence);
278 
279  const QString newUid = newIncidence->uid();
280  if (mItemIdByUid.contains(newIdentifier)) {
281  Incidence::Ptr oldIncidence = CalendarUtils::incidence(oldItem);
282  kWarning() << "New uid shouldn't be known: " << newIdentifier << "; id="
283  << newItem.id() << "; oldItem.id=" << mItemIdByUid[newIdentifier]
284  << "; new summary= " << newIncidence->summary()
285  << "; new recurrenceId=" << newIncidence->recurrenceId()
286  << "; oldIncidence" << oldIncidence;
287  if (oldIncidence) {
288  kWarning() << "; oldIncidence uid=" << oldIncidence->uid()
289  << "; oldIncidence recurrenceId = " << oldIncidence->recurrenceId()
290  << "; oldIncidence summary = " << oldIncidence->summary();
291  }
292  Q_ASSERT(false);
293  return;
294  }
295 
296  mItemIdByUid[newIdentifier] = newItem.id();
297 
298  // Get the real pointer
299  oldIncidence = q->MemoryCalendar::incidence(oldIncidence->uid());
300 
301  if (!oldIncidence) {
302  // How can this happen ?
303  kWarning() << "Couldn't find old incidence";
304  Q_ASSERT(false);
305  return;
306  }
307 
308  if (newIncidence->instanceIdentifier() == oldIncidence->instanceIdentifier()) {
309  kWarning() << "New uid=" << newIncidence->uid() << "; old uid=" << oldIncidence->uid()
310  << "; new recurrenceId="
311  << newIncidence->recurrenceId()
312  << "; old recurrenceId=" << oldIncidence->recurrenceId()
313  << "; new summary = " << newIncidence->summary()
314  << "; old summary = " << oldIncidence->summary()
315  << "; id = " << newItem.id();
316  Q_ASSERT(false); // The reason we're here in the first place
317  return;
318  }
319 
320  mItemIdByUid.remove(oldIncidence->instanceIdentifier());
321  const QString oldUid = oldIncidence->uid();
322 
323  if (mParentUidToChildrenUid.contains(oldUid)) {
324  Q_ASSERT(!mParentUidToChildrenUid.contains(newIdentifier));
325  QStringList children = mParentUidToChildrenUid.value(oldUid);
326  mParentUidToChildrenUid.insert(newIdentifier, children);
327  mParentUidToChildrenUid.remove(oldUid);
328  }
329 
330  // Update internal maps of the base class, MemoryCalendar
331  q->setObserversEnabled(false);
332  q->MemoryCalendar::deleteIncidence(oldIncidence);
333  q->MemoryCalendar::addIncidence(newIncidence);
334 
335  newIncidence->setUid(oldUid); // We set and unset just to notify observers of a change.
336  q->setObserversEnabled(true);
337  newIncidence->setUid(newUid);
338 }
339 
340 void CalendarBasePrivate::handleParentChanged(const KCalCore::Incidence::Ptr &newIncidence)
341 {
342  Q_ASSERT(newIncidence);
343 
344  if (newIncidence->hasRecurrenceId()) { // These ones don't/shouldn't have a parent
345  return;
346  }
347 
348  const QString originalParentUid = mUidToParent.value(newIncidence->uid());
349  const QString newParentUid = newIncidence->relatedTo();
350 
351  if (originalParentUid == newParentUid) {
352  return; // nothing changed
353  }
354 
355  if (!originalParentUid.isEmpty()) {
356  // Remove this child from it's old parent:
357  Q_ASSERT(mParentUidToChildrenUid.contains(originalParentUid));
358  mParentUidToChildrenUid[originalParentUid].removeAll(newIncidence->uid());
359  }
360 
361  mUidToParent.remove(newIncidence->uid());
362 
363  if (!newParentUid.isEmpty()) {
364  // Deliver this child to it's new parent:
365  Q_ASSERT(!mParentUidToChildrenUid[newParentUid].contains(newIncidence->uid()));
366  mParentUidToChildrenUid[newParentUid].append(newIncidence->uid());
367  mUidToParent.insert(newIncidence->uid(), newParentUid);
368  }
369 }
370 
371 CalendarBase::CalendarBase(QObject *parent) : MemoryCalendar(KSystemTimeZones::local())
372  , d_ptr(new CalendarBasePrivate(this))
373 {
374  setParent(parent);
375  setDeletionTracking(false);
376 }
377 
378 CalendarBase::CalendarBase(CalendarBasePrivate *const dd,
379  QObject *parent) : MemoryCalendar(KSystemTimeZones::local())
380  , d_ptr(dd)
381 {
382  setParent(parent);
383  setDeletionTracking(false);
384 }
385 
386 CalendarBase::~CalendarBase()
387 {
388 }
389 
390 Akonadi::Item CalendarBase::item(Akonadi::Item::Id id) const
391 {
392  Q_D(const CalendarBase);
393  Akonadi::Item i;
394  if (d->mItemById.contains(id)) {
395  i = d->mItemById[id];
396  } else {
397  kDebug() << "Can't find any item with id " << id;
398  }
399  return i;
400 }
401 
402 Akonadi::Item CalendarBase::item(const QString &uid) const
403 {
404  Q_D(const CalendarBase);
405  Akonadi::Item i;
406 
407  if (uid.isEmpty())
408  return i;
409 
410  if (d->mItemIdByUid.contains(uid)) {
411  const Akonadi::Item::Id id = d->mItemIdByUid[uid];
412  if (!d->mItemById.contains(id)) {
413  kError() << "Item with id " << id << "(uid=" << uid << ") not found, but in uid map";
414  Q_ASSERT_X(false, "CalendarBase::item", "not in mItemById");
415  }
416  i = d->mItemById[id];
417  } else {
418  kDebug() << "Can't find any incidence with uid " << uid;
419  }
420  return i;
421 }
422 
423 Item CalendarBase::item(const Incidence::Ptr &incidence) const
424 {
425  return incidence ? item(incidence->instanceIdentifier()) : Item();
426 }
427 
428 Akonadi::Item::List CalendarBase::items() const
429 {
430  Q_D(const CalendarBase);
431  return d->mItemById.values();
432 }
433 
434 Akonadi::Item::List CalendarBase::items(Akonadi::Collection::Id id) const
435 {
436  Q_D(const CalendarBase);
437  return d->mItemsByCollection.values(id);
438 }
439 
440 Akonadi::Item::List CalendarBase::itemList(const KCalCore::Incidence::List &incidences) const
441 {
442  Akonadi::Item::List items;
443 
444  foreach(const KCalCore::Incidence::Ptr &incidence, incidences) {
445  if (incidence) {
446  items << item(incidence->instanceIdentifier());
447  } else {
448  items << Akonadi::Item();
449  }
450  }
451 
452  return items;
453 }
454 
455 KCalCore::Incidence::List CalendarBase::childIncidences(const Akonadi::Item::Id &parentId) const
456 {
457  Q_D(const CalendarBase);
458  KCalCore::Incidence::List childs;
459 
460  if (d->mItemById.contains(parentId)) {
461  const Akonadi::Item item = d->mItemById.value(parentId);
462  Q_ASSERT(item.isValid());
463  KCalCore::Incidence::Ptr parent = CalendarUtils::incidence(item);
464 
465  if (parent) {
466  childs = childIncidences(parent->uid());
467  } else {
468  Q_ASSERT(false);
469  }
470  }
471 
472  return childs;
473 }
474 
475 KCalCore::Incidence::List CalendarBase::childIncidences(const QString &parentUid) const
476 {
477  Q_D(const CalendarBase);
478  KCalCore::Incidence::List children;
479  const QStringList uids = d->mParentUidToChildrenUid.value(parentUid);
480  Q_FOREACH(const QString &uid, uids) {
481  Incidence::Ptr child = incidence(uid);
482  if (child)
483  children.append(child);
484  else
485  kWarning() << "Invalid child with uid " << uid;
486  }
487  return children;
488 }
489 
490 Akonadi::Item::List CalendarBase::childItems(const Akonadi::Item::Id &parentId) const
491 {
492  Q_D(const CalendarBase);
493  Akonadi::Item::List childs;
494 
495  if (d->mItemById.contains(parentId)) {
496  const Akonadi::Item item = d->mItemById.value(parentId);
497  Q_ASSERT(item.isValid());
498  KCalCore::Incidence::Ptr parent = CalendarUtils::incidence(item);
499 
500  if (parent) {
501  childs = childItems(parent->uid());
502  } else {
503  Q_ASSERT(false);
504  }
505  }
506 
507  return childs;
508 }
509 
510 Akonadi::Item::List CalendarBase::childItems(const QString &parentUid) const
511 {
512  Q_D(const CalendarBase);
513  Akonadi::Item::List children;
514  const QStringList uids = d->mParentUidToChildrenUid.value(parentUid);
515  Q_FOREACH(const QString &uid, uids) {
516  Akonadi::Item child = item(uid);
517  if (child.isValid() && child.hasPayload<KCalCore::Incidence::Ptr>())
518  children.append(child);
519  else
520  kWarning() << "Invalid child with uid " << uid;
521  }
522  return children;
523 }
524 
525 bool CalendarBase::addEvent(const KCalCore::Event::Ptr &event)
526 {
527  return addIncidence(event);
528 }
529 
530 bool CalendarBase::deleteEvent(const KCalCore::Event::Ptr &event)
531 {
532  return deleteIncidence(event);
533 }
534 
535 void CalendarBase::deleteAllEvents()
536 {
537  Q_D(CalendarBase);
538  d->deleteAllIncidencesOfType(Event::eventMimeType());
539 }
540 
541 bool CalendarBase::addTodo(const KCalCore::Todo::Ptr &todo)
542 {
543  return addIncidence(todo);
544 }
545 
546 bool CalendarBase::deleteTodo(const KCalCore::Todo::Ptr &todo)
547 {
548  return deleteIncidence(todo);
549 }
550 
551 void CalendarBase::deleteAllTodos()
552 {
553  Q_D(CalendarBase);
554  d->deleteAllIncidencesOfType(Todo::todoMimeType());
555 }
556 
557 bool CalendarBase::addJournal(const KCalCore::Journal::Ptr &journal)
558 {
559  return addIncidence(journal);
560 }
561 
562 bool CalendarBase::deleteJournal(const KCalCore::Journal::Ptr &journal)
563 {
564  return deleteIncidence(journal);
565 }
566 
567 void CalendarBase::deleteAllJournals()
568 {
569  Q_D(CalendarBase);
570  d->deleteAllIncidencesOfType(Journal::journalMimeType());
571 }
572 
573 bool CalendarBase::addIncidence(const KCalCore::Incidence::Ptr &incidence)
574 {
575  //TODO: Parent for dialogs
576  Q_D(CalendarBase);
577 
578  // User canceled on the collection selection dialog
579  if (batchAdding() && d->mBatchInsertionCancelled) {
580  return false;
581  }
582 
583  d->mLastCreationCancelled = false;
584 
585  Akonadi::Collection collection;
586 
587  if (batchAdding() && d->mCollectionForBatchInsertion.isValid()) {
588  collection = d->mCollectionForBatchInsertion;
589  }
590 
591  if (incidence->hasRecurrenceId() && !collection.isValid()) {
592  // We are creating an exception, reuse the same collection that the main incidence uses
593  Item mainItem = item(incidence->uid());
594  if (mainItem.isValid()) {
595  collection = Collection(mainItem.storageCollectionId());
596  }
597  }
598 
599  const int changeId = d->mIncidenceChanger->createIncidence(incidence, collection);
600 
601  if (batchAdding()) {
602  const Akonadi::Collection lastCollection = d->mIncidenceChanger->lastCollectionUsed();
603  if (changeId != -1 && !lastCollection.isValid()) {
604  d->mBatchInsertionCancelled = true;
605  } else if (lastCollection.isValid() && !d->mCollectionForBatchInsertion.isValid()) {
606  d->mCollectionForBatchInsertion = d->mIncidenceChanger->lastCollectionUsed();
607  }
608  }
609 
610  return changeId != -1;
611 }
612 
613 bool CalendarBase::deleteIncidence(const KCalCore::Incidence::Ptr &incidence)
614 {
615  Q_D(CalendarBase);
616  Q_ASSERT(incidence);
617  Akonadi::Item item_ = item(incidence->instanceIdentifier());
618  return -1 != d->mIncidenceChanger->deleteIncidence(item_);
619 }
620 
621 bool CalendarBase::modifyIncidence(const KCalCore::Incidence::Ptr &newIncidence)
622 {
623  Q_D(CalendarBase);
624  Q_ASSERT(newIncidence);
625  Akonadi::Item item_ = item(newIncidence->instanceIdentifier());
626  item_.setPayload<KCalCore::Incidence::Ptr>(newIncidence);
627  return -1 != d->mIncidenceChanger->modifyIncidence(item_);
628 }
629 
630 void CalendarBase::setWeakPointer(const QWeakPointer<CalendarBase> &pointer)
631 {
632  Q_D(CalendarBase);
633  d->mWeakPointer = pointer;
634 }
635 
636 QWeakPointer<CalendarBase> CalendarBase::weakPointer() const
637 {
638  Q_D(const CalendarBase);
639  return d->mWeakPointer;
640 }
641 
642 IncidenceChanger* CalendarBase::incidenceChanger() const
643 {
644  Q_D(const CalendarBase);
645  return d->mIncidenceChanger;
646 }
647 
648 void CalendarBase::startBatchAdding()
649 {
650  KCalCore::MemoryCalendar::startBatchAdding();
651 }
652 
653 void CalendarBase::endBatchAdding()
654 {
655  Q_D(CalendarBase);
656  d->mCollectionForBatchInsertion = Akonadi::Collection();
657  d->mBatchInsertionCancelled = false;
658  KCalCore::MemoryCalendar::endBatchAdding();
659 }
660 
661 #include "moc_calendarbase.cpp"
662 #include "moc_calendarbase_p.cpp"
Akonadi::CalendarBase::deleteAllJournals
void deleteAllJournals()
Reimplementation of KCalCore::Calendar::deleteAllJournals() that does nothing.
Definition: calendarbase.cpp:567
Akonadi::CalendarBase::startBatchAdding
void startBatchAdding()
Call this to tell the calendar that you're adding a batch of incidences.
Definition: calendarbase.cpp:648
Akonadi::Collection
Represents a collection of PIM items.
Definition: collection.h:75
Akonadi::Entity::Id
qint64 Id
Describes the unique id type.
Definition: entity.h:65
Akonadi::CalendarBase::items
Akonadi::Item::List items() const
Returns the list of items contained in this calendar.
Definition: calendarbase.cpp:428
Akonadi::CalendarBase::item
Akonadi::Item item(const QString &uid) const
Returns the Item containing the incidence with uid uid or an invalid Item if the incidence isn't foun...
Definition: calendarbase.cpp:402
Akonadi::Collection::CanChangeItem
Can change items in this collection.
Definition: collection.h:88
Akonadi::CalendarBase::addTodo
bool addTodo(const KCalCore::Todo::Ptr &todo)
Adds a Todo to the calendar.
Definition: calendarbase.cpp:541
Akonadi::CalendarBase::deleteEvent
bool deleteEvent(const KCalCore::Event::Ptr &event)
Deletes an Event from the calendar.
Definition: calendarbase.cpp:530
Akonadi::CalendarBase::itemList
Akonadi::Item::List itemList(const KCalCore::Incidence::List &incidenceList) const
Returns the item list that corresponds to the incidenceList.
Definition: calendarbase.cpp:440
Akonadi::CalendarBase::addJournal
bool addJournal(const KCalCore::Journal::Ptr &journal)
Adds a Journal to the calendar.
Definition: calendarbase.cpp:557
Akonadi::CalendarBase::deleteIncidence
bool deleteIncidence(const KCalCore::Incidence::Ptr &)
Deletes an incidence from the calendar.
Definition: calendarbase.cpp:613
Akonadi::CalendarBase::deleteTodo
bool deleteTodo(const KCalCore::Todo::Ptr &todo)
Deletes a Todo from the calendar.
Definition: calendarbase.cpp:546
Akonadi::CalendarBase::~CalendarBase
~CalendarBase()
Destroys the calendar.
Definition: calendarbase.cpp:386
Akonadi::CalendarBase::deleteJournal
bool deleteJournal(const KCalCore::Journal::Ptr &journal)
Deletes a Journal from the calendar.
Definition: calendarbase.cpp:562
Akonadi::Collection::rights
Rights rights() const
Returns the rights the user has on the collection.
Definition: collection.cpp:99
Akonadi::CalendarBase::CalendarBase
CalendarBase(QObject *parent=0)
Constructs a CalendarBase object.
Definition: calendarbase.cpp:371
Akonadi::CalendarBase::addEvent
bool addEvent(const KCalCore::Event::Ptr &event)
Adds an Event to the calendar.
Definition: calendarbase.cpp:525
Akonadi::CalendarBase::modifyIncidence
bool modifyIncidence(const KCalCore::Incidence::Ptr &newIncidence)
Modifies an incidence.
Definition: calendarbase.cpp:621
Akonadi::CalendarBase::childItems
Akonadi::Item::List childItems(const QString &parentUid) const
Returns the child items of the parent identified by parentUid.
Definition: calendarbase.cpp:510
Akonadi::CalendarBase::childIncidences
KCalCore::Incidence::List childIncidences(const QString &parentUid) const
Returns the child incidences of the parent identified by parentUid.
Definition: calendarbase.cpp:475
Akonadi::CalendarBase::deleteAllEvents
void deleteAllEvents()
Reimplementation of KCalCore::Calendar::deleteAllEvents() that does nothing.
Definition: calendarbase.cpp:535
Akonadi::CalendarBase::weakPointer
QWeakPointer< CalendarBase > weakPointer() const
Returns the weak pointer set with setWeakPointer().
Definition: calendarbase.cpp:636
Akonadi::CalendarBase::incidenceChanger
Akonadi::IncidenceChanger * incidenceChanger() const
Returns the IncidenceChanger used by this calendar to make changes in akonadi.
Definition: calendarbase.cpp:642
Akonadi::CalendarBase::endBatchAdding
void endBatchAdding()
Tells the Calendar that you stoped adding a batch of incidences.
Definition: calendarbase.cpp:653
Akonadi::CalendarBase::addIncidence
bool addIncidence(const KCalCore::Incidence::Ptr &incidence)
Adds an incidence to the calendar.
Definition: calendarbase.cpp:573
Akonadi::CalendarBase
The base class for all akonadi aware calendars.
Definition: calendarbase.h:50
Akonadi::Entity::isValid
bool isValid() const
Returns whether the entity is valid.
Definition: entity.cpp:97
Akonadi::CalendarBase::deleteAllTodos
void deleteAllTodos()
Reimplementation of KCalCore::Calendar::deleteAllTodos() that does nothing.
Definition: calendarbase.cpp:551
Akonadi::CalendarBase::setWeakPointer
void setWeakPointer(const QWeakPointer< Akonadi::CalendarBase > &pointer)
Sets the weak pointer that's associated with this instance.
Definition: calendarbase.cpp:630
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

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