forked from blue/squawk
adding and removing contacts, rester testing
This commit is contained in:
parent
f0f26ae1a1
commit
bb509be29a
16 changed files with 389 additions and 14 deletions
|
@ -66,6 +66,8 @@ void Models::Accounts::addAccount(Account* account)
|
|||
accs.push_back(account);
|
||||
connect(account, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onAccountChanged(Models::Item*, int, int)));
|
||||
endInsertRows();
|
||||
|
||||
emit sizeChanged(accs.size());
|
||||
}
|
||||
|
||||
void Models::Accounts::onAccountChanged(Item* item, int row, int col)
|
||||
|
@ -93,4 +95,17 @@ void Models::Accounts::removeAccount(int index)
|
|||
disconnect(account, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onAccountChanged(Models::Item*, int, int)));
|
||||
accs.erase(accs.begin() + index);
|
||||
endRemoveRows();
|
||||
|
||||
emit sizeChanged(accs.size());
|
||||
}
|
||||
|
||||
std::deque<QString> Models::Accounts::getNames() const
|
||||
{
|
||||
std::deque<QString> res;
|
||||
|
||||
for (std::deque<Models::Account*>::const_iterator i = accs.begin(), end = accs.end(); i != end; ++i) {
|
||||
res.push_back((*i)->getName());
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,11 @@ public:
|
|||
|
||||
Account* getAccount(int index);
|
||||
|
||||
std::deque<QString> getNames() const;
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
void sizeChanged(unsigned int size);
|
||||
|
||||
private:
|
||||
std::deque<Account*> accs;
|
||||
|
|
|
@ -260,6 +260,7 @@ void Models::Roster::addContact(const QString& account, const QString& jid, cons
|
|||
qDebug() << "An attempt to add a contact " << jid << " ungrouped to non the account " << account << " for the second time, skipping";
|
||||
return;
|
||||
}
|
||||
itr++;
|
||||
}
|
||||
parent = acc;
|
||||
} else {
|
||||
|
@ -345,7 +346,8 @@ void Models::Roster::removeGroup(const QString& account, const QString& name)
|
|||
}
|
||||
}
|
||||
|
||||
delete item;
|
||||
item->deleteLater();
|
||||
groups.erase(gItr);
|
||||
}
|
||||
|
||||
void Models::Roster::changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data)
|
||||
|
@ -366,6 +368,7 @@ void Models::Roster::removeContact(const QString& account, const QString& jid)
|
|||
ElId id(account, jid);
|
||||
std::multimap<ElId, Contact*>::iterator cBeg = contacts.lower_bound(id);
|
||||
std::multimap<ElId, Contact*>::iterator cEnd = contacts.upper_bound(id);
|
||||
std::multimap<ElId, Contact*>::iterator cpBeg = cBeg;
|
||||
|
||||
QSet<QString> toRemove;
|
||||
for (; cBeg != cEnd; ++cBeg) {
|
||||
|
@ -376,8 +379,9 @@ void Models::Roster::removeContact(const QString& account, const QString& jid)
|
|||
}
|
||||
|
||||
parent->removeChild(contact->row());
|
||||
delete contact;
|
||||
contact->deleteLater();
|
||||
}
|
||||
contacts.erase(cpBeg, cEnd);
|
||||
|
||||
for (QSet<QString>::const_iterator itr = toRemove.begin(), end = toRemove.end(); itr != end; ++itr) {
|
||||
removeGroup(account, *itr);
|
||||
|
@ -402,6 +406,7 @@ void Models::Roster::removeContact(const QString& account, const QString& jid, c
|
|||
for (;cBeg != cEnd; ++cBeg) {
|
||||
if (cBeg->second->parentItem() == gr) {
|
||||
cont = cBeg->second;
|
||||
contacts.erase(cBeg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +417,7 @@ void Models::Roster::removeContact(const QString& account, const QString& jid, c
|
|||
}
|
||||
|
||||
gr->removeChild(cont->row());
|
||||
delete cont;
|
||||
cont->deleteLater();
|
||||
|
||||
if (gr->childCount() == 0) {
|
||||
removeGroup(account, group);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue