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 using namespace Akonadi;
13 
15  : d(new ItemMonitorPrivate(this))
16 {
17 }
18 
19 ItemMonitor::~ItemMonitor() = default;
20 
21 void ItemMonitor::setItem(const Item &item)
22 {
23  if (item == d->mItem) {
24  return;
25  }
26 
27  d->mMonitor->setItemMonitored(d->mItem, false);
28 
29  d->mItem = item;
30 
31  d->mMonitor->setItemMonitored(d->mItem, true);
32 
33  if (!d->mItem.isValid()) {
34  itemRemoved();
35  return;
36  }
37 
38  // start initial fetch of the new item
39  auto job = new ItemFetchJob(d->mItem);
40  job->setFetchScope(fetchScope());
41 
42  d->connect(job, &ItemFetchJob::result, d.get(), [this](KJob *job) {
43  d->initialFetchDone(job);
44  });
45 }
46 
48 {
49  return d->mItem;
50 }
51 
52 void ItemMonitor::itemChanged(const Item &item)
53 {
54  Q_UNUSED(item)
55 }
56 
58 {
59 }
60 
62 {
63  d->mMonitor->setItemFetchScope(fetchScope);
64 }
65 
67 {
68  return d->mMonitor->itemFetchScope();
69 }
70 
71 #include "moc_itemmonitor_p.cpp"
void result(KJob *job)
virtual void itemRemoved()
This method is called whenever the monitored item has been removed.
Definition: itemmonitor.cpp:57
virtual ~ItemMonitor()
Destroys the item monitor.
void setFetchScope(const ItemFetchScope &fetchScope)
Sets the item fetch scope.
Definition: itemmonitor.cpp:61
void setItem(const Item &item)
Sets the item that shall be monitored.
Definition: itemmonitor.cpp:21
virtual void itemChanged(const Item &item)
This method is called whenever the monitored item has changed.
Definition: itemmonitor.cpp:52
ItemFetchScope & fetchScope()
Returns the item fetch scope.
Definition: itemmonitor.cpp:66
Job that fetches items from the Akonadi storage.
Definition: itemfetchjob.h:69
ItemMonitor()
Creates a new item monitor.
Definition: itemmonitor.cpp:14
Item item() const
Returns the currently monitored item.
Definition: itemmonitor.cpp:47
Represents a PIM item stored in Akonadi storage.
Definition: item.h:104
Specifies which parts of an item should be fetched from the Akonadi storage.
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:00:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.