forked from blue/squawk
clearing presences and statuses on disconnect of an account
This commit is contained in:
parent
49aa99d4db
commit
833913cac2
@ -30,6 +30,9 @@ void Models::Account::setState(Shared::ConnectionState p_state)
|
||||
if (state != p_state) {
|
||||
state = p_state;
|
||||
changed(2);
|
||||
if (state == Shared::disconnected) {
|
||||
toOfflineState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,3 +201,8 @@ void Models::Account::setError(const QString& p_resource)
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Account::toOfflineState()
|
||||
{
|
||||
setAvailability(Shared::offline);
|
||||
Item::toOfflineState();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace Models {
|
||||
class Account : public Item {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Account(const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
||||
~Account();
|
||||
@ -50,6 +51,9 @@ namespace Models {
|
||||
QString error;
|
||||
Shared::ConnectionState state;
|
||||
Shared::Availability availability;
|
||||
|
||||
protected slots:
|
||||
void toOfflineState() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -320,3 +320,18 @@ const Models::Account * Models::Contact::getParentAccount() const
|
||||
|
||||
return static_cast<const Account*>(p);
|
||||
}
|
||||
|
||||
void Models::Contact::toOfflineState()
|
||||
{
|
||||
emit childIsAboutToBeRemoved(this, 0, childItems.size());
|
||||
for (int i = 0; i < childItems.size(); ++i) {
|
||||
Item* item = childItems[i];
|
||||
disconnect(item, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh()));
|
||||
Item::_removeChild(i);
|
||||
item->deleteLater();
|
||||
}
|
||||
childItems.clear();
|
||||
presences.clear();
|
||||
emit childRemoved();
|
||||
refresh();
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ protected:
|
||||
|
||||
protected slots:
|
||||
void refresh();
|
||||
void toOfflineState() override;
|
||||
|
||||
protected:
|
||||
void setAvailability(Shared::Availability p_state);
|
||||
|
@ -140,3 +140,11 @@ void Models::Item::changed(int col)
|
||||
emit childChanged(this, row(), col);
|
||||
}
|
||||
}
|
||||
|
||||
void Models::Item::toOfflineState()
|
||||
{
|
||||
for (std::deque<Item*>::iterator itr = childItems.begin(), end = childItems.end(); itr != end; ++itr) {
|
||||
Item* it = *itr;
|
||||
it->toOfflineState();
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ class Item : public QObject{
|
||||
Item* parent;
|
||||
|
||||
protected slots:
|
||||
virtual void toOfflineState();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user