コード例 #1
0
ファイル: contactlistmodel.cpp プロジェクト: psi-im/psi
void ContactListModel::Private::commit()
{
    SLOW_TIMER(100);

    commitTimerStartTime = QDateTime();

    commitTimer->stop();
    if (operationQueue.isEmpty())
        return;

    QHashIterator<PsiContact*, int> it(operationQueue);

    QList<PsiContact*> contactsForAdding;
    QList<PsiContact*> contactsForUpdate;


    while (it.hasNext()) {
        it.next();
        PsiContact *contact = it.key();

        int operations = simplifiedOperationList(it.value());
        if (operations & AddContact) {
            Q_ASSERT(!monitoredContacts.contains(contact));
            if (monitoredContacts.contains(contact))
                continue;

            contactsForAdding << contact;

        }
        if (operations & RemoveContact)
            Q_ASSERT(false);
        if (operations & UpdateContact)
            contactsForUpdate << contact;
        if (operations & ContactGroupsChanged) {
            removeContact(contact);
            if (!contactsForAdding.contains(contact)) {
                contactsForAdding << contact;
            }
        }
    }

    addContacts(contactsForAdding);
    updateContacts(contactsForUpdate);
    operationQueue.clear();
}
コード例 #2
0
void ContactListModelUpdater::commit()
{
	if (!updatesEnabled())
		return;

// qWarning("updater(%x):commit", (int)this);
	// qWarning("*** ContactListModelUpdater::commit(). operationQueue_.count() = %d", operationQueue_.count());
	commitTimerStartTime_ = QDateTime();
	commitTimer_->stop();
	if (operationQueue_.isEmpty())
		return;

	bool doBulkUpdate = operationQueue_.count() > 1;
	if (doBulkUpdate)
		emit beginBulkContactUpdate();

	QHashIterator<PsiContact*, int> it(operationQueue_);
	while (it.hasNext()) {
		it.next();

		int operations = simplifiedOperationList(it.value());
		if (operations & AddContact)
			emit addedContact(it.key());
		if (operations & RemoveContact)
			Q_ASSERT(false);
		if (operations & UpdateContact)
			emit contactUpdated(it.key());
		if (operations & ContactGroupsChanged)
			emit contactGroupsChanged(it.key());
	}

	if (doBulkUpdate)
		emit endBulkContactUpdate();

	operationQueue_.clear();
}