mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +03:00
AccountSettings: automatically refresh and expands the undecided folders #3541
This commit is contained in:
parent
157f59d44a
commit
38da1b7de1
3 changed files with 44 additions and 2 deletions
|
@ -86,6 +86,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
|
|||
|
||||
connect(ui->_folderList, SIGNAL(expanded(QModelIndex)) , this, SLOT(refreshSelectiveSyncStatus()));
|
||||
connect(ui->_folderList, SIGNAL(collapsed(QModelIndex)) , this, SLOT(refreshSelectiveSyncStatus()));
|
||||
connect(_model, SIGNAL(suggestExpand(QModelIndex)), ui->_folderList, SLOT(expand(QModelIndex)));
|
||||
connect(_model, SIGNAL(dirtyChanged()), this, SLOT(refreshSelectiveSyncStatus()));
|
||||
refreshSelectiveSyncStatus();
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void FolderStatusModel::setAccountState(const AccountState* accountState)
|
|||
|
||||
connect(f, SIGNAL(progressInfo(ProgressInfo)), this, SLOT(slotSetProgress(ProgressInfo)), Qt::UniqueConnection);
|
||||
connect(f, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection);
|
||||
connect(f, SIGNAL(newBigFolderDiscovered(QString)), this, SIGNAL(dirtyChanged()), Qt::UniqueConnection);
|
||||
connect(f, SIGNAL(newBigFolderDiscovered(QString)), this, SLOT(slotNewBigFolder()), Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
|
@ -437,6 +437,8 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
|
|||
}
|
||||
auto selectiveSyncUndecidedList = parentInfo->_folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
|
||||
|
||||
QVarLengthArray<int> undecidedIndexes;
|
||||
|
||||
int i = 0;
|
||||
foreach (QString path, list) {
|
||||
SubFolderInfo newInfo;
|
||||
|
@ -468,9 +470,19 @@ void FolderStatusModel::slotUpdateDirectories(const QStringList &list_)
|
|||
}
|
||||
newInfo._isUndecided = selectiveSyncUndecidedList.contains(path);
|
||||
parentInfo->_subs.append(newInfo);
|
||||
|
||||
foreach(const QString &str , selectiveSyncUndecidedList) {
|
||||
if (str.startsWith(path)) {
|
||||
undecidedIndexes.append(newInfo._pathIdx.last());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
|
||||
for (auto it = undecidedIndexes.begin(); it != undecidedIndexes.end(); ++it) {
|
||||
suggestExpand(idx.child(*it, 0));
|
||||
}
|
||||
}
|
||||
|
||||
void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply* r)
|
||||
|
@ -748,4 +760,31 @@ void FolderStatusModel::resetFolders()
|
|||
setAccountState(_accountState);
|
||||
}
|
||||
|
||||
void FolderStatusModel::slotNewBigFolder()
|
||||
{
|
||||
auto f = qobject_cast<Folder *>(sender());
|
||||
Q_ASSERT(f);
|
||||
|
||||
int folderIndex = -1;
|
||||
for (int i = 0; i < _folders.count(); ++i) {
|
||||
if (_folders.at(i)._folder == f) {
|
||||
folderIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (folderIndex < 0) { return; }
|
||||
|
||||
_folders[folderIndex]._fetched = false;
|
||||
_folders[folderIndex]._fetching = false;
|
||||
if (!_folders.at(folderIndex)._subs.isEmpty()) {
|
||||
beginRemoveRows(index(folderIndex), 0, _folders.at(folderIndex)._subs.count() - 1);
|
||||
_folders[folderIndex]._subs.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
emit suggestExpand(index(folderIndex));
|
||||
emit dirtyChanged();
|
||||
}
|
||||
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -94,8 +94,9 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void slotUpdateDirectories(const QStringList &);
|
||||
void slotFolderSyncStateChange();
|
||||
void slotLscolFinishedWithError(QNetworkReply *r);
|
||||
void slotFolderSyncStateChange();
|
||||
void slotNewBigFolder();
|
||||
|
||||
private:
|
||||
QStringList createBlackList(OCC::FolderStatusModel::SubFolderInfo* root,
|
||||
|
@ -111,6 +112,7 @@ private:
|
|||
|
||||
signals:
|
||||
void dirtyChanged();
|
||||
void suggestExpand(const QModelIndex &); // Tell the view that this item should be expanded because it has a undecided item
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
|
Loading…
Reference in a new issue