diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index ae8522d03..f11b87c81 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -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(); diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index cf76aeedc..a4a8f4be8 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -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 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(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 diff --git a/src/gui/folderstatusmodel.h b/src/gui/folderstatusmodel.h index 4b3e3942d..8279be3ff 100644 --- a/src/gui/folderstatusmodel.h +++ b/src/gui/folderstatusmodel.h @@ -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