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

akonadi

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

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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