From c03bc8540c3554bbff92fb10c95c5d3bd117d6a7 Mon Sep 17 00:00:00 2001 From: Michael Schuster Date: Sun, 22 Dec 2019 06:16:27 +0100 Subject: [PATCH] Fix folder opening in ActivityListModel After fixing the crash in the previous commit, double-clicking on Activity list rows still didn't work. This fix partly reverts commit 8546d53b05a76271e245f085d1caa5d405dadb8d in ActivityItemDelegate::PathRole of ActivityListModel::data, but adds a new check for relPath's existence in line 74. I'm assuming the previous change there has been done to shorten the code and avoid opening the user's home folder upon clicking entries which file value is "App Password". The new path-check takes care of that too now. Signed-off-by: Michael Schuster --- src/gui/activitylistmodel.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/activitylistmodel.cpp b/src/gui/activitylistmodel.cpp index 59598c71b..eeb0cc836 100644 --- a/src/gui/activitylistmodel.cpp +++ b/src/gui/activitylistmodel.cpp @@ -64,12 +64,19 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const case ActivityItemDelegate::PathRole: if(!a._file.isEmpty()){ auto folder = FolderMan::instance()->folder(a._folder); - if(!folder) - return QVariant(); - list = FolderMan::instance()->findFileInLocalFolders(folder->remotePath(), ast->account()); + QString relPath(a._file); + if(folder) relPath.prepend(folder->remotePath()); + list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account()); if (list.count() > 0) { return QVariant(list.at(0)); } + // File does not exist anymore? Let's try to open its path + if(QFileInfo(relPath).exists()) { + list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(relPath).path(), ast->account()); + if (list.count() > 0) { + return QVariant(list.at(0)); + } + } } return QVariant(); case ActivityItemDelegate::ActionsLinksRole:{