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


C++ ModelWatcher类代码示例

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


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

示例1: addEvent

void UnreadEventModelTest::addEvent()
{
    UnreadEventsModel model;
    watcher.setModel(&model);
    model.setQueryMode(EventModel::SyncQuery);
    GroupModel groupModel;
    groupModel.enableContactChanges(false);

    group1.setLocalUid("/org/freedesktop/Telepathy/Account/gabble/jabber/dut_40localhost0");
    QStringList uids;
    uids << "[email protected]";
    group1.setRemoteUids(uids);
    QVERIFY(groupModel.addGroup(group1));

    for (int j = 0; j < NUM_EVENTS; j++) {
        Event e;
        Event dbEvent;
        int id;

        e = createEvent("[email protected]");
        e.setGroupId(group1.id());
        QVERIFY(model.addEvent(e));
        watcher.waitForSignals();
        id = e.id();
        QVERIFY(id != -1);
        QVERIFY(model.trackerIO().getEvent(id, dbEvent));
        QCOMPARE(dbEvent.id(), id);
    }
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:29,代码来源:unreadeventsmodeltest.cpp

示例2: addEvent

//Private functions
bool SyncModelTest::addEvent(int parentId, int groupId, const QDateTime& sentReceivedTime,
                             const QString& localId, const QString& remoteId, const QString& text, bool read)
{
    EventModel model;
    watcher.setModel(&model);
    Event e;
    e.setType(Event::SMSEvent);
    e.setParentId(parentId);

    if (parentId == ::INBOX ||  parentId >= ::MYFOLDER) {
        e.setDirection(Event::Inbound);
    }  else {
        e.setDirection(Event::Outbound);
    }
    e.setGroupId(groupId);
    e.setStartTime(sentReceivedTime);
    e.setEndTime(sentReceivedTime);
    e.setLocalUid(localId);
    e.setRemoteUid(remoteId);
    e.setFreeText(text);
    e.setIsRead(read);

    bool ret_val =  model.addEvent(e);
    watcher.waitForSignals(1, 1);
    itemId = e.id();
    return ret_val;
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:28,代码来源:syncmodeltest.cpp

示例3: modifyEvent

bool  SyncModelTest::modifyEvent( int itemId, int parentId, int groupId, const QDateTime &lastModTime,
                                  const QString& localId, const QString& remoteId, const QString& text, bool read)
{
    Q_UNUSED(lastModTime);
    EventModel model;
    watcher.setModel(&model);
    Event e;
    e.setType(Event::SMSEvent);
    e.setId(itemId);
    e.setParentId(parentId);

    if (parentId == ::INBOX ||  parentId >= ::MYFOLDER) {
        e.setDirection(Event::Inbound);
    }  else {
        e.setDirection(Event::Outbound);
    }
    e.setGroupId(groupId);
    e.setLocalUid(localId);
    e.setRemoteUid(remoteId);
    e.setFreeText(text);
    e.setIsRead(read);

    bool    ret = model.modifyEvent(e);
    watcher.waitForSignals(1, 1);
    return ret;
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:26,代码来源:syncmodeltest.cpp

示例4: modifyEvent

void ConversationModelTest::modifyEvent()
{
    ConversationModel model;
    model.enableContactChanges(false);
    watcher.setModel(&model);
    model.setQueryMode(EventModel::SyncQuery);
    QVERIFY(model.getEvents(group1.id()));

    Event event;
    /* modify invalid event */
    QVERIFY(!model.modifyEvent(event));

    QVERIFY(model.rowCount() > 0);

    int row = rand() % model.rowCount();
    event = model.event(model.index(row, 0));
    qDebug() << row << event.id() << event.freeText();
    event.setFreeText("modified event");
    QDateTime modified = event.lastModified();
    QVERIFY(model.modifyEvent(event));
    watcher.waitForSignals();
    QVERIFY(model.trackerIO().getEvent(event.id(), event));
    QCOMPARE(event.freeText(), QString("modified event"));

    QSKIP("Make nie:contentLastUpdated handling consistent", SkipSingle);
    event = model.event(model.index(row, 0));
    QCOMPARE(event.freeText(), QString("modified event"));
    QVERIFY(event.lastModified() > modified);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:29,代码来源:conversationmodeltest.cpp

示例5: asyncMode

void ConversationModelTest::asyncMode()
{
    ConversationModel model;
    model.enableContactChanges(false);
    watcher.setModel(&model);
    QVERIFY(model.getEvents(group1.id()));
    QVERIFY(watcher.waitForModelReady());
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:8,代码来源:conversationmodeltest.cpp

示例6: initTestCase

void ClassZeroSMSModelTest::initTestCase()
{
    m_pModel = new ClassZeroSMSModel;
    qsrand(QDateTime::currentDateTime().toTime_t());

    watcher.setLoop(&m_eventLoop);
    watcher.setModel(m_pModel);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:8,代码来源:classzerosmsmodeltest.cpp

示例7: contacts

void ConversationModelTest::contacts()
{
    QFETCH(QString, localId);
    QFETCH(QString, remoteId);
    QFETCH(int, eventType);

    Group group;
    addTestGroup(group, localId, remoteId);

    ConversationModel model;
    Event::PropertySet p;
    p.insert(Event::ContactId);
    p.insert(Event::ContactName);
    model.setPropertyMask(p);

    model.enableContactChanges(false);
    watcher.setModel(&model);

    addTestEvent(model, (Event::EventType)eventType, Event::Inbound, localId,
                 group.id(), "text", false, false, QDateTime::currentDateTime(), remoteId);

    QVERIFY(model.getEvents(group.id()));
    QVERIFY(watcher.waitForModelReady());

    Event event;
    event = model.event(model.index(0, 0));
    QCOMPARE(event.contactId(), 0);

    QString noMatch = remoteId;
    noMatch += remoteId[1];

    int contactId1 = addTestContact("Really1Funny",
                   noMatch,
                   localId);

    QVERIFY(model.getEvents(group.id()));
    QVERIFY(watcher.waitForModelReady());

    event = model.event(model.index(0, 0));
    QCOMPARE(event.contactId(), 0);

    int contactId = addTestContact("ReallyUFunny", remoteId, localId);
    QTime timer;
    timer.start();
    while (timer.elapsed() < 1000)
        QCoreApplication::processEvents();
    QVERIFY(model.getEvents(group.id()));
    QVERIFY(watcher.waitForModelReady());

    event = model.event(model.index(0, 0));
    QCOMPARE(event.contactId(), contactId);
    QCOMPARE(event.contactName(), QString("ReallyUFunny"));

    deleteTestContact(contactId1);
    deleteTestContact(contactId);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:56,代码来源:conversationmodeltest.cpp

示例8: contactMatching

void SingleEventModelTest::contactMatching()
{
    QFETCH(QString, localId);
    QFETCH(QString, remoteId);
    QFETCH(int, eventType);

    SingleEventModel model;
    Event::PropertySet p;
    p.insert(Event::ContactId);
    p.insert(Event::ContactName);
    model.setPropertyMask(p);

    watcher.setModel(&model);


    int eventId = addTestEvent(model, (Event::EventType)eventType, Event::Inbound, localId, group1.id(),
                 "text", false, false, QDateTime::currentDateTime(), remoteId);
    watcher.waitForSignals();
    QVERIFY(eventId != -1);

    QVERIFY(model.getEventByUri(Event::idToUrl(eventId)));
    QVERIFY(watcher.waitForModelReady());
    Event event = model.event(model.index(0, 0));
    QCOMPARE(event.id(), eventId);
    QCOMPARE(event.contactId(), 0);

    QString noMatch = remoteId;
    noMatch += remoteId[1];

    int contactId1 = addTestContact("Really1Bad",
                   noMatch,
                   localId);

    QVERIFY(model.getEventByUri(Event::idToUrl(eventId)));
    QVERIFY(watcher.waitForModelReady());
    event = model.event(model.index(0, 0));
    QCOMPARE(event.id(), eventId);
    QCOMPARE(event.contactId(), 0);

    int contactId = addTestContact("Really Bad", remoteId, localId);

    QVERIFY(model.getEventByUri(Event::idToUrl(eventId)));
    QVERIFY(watcher.waitForModelReady());
    event = model.event(model.index(0, 0));
    QCOMPARE(event.id(), eventId);

    QCOMPARE(event.contactId(), contactId);
    QCOMPARE(event.contactName(), QString("Really Bad"));

    deleteTestContact(contactId1);
    deleteTestContact(contactId);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:52,代码来源:singleeventmodeltest.cpp

示例9: addEvent

void ClassZeroSMSModelTest::addEvent()
{
    for (int j = 0; j < NUM_EVENTS; j++) {
        Event e;
        int id;
        e = createEvent();
        QVERIFY(m_pModel->addEvent(e,true));
        id = e.id();
        QVERIFY(id != -1);
        watcher.waitForSignals(-1, 1);
        QCOMPARE(watcher.addedCount(), 1);
    }
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:13,代码来源:classzerosmsmodeltest.cpp

示例10: initTestCase

void UnreadEventModelTest::initTestCase()
{
    EventModel model;

    watcher.setLoop(&m_eventLoop);

    qsrand(QDateTime::currentDateTime().toTime_t());
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:8,代码来源:unreadeventsmodeltest.cpp

示例11: initTestCase

void CallModelTest::initTestCase()
{
    QVERIFY( QDBusConnection::sessionBus().isConnected() );

    deleteAll();

    qsrand( QDateTime::currentDateTime().toTime_t() );

    addTestGroups( group1, group2 );

    // add 8 call events from user1
    int cnt = 0;
    QDateTime when = QDateTime::currentDateTime();

    EventModel model;
    watcher.setModel(&model);
    // 2 dialed
    addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when,               REMOTEUID1 ); cnt++;
    addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(  5 ), REMOTEUID1 ); cnt++;
    testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::DialedCallType, 2 ) );

    // 1 missed
    addTestEvent( model, Event::CallEvent, Event::Inbound,  ACCOUNT1, -1, "", false, true,  when.addSecs( 10 ), REMOTEUID1 ); cnt++;
    testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::MissedCallType, 1 ) );

    // 2 received
    addTestEvent( model, Event::CallEvent, Event::Inbound,  ACCOUNT1, -1, "", false, false, when.addSecs( 15 ), REMOTEUID1 ); cnt++;
    addTestEvent( model, Event::CallEvent, Event::Inbound,  ACCOUNT1, -1, "", false, false, when.addSecs( 20 ), REMOTEUID1 ); cnt++;
    testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::ReceivedCallType, 2 ) );

    // 1 dialed
    addTestEvent( model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs( 25 ), REMOTEUID1 ); cnt++;
    testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::DialedCallType, 1 ) );

    // 2 missed
    addTestEvent( model, Event::CallEvent, Event::Inbound,  ACCOUNT1, -1, "", false, true,  when.addSecs( 30 ), REMOTEUID1 ); cnt++;
    addTestEvent( model, Event::CallEvent, Event::Inbound,  ACCOUNT1, -1, "", false, true,  when.addSecs( 35 ), REMOTEUID1 ); cnt++;
    testCalls.insert( 0, TestCallItem( REMOTEUID1, CallEvent::MissedCallType, 2 ) );

    // add 1 im and 2 sms events
    addTestEvent( model, Event::IMEvent,   Event::Outbound, ACCOUNT1, group1.id(), "test" );        cnt++;
    addTestEvent( model, Event::SMSEvent,  Event::Inbound,  ACCOUNT1, group1.id(), "test" );        cnt++;
    addTestEvent( model, Event::SMSEvent,  Event::Outbound, ACCOUNT1, group2.id(), "draft", true ); cnt++;

    QVERIFY(watcher.waitForAdded(cnt));
}
开发者ID:jpetrell,项目名称:libcommhistory,代码行数:46,代码来源:callmodeltest.cpp

示例12: reset

void ConversationModelTest::reset() {
    ConversationModel conv;
    conv.enableContactChanges(false);
    watcher.setModel(&conv);

    QVERIFY(conv.getEvents(group1.id()));

    QVERIFY(watcher.waitForModelReady());

    QVERIFY(conv.rowCount() >= 5 );

    QSignalSpy modelReset(&conv, SIGNAL(modelReset()));
    GroupModel groups;
    groups.deleteGroups(QList<int>() << group1.id());
    if (modelReset.isEmpty())
       QVERIFY(waitSignal(modelReset));
    QCOMPARE(conv.rowCount(), 0);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:18,代码来源:conversationmodeltest.cpp

示例13: markAsRead

void UnreadEventModelTest::markAsRead()
{
    UnreadEventsModel model;
    watcher.setModel(&model);
    model.setQueryMode(EventModel::SyncQuery);
    model.getEvents();
    const int count = model.rowCount();

    QList<Event> events;
    for (int i = 0; i < count; i++) {
        Event event = model.event(model.index(count-1-i, 0));
        event.setIsRead(true);
        events << event;
    }
    model.modifyEvents(events);
    if (count) watcher.waitForSignals();
    QVERIFY(model.rowCount() == 0);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:18,代码来源:unreadeventsmodeltest.cpp

示例14: initTestCase

void ConversationModelTest::initTestCase()
{
    QVERIFY(QDBusConnection::sessionBus().isConnected());

    deleteAll();

    loop = new QEventLoop(this);

    watcher.setLoop(loop);

    qsrand(QDateTime::currentDateTime().toTime_t());

    addTestGroups(group1, group2);

    EventModel model;
    watcher.setModel(&model);
    addTestEvent(model, Event::IMEvent, Event::Inbound, ACCOUNT1, group1.id());
    addTestEvent(model, Event::IMEvent, Event::Inbound, ACCOUNT1, group1.id());
    addTestEvent(model, Event::IMEvent, Event::Outbound, ACCOUNT1, group1.id());
    addTestEvent(model, Event::IMEvent, Event::Outbound, ACCOUNT1, group1.id());

    addTestEvent(model, Event::IMEvent, Event::Inbound, ACCOUNT2, group1.id());
    addTestEvent(model, Event::IMEvent, Event::Outbound, ACCOUNT2, group1.id());

    addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1, group1.id());
    addTestEvent(model, Event::SMSEvent, Event::Outbound, ACCOUNT1, group1.id());

    addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT2, group1.id());
    addTestEvent(model, Event::SMSEvent, Event::Outbound, ACCOUNT2, group1.id());

    addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1);
    addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1);

    addTestEvent(model, Event::IMEvent, Event::Outbound, ACCOUNT1, group1.id(),
                 "draft", true);

    // status message:
    // NOTE: this event is not visible in any of the further tests
    addTestEvent(model, Event::StatusMessageEvent, Event::Outbound, ACCOUNT1,
                 group1.id(), "statue message", false, false,
                 QDateTime::currentDateTime(), QString(), true);

    watcher.waitForSignals(13, 14);
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:44,代码来源:conversationmodeltest.cpp

示例15: sorting

void ConversationModelTest::sorting()
{
    EventModel model;
    model.setQueryMode(EventModel::StreamedAsyncQuery);
    model.setFirstChunkSize(5);
    model.enableContactChanges(false);
    watcher.setModel(&model);

    //add events with the same timestamp
    QDateTime now = QDateTime::currentDateTime();
    QDateTime future = now.addSecs(10);

    addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
                 group1.id(), "I", false, false, now);
    addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
                 group1.id(), "II", false, false, now);
    addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
                 group1.id(), "III", false, false, future);
    addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
                 group1.id(), "IV", false, false, future);
    addTestEvent(model, Event::SMSEvent, Event::Inbound, ACCOUNT1,
                 group1.id(), "V", false, false, future);

    watcher.waitForSignals(5, 5);

    ConversationModel conv;
    conv.setQueryMode(EventModel::StreamedAsyncQuery);
    conv.setFirstChunkSize(5);
    conv.enableContactChanges(false);
    QSignalSpy rowsInserted(&conv, SIGNAL(rowsInserted(const QModelIndex &, int, int)));

    QVERIFY(conv.getEvents(group1.id()));

    QVERIFY(waitSignal(rowsInserted));

    QVERIFY(conv.rowCount() >= 5 );

    QCOMPARE(conv.event(conv.index(0, 0)).freeText(), QLatin1String("V"));
    QCOMPARE(conv.event(conv.index(1, 0)).freeText(), QLatin1String("IV"));
    QCOMPARE(conv.event(conv.index(2, 0)).freeText(), QLatin1String("III"));
    QCOMPARE(conv.event(conv.index(3, 0)).freeText(), QLatin1String("II"));
    QCOMPARE(conv.event(conv.index(4, 0)).freeText(), QLatin1String("I"));
}
开发者ID:adenexter,项目名称:libcommhistory,代码行数:43,代码来源:conversationmodeltest.cpp


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