コード例 #1
0
void EntityTreeCreateJob::createNextLevelOfCollections()
{
    CollectionCreateJob *job;

    const Collection::List colList = m_collections.takeFirst();
    foreach (const Collection &collection, colList) {
        ++m_pendingJobs;
        job = new CollectionCreateJob(collection, this);
        job->setProperty(collectionIdMappingProperty, collection.id());
        connect(job, &CollectionCreateJob::result, this, &EntityTreeCreateJob::collectionCreateJobDone);
    }
コード例 #2
0
Akonadi::Collection VirtualResource::createCollection(const Akonadi::Collection &collection)
{
    // kDebug() << collection.name() << collection.parentCollection().remoteId();
    // kDebug() << "contentMimeTypes: " << collection.contentMimeTypes();

    Q_ASSERT(!collection.name().isEmpty());
    Collection col = collection;
    if (!col.parentCollection().isValid()) {
        col.setParentCollection(mRootCollection);
    }
    CollectionCreateJob *create = new CollectionCreateJob(col, mSession);
    EXEC(create);
    return create->collection();
}
コード例 #3
0
ファイル: addcommandtest.cpp プロジェクト: KDE/akonadiclient
void AddCommandTest::testAddItem()
{
    QDir dir(mTempDir->name());
    dir.cd("foo");
    QDir::setCurrent(dir.absolutePath());

    CollectionResolveJob *resolveJob = new CollectionResolveJob("/res3", this);
    QVERIFY(resolveJob->hasUsableInput());
    AKVERIFYEXEC(resolveJob);

    QVERIFY(resolveJob->collection().isValid());

    Collection col;
    col.setName("test");
    col.setParentCollection(resolveJob->collection());

    CollectionCreateJob *createJob = new CollectionCreateJob(col, this);
    AKVERIFYEXEC(createJob);

    col = createJob->collection();
    QVERIFY(col.isValid());

    const int numArgs = 5;
    QVector<QByteArray> args;
    args.reserve(numArgs);
    args << "akonadiclient" << "add" << "/res3/test" << "../test.txt" << "bar";

    const char *testArgs[numArgs];
    for (int i = 0; i < numArgs; i++) {
        testArgs[i] = args.at(i).data();
    }

    KCmdLineArgs *parsedArgs = getParsedArgs(numArgs, testArgs);

    AddCommand *command = new AddCommand(this);

    int ret = command->init(parsedArgs);
    QCOMPARE(ret, 0);

    ret = runCommand(command);
    QCOMPARE(ret, 0);

    ItemFetchJob *itemFetchJob1 = new ItemFetchJob(col, this);
    itemFetchJob1->fetchScope().fetchAllAttributes(false);
    itemFetchJob1->fetchScope().fetchFullPayload(true);

    AKVERIFYEXEC(itemFetchJob1);

    QCOMPARE(itemFetchJob1->items().count(), 1);
    QCOMPARE(itemFetchJob1->items().at(0).payloadData(), QByteArray("Testing"));

    CollectionFetchJob *fetchJob1 = new CollectionFetchJob(col, CollectionFetchJob::FirstLevel, this);
    AKVERIFYEXEC(fetchJob1);

    QCOMPARE(fetchJob1->collections().count(), 1);

    col = fetchJob1->collections().at(0);
    QCOMPARE(col.name(), QString("bar"));

    ItemFetchJob *itemFetchJob2 = new ItemFetchJob(col, this);
    itemFetchJob2->fetchScope().fetchAllAttributes(false);
    itemFetchJob2->fetchScope().fetchFullPayload(true);

    AKVERIFYEXEC(itemFetchJob2);
    QCOMPARE(itemFetchJob2->items().count(), 1);
    QCOMPARE(itemFetchJob2->items().at(0).payloadData(), QByteArray("Bar Item"));
}