forked from blue/squawk
fix bug when everything was treated as animation, bug with not working group amount of messages, handled the situation when preview is painted but the file was lost
This commit is contained in:
parent
0d584c5aba
commit
721f6daa36
10 changed files with 62 additions and 8 deletions
|
@ -31,7 +31,8 @@ Models::Account::Account(const QMap<QString, QVariant>& data, Models::Item* pare
|
|||
avatarPath(data.value("avatarPath").toString()),
|
||||
state(Shared::ConnectionState::disconnected),
|
||||
availability(Shared::Availability::offline),
|
||||
passwordType(Shared::AccountPassword::plain)
|
||||
passwordType(Shared::AccountPassword::plain),
|
||||
wasEverConnected(false)
|
||||
{
|
||||
QMap<QString, QVariant>::const_iterator sItr = data.find("state");
|
||||
if (sItr != data.end()) {
|
||||
|
@ -56,8 +57,19 @@ void Models::Account::setState(Shared::ConnectionState p_state)
|
|||
if (state != p_state) {
|
||||
state = p_state;
|
||||
changed(2);
|
||||
if (state == Shared::ConnectionState::disconnected) {
|
||||
toOfflineState();
|
||||
switch (state) {
|
||||
case Shared::ConnectionState::disconnected:
|
||||
toOfflineState();
|
||||
break;
|
||||
case Shared::ConnectionState::connected:
|
||||
if (wasEverConnected) {
|
||||
emit reconnected();
|
||||
} else {
|
||||
wasEverConnected = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,9 @@ namespace Models {
|
|||
QString getBareJid() const;
|
||||
QString getFullJid() const;
|
||||
|
||||
signals:
|
||||
void reconnected();
|
||||
|
||||
private:
|
||||
QString login;
|
||||
QString password;
|
||||
|
@ -87,6 +90,7 @@ namespace Models {
|
|||
Shared::ConnectionState state;
|
||||
Shared::Availability availability;
|
||||
Shared::AccountPassword passwordType;
|
||||
bool wasEverConnected;
|
||||
|
||||
protected slots:
|
||||
void toOfflineState() override;
|
||||
|
|
|
@ -240,3 +240,9 @@ QString Models::Contact::getDisplayedName() const
|
|||
return getContactName();
|
||||
}
|
||||
|
||||
void Models::Contact::handleRecconnect()
|
||||
{
|
||||
if (getMessagesCount() > 0) {
|
||||
feed->requestLatestMessages();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
QString getStatus() const;
|
||||
QString getDisplayedName() const override;
|
||||
|
||||
void handleRecconnect(); //this is a special method Models::Roster calls when reconnect happens
|
||||
|
||||
protected:
|
||||
void _removeChild(int index) override;
|
||||
void _appendChild(Models::Item * child) override;
|
||||
|
|
|
@ -104,6 +104,8 @@ void Models::Reference::onChildChanged(Models::Item* item, int row, int col)
|
|||
{
|
||||
if (item == original) {
|
||||
emit childChanged(this, row, col);
|
||||
} else {
|
||||
emit childChanged(item, row, col);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ Models::Roster::~Roster()
|
|||
void Models::Roster::addAccount(const QMap<QString, QVariant>& data)
|
||||
{
|
||||
Account* acc = new Account(data);
|
||||
connect(acc, &Account::reconnected, this, &Roster::onAccountReconnected);
|
||||
root->appendChild(acc);
|
||||
accounts.insert(std::make_pair(acc->getName(), acc));
|
||||
accountsModel->addAccount(acc);
|
||||
|
@ -744,6 +745,7 @@ void Models::Roster::removeAccount(const QString& account)
|
|||
}
|
||||
}
|
||||
|
||||
disconnect(acc, &Account::reconnected, this, &Roster::onAccountReconnected);
|
||||
acc->deleteLater();
|
||||
}
|
||||
|
||||
|
@ -1003,3 +1005,15 @@ Models::Element * Models::Roster::getElement(const Models::Roster::ElId& id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void Models::Roster::onAccountReconnected()
|
||||
{
|
||||
Account* acc = static_cast<Account*>(sender());
|
||||
|
||||
QString accName = acc->getName();
|
||||
for (const std::pair<const ElId, Contact*>& pair : contacts) {
|
||||
if (pair.first.account == accName) {
|
||||
pair.second->handleRecconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ private:
|
|||
|
||||
private slots:
|
||||
void onAccountDataChanged(const QModelIndex& tl, const QModelIndex& br, const QVector<int>& roles);
|
||||
void onAccountReconnected();
|
||||
void onChildChanged(Models::Item* item, int row, int col);
|
||||
void onChildIsAboutToBeInserted(Item* parent, int first, int last);
|
||||
void onChildInserted();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue