本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例5: asyncMode
void ConversationModelTest::asyncMode()
{
ConversationModel model;
model.enableContactChanges(false);
watcher.setModel(&model);
QVERIFY(model.getEvents(group1.id()));
QVERIFY(watcher.waitForModelReady());
}
示例6: initTestCase
void ClassZeroSMSModelTest::initTestCase()
{
m_pModel = new ClassZeroSMSModel;
qsrand(QDateTime::currentDateTime().toTime_t());
watcher.setLoop(&m_eventLoop);
watcher.setModel(m_pModel);
}
示例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);
}
示例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);
}
示例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);
}
}
示例10: initTestCase
void UnreadEventModelTest::initTestCase()
{
EventModel model;
watcher.setLoop(&m_eventLoop);
qsrand(QDateTime::currentDateTime().toTime_t());
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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"));
}