mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
ActivityListModel now keeps track of the account connection state
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
8cf778ba94
commit
431ccfec5a
@ -48,6 +48,11 @@ ActivityListModel::ActivityListModel(AccountState *accountState,
|
||||
: QAbstractListModel(parent)
|
||||
, _accountState(accountState)
|
||||
{
|
||||
if (_accountState) {
|
||||
connect(_accountState, &AccountState::stateChanged,
|
||||
this, &ActivityListModel::accountStateChanged);
|
||||
_accountStateWasConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ActivityListModel::roleNames() const
|
||||
@ -90,8 +95,17 @@ QHash<int, QByteArray> ActivityListModel::roleNames() const
|
||||
|
||||
void ActivityListModel::setAccountState(AccountState *state)
|
||||
{
|
||||
if (_accountState == state) {
|
||||
return;
|
||||
}
|
||||
|
||||
_accountState = state;
|
||||
Q_EMIT accountStateChanged();
|
||||
if (_accountState) {
|
||||
connect(_accountState, &AccountState::stateChanged,
|
||||
this, &ActivityListModel::accountStateHasChanged);
|
||||
_accountStateWasConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityListModel::setCurrentItem(const int currentItem)
|
||||
@ -558,6 +572,25 @@ void ActivityListModel::addEntriesToActivityList(const ActivityList &activityLis
|
||||
setHasSyncConflicts(conflictsFound);
|
||||
}
|
||||
|
||||
void ActivityListModel::accountStateHasChanged()
|
||||
{
|
||||
if (!_accountState) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_accountStateWasConnected == _accountState->isConnected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_accountState->isConnected()) {
|
||||
_durationSinceDisconnection.start();
|
||||
} else {
|
||||
_durationSinceDisconnection.invalidate();
|
||||
}
|
||||
|
||||
_accountStateWasConnected = _accountState->isConnected();
|
||||
}
|
||||
|
||||
void ActivityListModel::addErrorToActivityList(const Activity &activity, const ErrorType type)
|
||||
{
|
||||
qCDebug(lcActivity) << "Error successfully added to the notification list: " << type << activity._message << activity._subject << activity._syncResultStatus << activity._syncFileItemStatus;
|
||||
|
||||
@ -163,6 +163,7 @@ protected slots:
|
||||
|
||||
private slots:
|
||||
void addEntriesToActivityList(const OCC::ActivityList &activityList);
|
||||
void accountStateHasChanged();
|
||||
|
||||
private:
|
||||
static QVariantList convertLinksToMenuEntries(const Activity &activity);
|
||||
@ -209,6 +210,10 @@ private:
|
||||
|
||||
bool _hasSyncConflicts = false;
|
||||
|
||||
bool _accountStateWasConnected = false;
|
||||
|
||||
QElapsedTimer _durationSinceDisconnection;
|
||||
|
||||
static constexpr quint32 MaxActionButtons = 3;
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user