当前位置: 首页>>代码示例>>C++>>正文


C++ ItemFetchJob::items方法代码示例

本文整理汇总了C++中ItemFetchJob::items方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemFetchJob::items方法的具体用法?C++ ItemFetchJob::items怎么用?C++ ItemFetchJob::items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ItemFetchJob的用法示例。


在下文中一共展示了ItemFetchJob::items方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:31,代码来源:tagtest.cpp

示例2: testFetchItemsByTag

void TagTest::testFetchItemsByTag()
{
    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(tag, this);
    AKVERIFYEXEC(fetchJob);
    QCOMPARE(fetchJob->items().size(), 1);
    Item i = fetchJob->items().first();
    QCOMPARE(i, item1);

    TagDeleteJob *deleteJob = new TagDeleteJob(tag, this);
    AKVERIFYEXEC(deleteJob);
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:32,代码来源:tagtest.cpp

示例3: 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);
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:33,代码来源:tagtest.cpp

示例4: 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);
}
开发者ID:KDE,项目名称:akonadi,代码行数:28,代码来源:itemappendtest.cpp

示例5: 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() );
      }
    }
开发者ID:lenggi,项目名称:kcalcore,代码行数:27,代码来源:itemmovetest.cpp

示例6: 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);
}
开发者ID:KDE,项目名称:akonadi,代码行数:31,代码来源:itemappendtest.cpp

示例7: 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);
    }
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:30,代码来源:itemcopytest.cpp

示例8: 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);
    }
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:55,代码来源:relationtest.cpp

示例9: 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);
    }
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:52,代码来源:tagtest.cpp

示例10: qCDebug

void RetrieveItemsJob::Private::akonadiFetchResult(KJob *job)
{
    if (job->error() != 0) {
        return;    // handled by base class
    }

    ItemFetchJob *itemFetch = qobject_cast<ItemFetchJob *>(job);
    Q_ASSERT(itemFetch != 0);

    Item::List items = itemFetch->items();
    itemFetch->clearItems(); // save memory
    qCDebug(MIXEDMAILDIR_LOG) << "Akonadi fetch got" << items.count() << "items";

    mServerItemsByRemoteId.reserve(items.size());
    for (int i = 0; i < items.count(); ++i) {
        Item &item = items[i];
        // items without remoteId have not been written to the resource yet
        if (!item.remoteId().isEmpty()) {
            // set the parent collection (with all ancestors) in every item
            item.setParentCollection(mCollection);
            mServerItemsByRemoteId.insert(item.remoteId(), item);
        }
    }

    qCDebug(MIXEDMAILDIR_LOG) << "of which" << mServerItemsByRemoteId.count() << "have remoteId";

    FileStore::ItemFetchJob *storeFetch = mStore->fetchItems(mCollection);
    // just basic items, no data

    connect(storeFetch, SIGNAL(result(KJob*)), q, SLOT(storeListResult(KJob*)));
}
开发者ID:KDE,项目名称:kdepim-runtime,代码行数:31,代码来源:retrieveitemsjob.cpp

示例11: slotOtherItemFetched

void ConflictHandler::slotOtherItemFetched( KJob *job )
{
  if ( job->error() ) {
    emit error( job->errorText() ); //TODO: extend error message
    return;
  }

  ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob*>( job );
  if ( fetchJob->items().isEmpty() ) {
    emit error( i18n( "Did not find other item for conflict handling" ) );
    return;
  }

  mConflictingItem = fetchJob->items().first();
  QMetaObject::invokeMethod( this, "resolve", Qt::QueuedConnection );
}
开发者ID:lenggi,项目名称:kcalcore,代码行数:16,代码来源:conflicthandler.cpp

示例12: stat

void AkonadiSlave::stat(const QUrl &url)
{
    qCDebug(AKONADISLAVE_LOG) << url;

    // Stats for a collection
    if (Collection::fromUrl(url).isValid()) {
        Collection collection = Collection::fromUrl(url);

        if (collection != Collection::root()) {
            // Check that the collection exists.
            CollectionFetchJob *job = new CollectionFetchJob(collection, CollectionFetchJob::Base);
            if (!job->exec()) {
                error(KIO::ERR_INTERNAL, job->errorString());
                return;
            }

            if (job->collections().count() != 1) {
                error(KIO::ERR_DOES_NOT_EXIST, i18n("No such item."));
                return;
            }

            collection = job->collections().at(0);
        }

        statEntry(entryForCollection(collection));
        finished();
    }
    // Stats for an item
    else if (Item::fromUrl(url).isValid()) {
        ItemFetchJob *job = new ItemFetchJob(Item::fromUrl(url));

        if (!job->exec()) {
            error(KIO::ERR_INTERNAL, job->errorString());
            return;
        }

        if (job->items().count() != 1) {
            error(KIO::ERR_DOES_NOT_EXIST, i18n("No such item."));
            return;
        }

        const Item item = job->items().at(0);
        statEntry(entryForItem(item));
        finished();
    }
}
开发者ID:KDE,项目名称:kdepim-runtime,代码行数:46,代码来源:akonadislave.cpp

示例13: itemFetchResult

void RecursiveMover::itemFetchResult( KJob *job )
{
  Q_ASSERT( m_currentAction == None );
  --m_runningJobs;

  if ( job->error() )
    return; // error handling is in the base class

  ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob*>( job );
  if ( fetchJob->items().size() == 1 ) {
    m_currentAction = AddItem;
    m_agentBase->itemAdded( fetchJob->items().first(), m_currentCollection );
  } else {
    // deleted since we started, skip
    m_currentItem = Item();
    replayNextItem();
  }
}
开发者ID:crevetor,项目名称:kcalcore,代码行数:18,代码来源:recursivemover.cpp

示例14: testNewMimetype

void ItemAppendTest::testNewMimetype()
{
    const Collection col(collectionIdFromPath(QStringLiteral("res2/space folder")));
    QVERIFY(col.isValid());

    Item item;
    item.setMimeType(QStringLiteral("application/new-type"));
    ItemCreateJob *job = new ItemCreateJob(item, col, this);
    AKVERIFYEXEC(job);

    item = job->item();
    QVERIFY(item.isValid());

    ItemFetchJob *fetch = new ItemFetchJob(item, this);
    AKVERIFYEXEC(fetch);
    QCOMPARE(fetch->items().count(), 1);
    QCOMPARE(fetch->items().first().mimeType(), item.mimeType());
}
开发者ID:KDE,项目名称:akonadi,代码行数:18,代码来源:itemappendtest.cpp

示例15: testItemSize

void ItemAppendTest::testItemSize()
{
    QFETCH(Akonadi::Item, item);
    QFETCH(qint64, size);

    const Collection col(collectionIdFromPath(QStringLiteral("res2/space folder")));
    QVERIFY(col.isValid());

    ItemCreateJob *create = new ItemCreateJob(item, col, this);
    AKVERIFYEXEC(create);
    Item newItem = create->item();

    ItemFetchJob *fetch = new ItemFetchJob(newItem, this);
    AKVERIFYEXEC(fetch);
    QCOMPARE(fetch->items().count(), 1);

    QCOMPARE(fetch->items().first().size(), size);
}
开发者ID:KDE,项目名称:akonadi,代码行数:18,代码来源:itemappendtest.cpp


注:本文中的ItemFetchJob::items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。