File indexing completed on 2024-11-10 04:40:41
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 Tobias Koenig <tokoe@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "itemmonitor.h" 0008 #include "itemmonitor_p.h" 0009 0010 #include "itemfetchscope.h" 0011 0012 using namespace Akonadi; 0013 0014 ItemMonitor::ItemMonitor() 0015 : d(new ItemMonitorPrivate(this)) 0016 { 0017 } 0018 0019 ItemMonitor::~ItemMonitor() = default; 0020 0021 void ItemMonitor::setItem(const Item &item) 0022 { 0023 if (item == d->mItem) { 0024 return; 0025 } 0026 0027 d->mMonitor->setItemMonitored(d->mItem, false); 0028 0029 d->mItem = item; 0030 0031 d->mMonitor->setItemMonitored(d->mItem, true); 0032 0033 if (!d->mItem.isValid()) { 0034 itemRemoved(); 0035 return; 0036 } 0037 0038 // start initial fetch of the new item 0039 auto job = new ItemFetchJob(d->mItem); 0040 job->setFetchScope(fetchScope()); 0041 0042 d->connect(job, &ItemFetchJob::result, d.get(), [this](KJob *job) { 0043 d->initialFetchDone(job); 0044 }); 0045 } 0046 0047 Item ItemMonitor::item() const 0048 { 0049 return d->mItem; 0050 } 0051 0052 void ItemMonitor::itemChanged(const Item &item) 0053 { 0054 Q_UNUSED(item) 0055 } 0056 0057 void ItemMonitor::itemRemoved() 0058 { 0059 } 0060 0061 void ItemMonitor::setFetchScope(const ItemFetchScope &fetchScope) 0062 { 0063 d->mMonitor->setItemFetchScope(fetchScope); 0064 } 0065 0066 ItemFetchScope &ItemMonitor::fetchScope() 0067 { 0068 return d->mMonitor->itemFetchScope(); 0069 } 0070 0071 #include "moc_itemmonitor_p.cpp"