コード例 #1
0
Akonadi::Monitor *TripComponentFactory::createTodoMonitor(QObject *parent)
{
    Akonadi::Monitor *chMon = new Akonadi::Monitor(parent);
    chMon->setMimeTypeMonitored(KCalCore::Todo::todoMimeType());
    chMon->itemFetchScope().fetchFullPayload(true);
    return chMon;
}
コード例 #2
0
Akonadi::Monitor *TripComponentFactory::createNotesMonitor(QObject *parent)
{
    Akonadi::Monitor *chMon = new Akonadi::Monitor(parent);
    chMon->setMimeTypeMonitored(Akonotes::Note::mimeType());
    chMon->itemFetchScope().fetchFullPayload(true);
    return chMon;
}
コード例 #3
0
ファイル: tagtest.cpp プロジェクト: quazgar/kdepimlibs
void TagTest::testDeleteRIDIsolation()
{
    Tag tag;
    tag.setGid("gid");
    tag.setType("mytype");
    tag.setRemoteId("rid_0");

    {
        ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral("akonadi_knut_resource_0"));
        AKVERIFYEXEC(select);

        TagCreateJob *createJob = new TagCreateJob(tag, this);
        AKVERIFYEXEC(createJob);
        QVERIFY(createJob->tag().isValid());
        tag.setId(createJob->tag().id());
    }

    tag.setRemoteId("rid_1");
    {
        ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral("akonadi_knut_resource_1"));
        AKVERIFYEXEC(select);

        TagCreateJob *createJob = new TagCreateJob(tag, this);
        createJob->setMergeIfExisting(true);
        AKVERIFYEXEC(createJob);
        QVERIFY(createJob->tag().isValid());
    }

    Akonadi::Monitor monitor;
    monitor.setTypeMonitored(Akonadi::Monitor::Tags);
    QSignalSpy signalSpy(&monitor, SIGNAL(tagRemoved(Akonadi::Tag)));

    TagDeleteJob *deleteJob = new TagDeleteJob(tag, this);
    AKVERIFYEXEC(deleteJob);

    // Other tests notifications might interfere due to notification compression on server
    QTRY_VERIFY(signalSpy.count() >= 1);

    Tag removedTag;
    while (!signalSpy.isEmpty()) {
        const Tag t = signalSpy.takeFirst().takeFirst().value<Akonadi::Tag>();
        if (t.id() == tag.id()) {
            removedTag = t;
            break;
        }
    }

    QVERIFY(removedTag.isValid());
    QVERIFY(removedTag.remoteId().isEmpty());

    {
        ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral(""), this);
        AKVERIFYEXEC(select);
    }
}
コード例 #4
0
void KPDialog::setupPane()
{
    kDebug() << "Setting up";
    // Setup the core model
    Akonadi::Session *session = new Akonadi::Session( "KPApplet", m_folderListWidget );

      Akonadi::Monitor *monitor = new Akonadi::Monitor( m_folderListWidget );
      monitor->setCollectionMonitored( Akonadi::Collection::root() );
      monitor->fetchCollection( true );
      monitor->setMimeTypeMonitored( "message/rfc822", true );
      monitor->itemFetchScope().fetchFullPayload(true);

      Akonadi::EntityTreeModel *entityModel = new Akonadi::EntityTreeModel( session, monitor, m_folderListWidget );
      entityModel->setItemPopulationStrategy( Akonadi::EntityTreeModel::LazyPopulation );

      // Create the collection view
      m_folderListView = new Akonadi::EntityTreeView( 0, m_folderListWidget );
      m_folderListView->setSelectionMode( QAbstractItemView::ExtendedSelection );



      // Setup the message folders collection...
      Akonadi::EntityFilterProxyModel *collectionFilter = new Akonadi::EntityFilterProxyModel( m_folderListWidget );
      collectionFilter->setSourceModel( entityModel );
      //collectionFilter->addMimeTypeInclusionFilter( "message/rfc822" );
      collectionFilter->addMimeTypeInclusionFilter( Akonadi::Collection::mimeType() );
      collectionFilter->setHeaderSet( Akonadi::EntityTreeModel::CollectionTreeHeaders );

      // ... with statistics...
      Akonadi::StatisticsToolTipProxyModel *statisticsProxyModel = new Akonadi::StatisticsToolTipProxyModel( m_folderListWidget );
      statisticsProxyModel->setSourceModel( collectionFilter );

      // ... and sortable
      QSortFilterProxyModel *sortModel = new QSortFilterProxyModel( m_folderListWidget );
      sortModel->setDynamicSortFilter( true );
      sortModel->setSortCaseSensitivity( Qt::CaseInsensitive );
      sortModel->setSourceModel( statisticsProxyModel );
      // Use the model
      m_folderListView->setModel( sortModel );
      entityModel->setRootCollection(Akonadi::Collection::root());
      
      // Now make the message list multi-tab pane
      m_messagePane = new MessageList::Pane( entityModel, m_folderListView->selectionModel(), m_messageListWidget );
      //connect( m_messagePane, SIGNAL(messageSelected(Akonadi::Item)),
      //       this, SLOT(slotMessageSelected(Akonadi::Item)) );

}
コード例 #5
0
ファイル: tagtest.cpp プロジェクト: quazgar/kdepimlibs
void TagTest::testMonitor()
{
    Akonadi::Monitor monitor;
    monitor.setTypeMonitored(Akonadi::Monitor::Tags);
    monitor.tagFetchScope().fetchAttribute<Akonadi::TagAttribute>();

    Akonadi::Tag createdTag;
    {
        QSignalSpy addedSpy(&monitor, SIGNAL(tagAdded(Akonadi::Tag)));
        QVERIFY(addedSpy.isValid());
        Tag tag;
        tag.setGid("gid2");
        tag.setName(QStringLiteral("name2"));
        tag.setType("type2");
        TagCreateJob *createjob = new TagCreateJob(tag, this);
        AKVERIFYEXEC(createjob);
        createdTag = createjob->tag();
        //We usually pick up signals from the previous tests as well (due to server-side notification caching)
        QTRY_VERIFY(addedSpy.count() >= 1);
        QTRY_COMPARE(addedSpy.last().first().value<Akonadi::Tag>().id(), createdTag.id());
        QVERIFY(addedSpy.last().first().value<Akonadi::Tag>().hasAttribute<Akonadi::TagAttribute>());
    }

    {
        QSignalSpy modifedSpy(&monitor, SIGNAL(tagChanged(Akonadi::Tag)));
        QVERIFY(modifedSpy.isValid());
        createdTag.setName(QStringLiteral("name3"));

        TagModifyJob *modJob = new TagModifyJob(createdTag, this);
        AKVERIFYEXEC(modJob);
        //We usually pick up signals from the previous tests as well (due to server-side notification caching)
        QTRY_VERIFY(modifedSpy.count() >= 1);
        QTRY_COMPARE(modifedSpy.last().first().value<Akonadi::Tag>().id(), createdTag.id());
        QVERIFY(modifedSpy.last().first().value<Akonadi::Tag>().hasAttribute<Akonadi::TagAttribute>());
    }

    {
        QSignalSpy removedSpy(&monitor, SIGNAL(tagRemoved(Akonadi::Tag)));
        QVERIFY(removedSpy.isValid());
        TagDeleteJob *deletejob = new TagDeleteJob(createdTag, this);
        AKVERIFYEXEC(deletejob);
        QTRY_VERIFY(removedSpy.count() >= 1);
        QTRY_COMPARE(removedSpy.last().first().value<Akonadi::Tag>().id(), createdTag.id());
    }
}
コード例 #6
0
ファイル: relationtest.cpp プロジェクト: quazgar/kdepimlibs
void RelationTest::testMonitor()
{
    Akonadi::Monitor monitor;
    monitor.setTypeMonitored(Akonadi::Monitor::Relations);

    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);

    {
        QSignalSpy addedSpy(&monitor, SIGNAL(relationAdded(Akonadi::Relation)));
        QVERIFY(addedSpy.isValid());

        RelationCreateJob *createjob = new RelationCreateJob(rel, this);
        AKVERIFYEXEC(createjob);

        //We usually pick up signals from the previous tests as well (due to server-side notification caching)
        QTRY_VERIFY(addedSpy.count() >= 1);
        QTRY_COMPARE(addedSpy.last().first().value<Akonadi::Relation>(), rel);
    }

    {
        QSignalSpy removedSpy(&monitor, SIGNAL(relationRemoved(Akonadi::Relation)));
        QVERIFY(removedSpy.isValid());
        RelationDeleteJob *deleteJob = new RelationDeleteJob(rel, this);
        AKVERIFYEXEC(deleteJob);
        QTRY_VERIFY(removedSpy.count() >= 1);
        QTRY_COMPARE(removedSpy.last().first().value<Akonadi::Relation>(), rel);
    }
}
コード例 #7
0
ファイル: tagtest.cpp プロジェクト: quazgar/kdepimlibs
void TagTest::testTagItem()
{
    Akonadi::Monitor monitor;
    monitor.itemFetchScope().setFetchTags(true);
    monitor.setAllMonitored(true);
    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();
    }

    item1.setTag(tag);

    QSignalSpy tagsSpy(&monitor, SIGNAL(itemsTagsChanged(Akonadi::Item::List,QSet<Akonadi::Tag>,QSet<Akonadi::Tag>)));
    QVERIFY(tagsSpy.isValid());

    ItemModifyJob *modJob = new ItemModifyJob(item1, this);
    AKVERIFYEXEC(modJob);

    QTRY_VERIFY(tagsSpy.count() >= 1);
    QTRY_COMPARE(tagsSpy.last().first().value<Akonadi::Item::List>().first().id(), item1.id());
    QTRY_COMPARE(tagsSpy.last().at(1).value< QSet<Tag> >().size(), 1); //1 added tag

    ItemFetchJob *fetchJob = new ItemFetchJob(item1, this);
    fetchJob->fetchScope().setFetchTags(true);
    AKVERIFYEXEC(fetchJob);
    QCOMPARE(fetchJob->items().first().tags().size(), 1);

    TagDeleteJob *deleteJob = new TagDeleteJob(tag, this);
    AKVERIFYEXEC(deleteJob);
}
コード例 #8
0
ファイル: tagtest.cpp プロジェクト: quazgar/kdepimlibs
void TagTest::testDelete()
{
    Akonadi::Monitor monitor;
    monitor.setTypeMonitored(Monitor::Tags);
    QSignalSpy spy(&monitor, SIGNAL(tagRemoved(Akonadi::Tag)));

    Tag tag1;
    {
        tag1.setGid("tag1");
        TagCreateJob *createjob = new TagCreateJob(tag1, this);
        AKVERIFYEXEC(createjob);
        QVERIFY(createjob->tag().isValid());
        tag1 = createjob->tag();
    }
    Tag tag2;
    {
        tag2.setGid("tag2");
        TagCreateJob *createjob = new TagCreateJob(tag2, this);
        AKVERIFYEXEC(createjob);
        QVERIFY(createjob->tag().isValid());
        tag2 = createjob->tag();
    }
    {
        TagDeleteJob *deleteJob = new TagDeleteJob(tag1, this);
        AKVERIFYEXEC(deleteJob);
    }

    {
        TagFetchJob *fetchJob = new TagFetchJob(this);
        AKVERIFYEXEC(fetchJob);
        QCOMPARE(fetchJob->tags().size(), 1);
        QCOMPARE(fetchJob->tags().first().gid(), tag2.gid());
    }
    {
        TagDeleteJob *deleteJob = new TagDeleteJob(tag2, this);
        AKVERIFYEXEC(deleteJob);
    }

    // Collect Remove notification, so that they don't interfere with testDeleteRIDIsolation
    QTRY_VERIFY(!spy.isEmpty());
}