Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ void FolderMan::removeFolderSync(Folder *f)

qCInfo(lcFolderMan) << "Removing " << f->path();

Q_EMIT folderAboutToBeRemoved(f);

const bool currentlyRunning = f->isSyncRunning();
if (currentlyRunning) {
// abort the sync now
Expand All @@ -702,7 +704,6 @@ void FolderMan::removeFolderSync(Folder *f)

disconnectFolder(f);

Q_EMIT folderRemoved(f);
Q_EMIT folderListChanged();

f->deleteLater();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/folderman.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class OWNCLOUDGUI_EXPORT FolderMan : public QObject
* Emitted whenever the list of configured folders changes.
*/
void folderListChanged();
void folderRemoved(Folder *folder);
void folderAboutToBeRemoved(Folder *folder);
// Refactoring todo: we need folderAdded too. The folder model should use that for normal folder updates instead of folderListChanged
// which causes full rebuild of the model -> crazy inefficient. Ideally folderListChanged should only be emitted for large operations (eg after loading
// folders from config or from new account)
Expand Down
12 changes: 7 additions & 5 deletions src/gui/issueswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,7 @@ IssuesWidget::IssuesWidget(QWidget *parent)
tr("There were conflicts. <a href=\"%1\">Check the documentation on how to resolve them.</a>")
.arg(Theme::instance()->conflictHelpUrl()));

connect(FolderMan::instance(), &FolderMan::folderRemoved, this, [this](Folder *f) {
_model->remove_if([f](const ProtocolItem &item) {
return item.folder() == f;
});
});
connect(FolderMan::instance(), &FolderMan::folderAboutToBeRemoved, this, &IssuesWidget::slotFolderAboutToBeRemoved);
}

IssuesWidget::~IssuesWidget()
Expand Down Expand Up @@ -353,6 +349,12 @@ void IssuesWidget::slotItemCompleted(Folder *folder, const SyncFileItemPtr &item
_model->addProtocolItem(ProtocolItem { folder, item });
}

void IssuesWidget::slotFolderAboutToBeRemoved(Folder *folder)
{
// Remove all items whose folder matches the folder that's going to be removed
_model->remove_if([folder](const ProtocolItem &item) { return item.folder() == folder; });
}

void IssuesWidget::filterDidChange()
{
// We have two filters here: the filter by status (which can have multiple items checked *off*...
Expand Down
1 change: 1 addition & 0 deletions src/gui/issueswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class IssuesWidget : public QWidget
public Q_SLOTS:
void slotProgressInfo(Folder *folder, const ProgressInfo &progress);
void slotItemCompleted(Folder *folder, const SyncFileItemPtr &item);
void slotFolderAboutToBeRemoved(Folder *folder);
void filterDidChange();

Q_SIGNALS:
Expand Down
12 changes: 7 additions & 5 deletions src/gui/protocolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ ProtocolWidget::ProtocolWidget(QWidget *parent)
showFilterMenu(_ui->_filterButton, _sortModel, static_cast<int>(ProtocolItemModel::ProtocolItemRole::Account), tr("Account"));
});

connect(FolderMan::instance(), &FolderMan::folderRemoved, this, [this](Folder *f) {
_model->remove_if([f](const ProtocolItem &item) {
return item.folder() == f;
});
});
connect(FolderMan::instance(), &FolderMan::folderAboutToBeRemoved, this, &ProtocolWidget::slotFolderAboutToBeRemoved);
}

ProtocolWidget::~ProtocolWidget()
Expand Down Expand Up @@ -213,4 +209,10 @@ void ProtocolWidget::filterDidChange()
_ui->_filterButton->setText(CommonStrings::filterButtonText(_sortModel->filterRegularExpression().pattern().isEmpty() ? 0 : 1));
}

void ProtocolWidget::slotFolderAboutToBeRemoved(Folder *folder)
{
// Remove all items whose folder matches the folder that's going to be removed
_model->remove_if([folder](const ProtocolItem &item) { return item.folder() == folder; });
}

} // OCC namespace
1 change: 1 addition & 0 deletions src/gui/protocolwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ProtocolWidget : public QWidget
public Q_SLOTS:
void slotItemCompleted(Folder *folder, const SyncFileItemPtr &item);
void filterDidChange();
void slotFolderAboutToBeRemoved(Folder *folder);

private Q_SLOTS:
void slotItemContextMenu(const QPoint &pos);
Expand Down
7 changes: 7 additions & 0 deletions src/gui/scheduling/etagwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ETagWatcher::ETagWatcher(FolderMan *folderMan, QObject *parent)
{
// Refactoring todo: use folderAdded/folderAboutToBeRemoved signals when implemented on the FolderMan
connect(folderMan, &FolderMan::folderListChanged, this, &ETagWatcher::slotFolderListChanged);
connect(folderMan, &FolderMan::folderAboutToBeRemoved, this, &ETagWatcher::slotFolderAboutToBeRemoved);
}

void ETagWatcher::slotSpaceChanged(GraphApi::Space *space)
Expand Down Expand Up @@ -76,6 +77,12 @@ void ETagWatcher::slotFolderListChanged()
_lastEtagJobForSpace = std::move(newMap);
}

void ETagWatcher::slotFolderAboutToBeRemoved(Folder *folder)
{
QString spaceId = folder->definition().spaceId();
_lastEtagJobForSpace.erase(spaceId);
}

void ETagWatcher::updateEtag(const QString &spaceId, const QString &etag)
{
// the server must provide a valid etag but there might be bugs
Expand Down
1 change: 1 addition & 0 deletions src/gui/scheduling/etagwatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ETagWatcher : public QObject
public Q_SLOTS:
void slotSpaceChanged(GraphApi::Space *space);
void slotFolderListChanged();
void slotFolderAboutToBeRemoved(Folder *folder);

private:
void updateEtag(const QString &spaceId, const QString &etag);
Expand Down
Loading