本文整理汇总了C++中ItemFetchJob::fetchScope方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemFetchJob::fetchScope方法的具体用法?C++ ItemFetchJob::fetchScope怎么用?C++ ItemFetchJob::fetchScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemFetchJob
的用法示例。
在下文中一共展示了ItemFetchJob::fetchScope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testFetchFullTagWithItem
void TagTest::testFetchFullTagWithItem()
{
const Collection res3 = Collection(collectionIdFromPath(QStringLiteral("res3")));
Tag tag;
{
TagCreateJob *createjob = new TagCreateJob(Tag(QStringLiteral("gid1")), this);
AKVERIFYEXEC(createjob);
tag = createjob->tag();
}
Item item1;
{
item1.setMimeType(QStringLiteral("application/octet-stream"));
ItemCreateJob *append = new ItemCreateJob(item1, res3, this);
AKVERIFYEXEC(append);
item1 = append->item();
//FIXME This should also be possible with create, but isn't
item1.setTag(tag);
}
ItemModifyJob *modJob = new ItemModifyJob(item1, this);
AKVERIFYEXEC(modJob);
ItemFetchJob *fetchJob = new ItemFetchJob(item1, this);
fetchJob->fetchScope().setFetchTags(true);
fetchJob->fetchScope().tagFetchScope().setFetchIdOnly(false);
AKVERIFYEXEC(fetchJob);
QCOMPARE(fetchJob->items().first().tags().size(), 1);
Tag t = fetchJob->items().first().tags().first();
QCOMPARE(t, tag);
QVERIFY(!t.gid().isEmpty());
TagDeleteJob *deleteJob = new TagDeleteJob(tag, this);
AKVERIFYEXEC(deleteJob);
}
示例2: testMultipartAppend
void ItemAppendTest::testMultipartAppend()
{
const Collection testFolder1(collectionIdFromPath(QStringLiteral("res2/space folder")));
QVERIFY(testFolder1.isValid());
Item item;
item.setMimeType(QStringLiteral("application/octet-stream"));
item.setPayload<QByteArray>("body data");
item.attribute<TestAttribute>(Item::AddIfMissing)->data = "extra data";
item.setFlag("TestFlag");
ItemCreateJob *job = new ItemCreateJob(item, testFolder1, this);
AKVERIFYEXEC(job);
Item ref = job->item();
ItemFetchJob *fjob = new ItemFetchJob(ref, this);
fjob->fetchScope().fetchFullPayload();
fjob->fetchScope().fetchAttribute<TestAttribute>();
AKVERIFYEXEC(fjob);
QCOMPARE(fjob->items().count(), 1);
item = fjob->items().first();
QCOMPARE(item.payload<QByteArray>(), QByteArray("body data"));
QVERIFY(item.hasAttribute<TestAttribute>());
QCOMPARE(item.attribute<TestAttribute>()->data, QByteArray("extra data"));
QVERIFY(item.flags().contains("TestFlag"));
ItemDeleteJob *djob = new ItemDeleteJob(ref, this);
AKVERIFYEXEC(djob);
}
示例3: testFetchTagIdWithItem
void TagTest::testFetchTagIdWithItem()
{
const Collection res3 = Collection(collectionIdFromPath(QStringLiteral("res3")));
Tag tag;
{
TagCreateJob *createjob = new TagCreateJob(Tag(QStringLiteral("gid1")), this);
AKVERIFYEXEC(createjob);
tag = createjob->tag();
}
Item item1;
{
item1.setMimeType(QStringLiteral("application/octet-stream"));
item1.setTag(tag);
ItemCreateJob *append = new ItemCreateJob(item1, res3, this);
AKVERIFYEXEC(append);
item1 = append->item();
}
ItemFetchJob *fetchJob = new ItemFetchJob(item1, this);
fetchJob->fetchScope().setFetchTags(true);
fetchJob->fetchScope().tagFetchScope().setFetchIdOnly(true);
AKVERIFYEXEC(fetchJob);
QCOMPARE(fetchJob->items().first().tags().size(), 1);
Tag t = fetchJob->items().first().tags().first();
QCOMPARE(t.id(), tag.id());
QVERIFY(t.gid().isEmpty());
TagDeleteJob *deleteJob = new TagDeleteJob(tag, this);
AKVERIFYEXEC(deleteJob);
}
示例4: testCopy
void testCopy()
{
const Collection target(collectionIdFromPath(QStringLiteral("res3")));
QVERIFY(target.isValid());
ItemCopyJob *copy = new ItemCopyJob(Item(1), target);
AKVERIFYEXEC(copy);
Item source(1);
ItemFetchJob *sourceFetch = new ItemFetchJob(source);
AKVERIFYEXEC(sourceFetch);
source = sourceFetch->items().first();
ItemFetchJob *fetch = new ItemFetchJob(target);
fetch->fetchScope().fetchFullPayload();
fetch->fetchScope().fetchAllAttributes();
fetch->fetchScope().setCacheOnly(true);
AKVERIFYEXEC(fetch);
QCOMPARE(fetch->items().count(), 1);
Item item = fetch->items().first();
QVERIFY(item.hasPayload());
QVERIFY(source.size() > 0);
QVERIFY(item.size() > 0);
QCOMPARE(item.size(), source.size());
QCOMPARE(item.attributes().count(), 1);
QVERIFY(item.remoteId().isEmpty());
QEXPECT_FAIL("", "statistics are not properly updated after copy", Abort);
QCOMPARE(target.statistics().count(), 1ll);
}
示例5: testCreateFetch
void RelationTest::testCreateFetch()
{
const Collection res3 = Collection(collectionIdFromPath(QStringLiteral("res3")));
Item item1;
{
item1.setMimeType(QStringLiteral("application/octet-stream"));
ItemCreateJob *append = new ItemCreateJob(item1, res3, this);
AKVERIFYEXEC(append);
item1 = append->item();
}
Item item2;
{
item2.setMimeType(QStringLiteral("application/octet-stream"));
ItemCreateJob *append = new ItemCreateJob(item2, res3, this);
AKVERIFYEXEC(append);
item2 = append->item();
}
Relation rel(Relation::GENERIC, item1, item2);
RelationCreateJob *createjob = new RelationCreateJob(rel, this);
AKVERIFYEXEC(createjob);
//Test fetch & create
{
RelationFetchJob *fetchJob = new RelationFetchJob(QVector<QByteArray>(), this);
AKVERIFYEXEC(fetchJob);
QCOMPARE(fetchJob->relations().size(), 1);
QCOMPARE(fetchJob->relations().first().type(), QByteArray(Relation::GENERIC));
}
//Test item fetch
{
ItemFetchJob *fetchJob = new ItemFetchJob(item1);
fetchJob->fetchScope().setFetchRelations(true);
AKVERIFYEXEC(fetchJob);
QCOMPARE(fetchJob->items().first().relations().size(), 1);
}
{
ItemFetchJob *fetchJob = new ItemFetchJob(item2);
fetchJob->fetchScope().setFetchRelations(true);
AKVERIFYEXEC(fetchJob);
QCOMPARE(fetchJob->items().first().relations().size(), 1);
}
//Test delete
{
RelationDeleteJob *deleteJob = new RelationDeleteJob(rel, this);
AKVERIFYEXEC(deleteJob);
RelationFetchJob *fetchJob = new RelationFetchJob(QVector<QByteArray>(), this);
AKVERIFYEXEC(fetchJob);
QCOMPARE(fetchJob->relations().size(), 0);
}
}
示例6: start
void ConflictHandler::start()
{
if ( mConflictType == LocalLocalConflict || mConflictType == LocalRemoteConflict ) {
ItemFetchJob *job = new ItemFetchJob( mConflictingItem, mSession );
job->fetchScope().fetchFullPayload();
job->fetchScope().setAncestorRetrieval( ItemFetchScope::Parent );
connect( job, SIGNAL(result(KJob*)), SLOT(slotOtherItemFetched(KJob*)) );
} else {
resolve();
}
}
示例7: testMove
void testMove()
{
QFETCH( Item::List, items );
QFETCH( Collection, destination );
Collection source( collectionIdFromPath( "res1/foo" ) );
QVERIFY( source.isValid() );
ResourceSelectJob *select = new ResourceSelectJob( "akonadi_knut_resource_0" );
AKVERIFYEXEC( select ); // for rid based moves
ItemFetchJob *prefetchjob = new ItemFetchJob( destination, this );
AKVERIFYEXEC( prefetchjob );
int baseline = prefetchjob->items().size();
ItemMoveJob *move = new ItemMoveJob( items, destination, this );
AKVERIFYEXEC( move );
ItemFetchJob *fetch = new ItemFetchJob( destination, this );
fetch->fetchScope().fetchFullPayload();
AKVERIFYEXEC( fetch );
QCOMPARE( fetch->items().count(), items.count() + baseline );
foreach ( const Item& movedItem, fetch->items() ) {
QVERIFY( movedItem.hasPayload() );
QVERIFY( !movedItem.payload<QByteArray>().isEmpty() );
}
}
示例8: testModifyItemWithTagByGID
void TagTest::testModifyItemWithTagByGID()
{
const Collection res3 = Collection(collectionIdFromPath(QStringLiteral("res3")));
{
Tag tag;
tag.setGid("gid2");
TagCreateJob *createjob = new TagCreateJob(tag, this);
AKVERIFYEXEC(createjob);
}
Item item1;
{
item1.setMimeType(QStringLiteral("application/octet-stream"));
ItemCreateJob *append = new ItemCreateJob(item1, res3, this);
AKVERIFYEXEC(append);
item1 = append->item();
}
Tag tag;
tag.setGid("gid2");
item1.setTag(tag);
ItemModifyJob *modJob = new ItemModifyJob(item1, this);
AKVERIFYEXEC(modJob);
ItemFetchJob *fetchJob = new ItemFetchJob(item1, this);
fetchJob->fetchScope().setFetchTags(true);
AKVERIFYEXEC(fetchJob);
QCOMPARE(fetchJob->items().first().tags().size(), 1);
TagDeleteJob *deleteJob = new TagDeleteJob(fetchJob->items().first().tags().first(), this);
AKVERIFYEXEC(deleteJob);
}
示例9: testContent
void ItemAppendTest::testContent()
{
const Collection testFolder1(collectionIdFromPath(QStringLiteral("res2/space folder")));
QVERIFY(testFolder1.isValid());
QFETCH(QByteArray, data);
Item item;
item.setMimeType(QStringLiteral("application/octet-stream"));
if (!data.isNull()) {
item.setPayload(data);
}
ItemCreateJob *job = new ItemCreateJob(item, testFolder1, this);
AKVERIFYEXEC(job);
Item ref = job->item();
ItemFetchJob *fjob = new ItemFetchJob(testFolder1, this);
fjob->fetchScope().setCacheOnly(true);
fjob->fetchScope().fetchFullPayload();
AKVERIFYEXEC(fjob);
QCOMPARE(fjob->items().count(), 1);
Item item2 = fjob->items().first();
QCOMPARE(item2.hasPayload(), !data.isNull());
if (item2.hasPayload()) {
QCOMPARE(item2.payload<QByteArray>(), data);
}
ItemDeleteJob *djob = new ItemDeleteJob(ref, this);
AKVERIFYEXEC(djob);
}
示例10: send
void TransportResourceBasePrivate::send(Item::Id id)
{
ItemFetchJob *job = new ItemFetchJob(Item(id));
job->fetchScope().fetchFullPayload();
job->setProperty("id", QVariant(id));
connect(job, &KJob::result, this, &TransportResourceBasePrivate::fetchResult);
}
示例11: itemRemoved
void CalendarResource::itemRemoved(const Akonadi::Item &item)
{
if (!canPerformTask()) {
return;
}
if (item.mimeType() == KCalCore::Event::eventMimeType()) {
KGAPI2::Job *job = new EventDeleteJob(item.remoteId(), item.parentCollection().remoteId(), account(), this);
job->setProperty(ITEM_PROPERTY, QVariant::fromValue(item));
connect(job, &EventCreateJob::finished, this, &CalendarResource::slotGenericJobFinished);
} else if (item.mimeType() == KCalCore::Todo::todoMimeType()) {
/* Google always automatically removes tasks with all their subtasks. In KOrganizer
* by default we only remove the item we are given. For this reason we have to first
* fetch all tasks, find all sub-tasks for the task being removed and detach them
* from the task. Only then the task can be safely removed. */
ItemFetchJob *fetchJob = new ItemFetchJob(item.parentCollection());
fetchJob->setAutoDelete(true);
fetchJob->fetchScope().fetchFullPayload(true);
fetchJob->setProperty(ITEM_PROPERTY, qVariantFromValue(item));
connect(fetchJob, &ItemFetchJob::finished, this, &CalendarResource::slotRemoveTaskFetchJobFinished);
fetchJob->start();
} else {
cancelTask(i18n("Invalid payload type. Expected event or todo, got %1", item.mimeType()));
}
}
示例12: testModifyItemWithTagByRID
void TagTest::testModifyItemWithTagByRID()
{
{
ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral("akonadi_knut_resource_0"));
AKVERIFYEXEC(select);
}
const Collection res3 = Collection(collectionIdFromPath(QStringLiteral("res3")));
Tag tag3;
{
tag3.setGid("gid3");
tag3.setRemoteId("rid3");
TagCreateJob *createjob = new TagCreateJob(tag3, this);
AKVERIFYEXEC(createjob);
tag3 = createjob->tag();
}
Item item1;
{
item1.setMimeType(QStringLiteral("application/octet-stream"));
ItemCreateJob *append = new ItemCreateJob(item1, res3, this);
AKVERIFYEXEC(append);
item1 = append->item();
}
Tag tag;
tag.setRemoteId("rid2");
item1.setTag(tag);
ItemModifyJob *modJob = new ItemModifyJob(item1, this);
AKVERIFYEXEC(modJob);
ItemFetchJob *fetchJob = new ItemFetchJob(item1, this);
fetchJob->fetchScope().setFetchTags(true);
AKVERIFYEXEC(fetchJob);
QCOMPARE(fetchJob->items().first().tags().size(), 1);
{
TagDeleteJob *deleteJob = new TagDeleteJob(fetchJob->items().first().tags().first(), this);
AKVERIFYEXEC(deleteJob);
}
{
TagDeleteJob *deleteJob = new TagDeleteJob(tag3, this);
AKVERIFYEXEC(deleteJob);
}
{
ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral(""));
AKVERIFYEXEC(select);
}
}
示例13: fetchItems
void InfoCommand::fetchItems()
{
Item item;
// See if user input is a valid integer as an item ID
bool ok;
int id = mEntityArg.toInt(&ok);
if (ok) item = Item(id); // conversion succeeded
else
{
// Otherwise check if we have an Akonadi URL
const KUrl url = QUrl::fromUserInput(mEntityArg);
if (url.isValid() && url.scheme()==QLatin1String("akonadi"))
{
item = Item::fromUrl(url);
}
else
{
emit error(i18nc("@info:shell", "Invalid item/collection syntax"));
emit finished(RuntimeError);
return;
}
}
ItemFetchJob *job = new ItemFetchJob(item, this);
job->fetchScope().setFetchModificationTime(true);
job->fetchScope().fetchAllAttributes(true);
// Need this so that parentCollection() will be valid.
job->fetchScope().setAncestorRetrieval(ItemFetchScope::Parent);
// Not actually going to use the payload here, but if we don't set it
// to be fetched then hasPayload() will not return a meaningful result.
job->fetchScope().fetchFullPayload(true);
connect(job, SIGNAL(result(KJob *)), SLOT(onItemsFetched(KJob *)));
}
示例14: fetchItems
void InfoCommand::fetchItems()
{
Item item = CollectionResolveJob::parseItem(mEntityArg);
if (!item.isValid())
{
emit error(i18nc("@info:shell", "Invalid item/collection syntax"));
emit finished(RuntimeError);
return;
}
ItemFetchJob *job = new ItemFetchJob(item, this);
job->fetchScope().setFetchModificationTime(true);
job->fetchScope().setFetchTags(true);
job->fetchScope().fetchAllAttributes(true);
// Need this so that parentCollection() will be valid.
job->fetchScope().setAncestorRetrieval(ItemFetchScope::Parent);
// Not actually going to use the payload here, but if we don't set it
// to be fetched then hasPayload() will not return a meaningful result.
job->fetchScope().fetchFullPayload(true);
connect(job, SIGNAL(result(KJob *)), SLOT(onItemsFetched(KJob *)));
}
示例15: replayNextItem
void RecursiveMover::replayNextItem()
{
Q_ASSERT( m_currentCollection.isValid() );
if ( m_pendingItems.isEmpty() ) {
replayNextCollection(); // all items processed here
return;
} else {
Q_ASSERT( m_currentAction == None );
m_currentItem = m_pendingItems.takeFirst();
ItemFetchJob *job = new ItemFetchJob( m_currentItem, this );
job->fetchScope().fetchFullPayload();
connect( job, SIGNAL(result(KJob*)), SLOT(itemFetchResult(KJob*)) );
addSubjob( job );
++m_runningJobs;
}
}