本文整理汇总了C++中ModelWatcher::waitForUpdated方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelWatcher::waitForUpdated方法的具体用法?C++ ModelWatcher::waitForUpdated怎么用?C++ ModelWatcher::waitForUpdated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelWatcher
的用法示例。
在下文中一共展示了ModelWatcher::waitForUpdated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSortByTimeUpdate
void CallModelTest::testSortByTimeUpdate()
{
deleteAll();
CallModel model;
watcher.setModel(&model);
/*
* user1, missed (2)
* (user1, dialed)
* user1, missed (1)
*/
QDateTime when = QDateTime::currentDateTime();
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when, REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(1), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(2), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(3), REMOTEUID1);
QVERIFY(watcher.waitForAdded(4));
QVERIFY(model.setFilter(CallModel::SortByTime, CallEvent::MissedCallType));
QVERIFY(model.getEvents());
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 2);
Event e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.eventCount(), 2);
Event e2 = model.event(model.index(1, 0));
QCOMPARE(e2.remoteUid(), REMOTEUID1);
QVERIFY(e2.isMissedCall());
QVERIFY(e2.eventCount() <= 1);
// add received call, count for top item should reset
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs(4), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 1);
CallModel model2;
model2.setQueryMode(EventModel::SyncQuery);
QVERIFY(model2.getEvents(CallModel::SortByTime, CallEvent::MissedCallType));
QCOMPARE(model2.rowCount(), 2);
QVERIFY(model2.event(model2.index(0, 0)).eventCount() <= 1);
// add missed call, count should remain 1
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(5), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
e1 = model.event(model.index(0, 0));
int firstMissedId = e1.id();
QCOMPARE(e1.eventCount(), 1);
QCOMPARE(model2.event(model2.index(0, 0)).eventCount(), 1);
QVERIFY(model2.getEvents(CallModel::SortByTime, CallEvent::MissedCallType));
QCOMPARE(model2.rowCount(), 3);
QCOMPARE(model2.event(model2.index(0, 0)).eventCount(), 1);
// add another missed call, count should increase
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(6), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 2);
QCOMPARE(model2.event(model2.index(0, 0)).eventCount(), 2);
QVERIFY(model2.getEvents(CallModel::SortByTime, CallEvent::MissedCallType));
QCOMPARE(model2.rowCount(), 3);
QCOMPARE(model2.event(model.index(0, 0)).eventCount(), 2);
// mark latest missed call as read, the first should also be marked
Event e = model.event(model.index(0, 0));
e.setIsRead(true);
QVERIFY(model.modifyEvent(e));
QVERIFY(watcher.waitForUpdated(2));
QVERIFY(model.databaseIO().getEvent(firstMissedId, e));
QVERIFY(e.isRead());
}
示例2: testModifyEvent
void CallModelTest::testModifyEvent()
{
Event e1, e2, e3;
deleteAll();
CallModel model;
watcher.setModel(&model);
/*
* user1, received
* user1, dialed
* user2, missed
* user1, received
* -> displayed as
* user1, received
* user2, missed
*/
QDateTime when = QDateTime::currentDateTime();
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when, REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(1), REMOTEUID2);
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(2), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs(3), REMOTEUID1);
QVERIFY(watcher.waitForAdded(6, 4)); // always grouped by contact -> +2
QVERIFY(model.setFilter(CallModel::SortByContact));
QVERIFY(model.getEvents());
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.direction(), Event::Inbound);
e2 = model.event(model.index(1, 0));
QCOMPARE(e2.remoteUid(), REMOTEUID2);
QCOMPARE(e2.direction(), Event::Inbound);
/*
* upgrade latest user1 call to video:
* user1, received, video
* user1, dialed
* user2, missed
*/
e1.setIsVideoCall(true);
QVERIFY(model.modifyEvent(e1));
QVERIFY(watcher.waitForUpdated());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.direction(), Event::Inbound);
QCOMPARE(e1.isVideoCall(), true);
e2 = model.event(model.index(1, 0));
QCOMPARE(e2.remoteUid(), REMOTEUID1);
QCOMPARE(e2.direction(), Event::Outbound);
QCOMPARE(e2.isVideoCall(), false);
e3 = model.event(model.index(2, 0));
QCOMPARE(e3.remoteUid(), REMOTEUID2);
QCOMPARE(e3.direction(), Event::Inbound);
QCOMPARE(e3.isVideoCall(), false);
/*
* downgrade back to audio:
* user1, received
* user2, missed
*/
e1.setIsVideoCall(false);
QVERIFY(model.modifyEvent(e1));
QVERIFY(watcher.waitForUpdated());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.direction(), Event::Inbound);
e2 = model.event(model.index(1, 0));
QCOMPARE(e2.remoteUid(), REMOTEUID2);
QCOMPARE(e2.direction(), Event::Inbound);
}
示例3: testSortByContactUpdate
void CallModelTest::testSortByContactUpdate()
{
deleteAll();
CallModel model;
watcher.setModel(&model);
/*
* user1, missed (2)
* (user1, dialed)
* user1, missed (1)
*/
QDateTime when = QDateTime::currentDateTime();
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when, REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(1), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(2), REMOTEUID1);
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(3), REMOTEUID1);
QVERIFY(watcher.waitForAdded(4));
QVERIFY(model.setFilter(CallModel::SortByContact));
QVERIFY(model.getEvents());
QVERIFY(watcher.waitForModelReady());
QCOMPARE(model.rowCount(), 1);
Event e1 = model.event(model.index(0, 0));
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.eventCount(), 2);
// add received call
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, false, when.addSecs(4), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 1);
QCOMPARE(e1.direction(), Event::Inbound);
// add call to another contact
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(5), REMOTEUID2);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 1);
QCOMPARE(e1.direction(), Event::Outbound);
QCOMPARE(e1.remoteUid(), REMOTEUID2);
// missed call to first contact, should reorder
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(6), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
int firstMissedId = e1.id();
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.eventCount(), 1);
// another missed call, increase event count
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(7), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.eventCount(), 2);
// mark latest missed call as read, the first should also be marked
Event e = model.event(model.index(0, 0));
e.setIsRead(true);
QVERIFY(model.modifyEvent(e));
QVERIFY(watcher.waitForUpdated(7));
QVERIFY(model.databaseIO().getEvent(firstMissedId, e));
QVERIFY(e.isRead());
// add call to the other contact...
addTestEvent(model, Event::CallEvent, Event::Outbound, ACCOUNT1, -1, "", false, false, when.addSecs(10), REMOTEUID2);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QCOMPARE(e1.eventCount(), 2);
QCOMPARE(e1.direction(), Event::Outbound);
QCOMPARE(e1.remoteUid(), REMOTEUID2);
// ...and a missed call to the first -> move to top and increase event count
addTestEvent(model, Event::CallEvent, Event::Inbound, ACCOUNT1, -1, "", false, true, when.addSecs(15), REMOTEUID1);
QVERIFY(watcher.waitForAdded());
QCOMPARE(model.rowCount(), 2);
e1 = model.event(model.index(0, 0));
QVERIFY(e1.isMissedCall());
QCOMPARE(e1.remoteUid(), REMOTEUID1);
QCOMPARE(e1.eventCount(), 3);
}