本文整理汇总了C++中ModelWatcher::waitForDeleted方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelWatcher::waitForDeleted方法的具体用法?C++ ModelWatcher::waitForDeleted怎么用?C++ ModelWatcher::waitForDeleted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelWatcher
的用法示例。
在下文中一共展示了ModelWatcher::waitForDeleted方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testDeleteEvent
void CallModelTest::testDeleteEvent()
{
CallModel model;
watcher.setModel(&model);
// force change of sorting to SortByContact
QVERIFY( model.setFilter( CallModel::SortByContact ) );
QVERIFY( model.getEvents() );
QVERIFY(watcher.waitForModelReady());
/* by contact:
* -----------
* "", received (0)
* user2, received (0)
* user1, received (0)
*/
// delete first event from hidden number
Event e = model.event( model.index( 0, 0 ) );
QVERIFY( e.isValid() );
QCOMPARE( e.type(), Event::CallEvent );
qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
QCOMPARE( e.direction(), Event::Inbound );
QCOMPARE( e.isMissedCall(), false );
QCOMPARE( e.remoteUid(), QLatin1String("<hidden>") );
// delete it
QVERIFY( model.deleteEvent( e.id() ) );
QVERIFY( watcher.waitForDeleted() );
// correct test helper lists to match current situation
QMutableListIterator<TestCallItem> i(testCalls);
while (i.hasNext()) {
i.next();
if (i.value().remoteUid == QLatin1String("<hidden>"))
i.remove();
}
// test if model contains what we want it does
testGetEvents( CallModel::SortByContact, 2, testCalls );
/* by contact:
* -----------
* user2, received (0)
* user1, received (0)
*/
// delete first group from user2
e = model.event( model.index( 0, 0 ) );
QVERIFY( e.isValid() );
QCOMPARE( e.type(), Event::CallEvent );
qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
QCOMPARE( e.direction(), Event::Inbound );
QCOMPARE( e.isMissedCall(), false );
QCOMPARE( e.remoteUid(), REMOTEUID2 );
// delete it
QVERIFY( model.deleteEvent( e.id() ) );
QVERIFY( watcher.waitForDeleted(2) );
// correct test helper lists to match current situation
i = QMutableListIterator<TestCallItem>(testCalls);
while (i.hasNext()) {
i.next();
if (i.value().remoteUid == REMOTEUID2)
i.remove();
}
// test if model contains what we want it does
testGetEvents( CallModel::SortByContact, 1, testCalls );
// force change of sorting to SortByTime
QVERIFY( model.setFilter( CallModel::SortByTime ) );
QVERIFY(watcher.waitForModelReady());
/* by time:
* --------
* user1, received (6)***
* user1, dialed (1)
* user1, missed (2)
* user1, dialed (1)
* user1, received (2)
* user1, missed (1)
* user1, dialed (2)
*
* ||
* \/
*
* user1, dialed (1)
* user1, missed (2)
* user1, dialed (1)
* user1, received (2)
* user1, missed (1)
* user1, dialed (2)
*/
// take the event
e = model.event( model.index( 0, 0 ) );
QVERIFY( e.isValid() );
QCOMPARE( e.type(), Event::CallEvent );
qDebug() << "EVENT:" << e.id() << "|" << e.remoteUid() << "|" << e.direction() << "|" << e.isMissedCall() << "|" << e.eventCount();
QCOMPARE( e.direction(), Event::Inbound );
QCOMPARE( e.isMissedCall(), false );
// delete it
QVERIFY( model.deleteEvent( e.id() ) );
QVERIFY( watcher.waitForDeleted(6) );
// correct test helper lists to match current situation
foreach (TestCallItem item, testCalls) {
qDebug() << item.remoteUid << item.callType << item.eventCount;
//.........这里部分代码省略.........