Akonadi

itemmonitor.cpp
1 /*
2  SPDX-FileCopyrightText: 2007-2008 Tobias Koenig <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "itemmonitor.h"
8 #include "itemmonitor_p.h"
9 
10 #include "itemfetchscope.h"
11 
12 
13 using namespace Akonadi;
14 
16  : d(new Private(this))
17 {
18 }
19 
21 {
22  delete d;
23 }
24 
25 void ItemMonitor::setItem(const Item &item)
26 {
27  if (item == d->mItem) {
28  return;
29  }
30 
31  d->mMonitor->setItemMonitored(d->mItem, false);
32 
33  d->mItem = item;
34 
35  d->mMonitor->setItemMonitored(d->mItem, true);
36 
37  if (!d->mItem.isValid()) {
38  itemRemoved();
39  return;
40  }
41 
42  // start initial fetch of the new item
43  ItemFetchJob *job = new ItemFetchJob(d->mItem);
44  job->setFetchScope(fetchScope());
45 
46  d->connect(job, &ItemFetchJob::result, d, [this](KJob* job) {d->initialFetchDone(job); });
47 }
48 
49 Item ItemMonitor::item() const
50 {
51  return d->mItem;
52 }
53 
54 void ItemMonitor::itemChanged(const Item &item)
55 {
56  Q_UNUSED(item)
57 }
58 
60 {
61 }
62 
64 {
65  d->mMonitor->setItemFetchScope(fetchScope);
66 }
67 
69 {
70  return d->mMonitor->itemFetchScope();
71 }
72 
73 #include "moc_itemmonitor_p.cpp"
ItemFetchScope & fetchScope()
Returns the item fetch scope.
Definition: itemmonitor.cpp:68
virtual void itemRemoved()
This method is called whenever the monitored item has been removed.
Definition: itemmonitor.cpp:59
virtual ~ItemMonitor()
Destroys the item monitor.
Definition: itemmonitor.cpp:20
void setFetchScope(const ItemFetchScope &fetchScope)
Sets the item fetch scope.
Definition: itemmonitor.cpp:63
Item item() const
Returns the currently monitored item.
Definition: itemmonitor.cpp:49
void setFetchScope(const ItemFetchScope &fetchScope)
Sets the item fetch scope.
Specifies which parts of an item should be fetched from the Akonadi storage.
ItemMonitor()
Creates a new item monitor.
Definition: itemmonitor.cpp:15
void setItem(const Item &item)
Sets the item that shall be monitored.
Definition: itemmonitor.cpp:25
Helper integration between Akonadi and Qt.
Job that fetches items from the Akonadi storage.
Definition: itemfetchjob.h:71
virtual void itemChanged(const Item &item)
This method is called whenever the monitored item has changed.
Definition: itemmonitor.cpp:54
void result(KJob *job)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jul 8 2020 23:15:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.