From 5611f876b0b22c921312c5aa23fa59de071f59e7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 10 May 2024 13:10:43 +0800 Subject: [PATCH 1/4] Constify openLocalFolder Signed-off-by: Claudio Cambra --- src/gui/tray/usermodel.cpp | 6 ++---- src/gui/tray/usermodel.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 9c9f3cf819e93..3121fc5f2bc3d 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -925,11 +925,9 @@ UnifiedSearchResultsListModel *User::getUnifiedSearchResultsListModel() const return _unifiedSearchResultsModel; } -void User::openLocalFolder() +void User::openLocalFolder() const { - const auto folder = getFolder(); - - if (folder) { + if (const auto folder = getFolder()) { QDesktopServices::openUrl(QUrl::fromLocalFile(folder->path())); } } diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 33c3ae455a5bb..466cd6ab81976 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -76,7 +76,7 @@ class User : public QObject [[nodiscard]] Folder *getFolder() const; ActivityListModel *getActivityModel(); [[nodiscard]] UnifiedSearchResultsListModel *getUnifiedSearchResultsListModel() const; - void openLocalFolder(); + void openLocalFolder() const; void openFolderLocallyOrInBrowser(const QString &fullRemotePath); [[nodiscard]] QString name() const; [[nodiscard]] QString server(bool shortened = true) const; From e113118e1e3d29e78a834ab6cc3426c341f63394 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 10 May 2024 13:11:27 +0800 Subject: [PATCH 2/4] Use for : loop in getFolder Signed-off-by: Claudio Cambra --- src/gui/tray/usermodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 3121fc5f2bc3d..f217f6ac6fc9a 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -906,7 +906,7 @@ void User::setCurrentUser(const bool &isCurrent) Folder *User::getFolder() const { - foreach (Folder *folder, FolderMan::instance()->map()) { + for (Folder *const folder : FolderMan::instance()->map()) { if (folder->accountState() == _account.data()) { return folder; } From e2467baf0c40e5b4abb7ddcc3e2249457c5ec764 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 10 May 2024 13:13:38 +0800 Subject: [PATCH 3/4] Prevent double slashes in group folder path parsing Signed-off-by: Claudio Cambra --- src/gui/tray/usermodel.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index f217f6ac6fc9a..914517672a2a0 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -339,15 +339,22 @@ void User::parseNewGroupFolderPath(const QString &mountPoint) if (mountPoint.isEmpty()) { return; } - auto mountPointSplit = mountPoint.split(QLatin1Char('/'), Qt::SkipEmptyParts); + + auto sanitisedMountPoint = mountPoint; + sanitisedMountPoint.replace("//", "/"); + auto mountPointSplit = sanitisedMountPoint.split('/', Qt::SkipEmptyParts); if (mountPointSplit.isEmpty()) { return; } const auto groupFolderName = mountPointSplit.takeLast(); - const auto parentPath = mountPointSplit.join(QLatin1Char('/')); - _trayFolderInfos.push_back(QVariant::fromValue(TrayFolderInfo{groupFolderName, parentPath, mountPoint, TrayFolderInfo::GroupFolder})); + const auto parentPath = mountPointSplit.join('/'); + const auto folderInfo = TrayFolderInfo( + groupFolderName, parentPath, sanitisedMountPoint, TrayFolderInfo::GroupFolder + ); + const auto folderInfoVariant = QVariant::fromValue(folderInfo); + _trayFolderInfos.push_back(folderInfoVariant); } void User::prePendGroupFoldersWithLocalFolder() From 985d2d9a7a2071d4d62289d28b10cd7db628bac5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 16 Oct 2024 10:10:54 +0800 Subject: [PATCH 4/4] Take reference to folder in folder map within User::getFolder Signed-off-by: Claudio Cambra --- src/gui/tray/usermodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 914517672a2a0..98393f4ca9406 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -913,7 +913,7 @@ void User::setCurrentUser(const bool &isCurrent) Folder *User::getFolder() const { - for (Folder *const folder : FolderMan::instance()->map()) { + for (const auto &folder : FolderMan::instance()->map()) { if (folder->accountState() == _account.data()) { return folder; }