Skip to content

Commit 4c8a43d

Browse files
VxUrlUtils: correct the behavior of 'getFilePath..' functions (#2638)
1.Now, QWidgetAction in 'ToolBarHelper::updateQuickAccessMenu' functions properly with 'setToolTip(displayFullName);' 2.Skips vx.json files in the recycle bin directory when searching for signature." Co-authored-by: schips <schips@dingtalk.com>
1 parent 6fd3703 commit 4c8a43d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/utils/vxurlutils.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <core/exception.h>
99
#include <core/global.h>
10+
#include <core/vnotex.h>
11+
#include <core/notebookmgr.h>
1012

1113
#include "pathutils.h"
1214
#include <QJsonArray>
@@ -43,13 +45,18 @@ QString VxUrlUtils::getFilePathFromVxURL(const QString &p_vxUrl) {
4345
int colonPos = p_vxUrl.indexOf(':');
4446
if (colonPos != -1) {
4547
filePath = p_vxUrl.mid(colonPos + 1);
46-
filePath = PathUtils::fileName(filePath); // get 'filePath'
4748
return filePath;
4849
}
4950
} // if not 'filePath', return original 'vxUrl'
5051
return p_vxUrl;
5152
}
5253

54+
QString VxUrlUtils::getFileNameFromVxURL(const QString &p_vxUrl) {
55+
QString filePath = VxUrlUtils::getFilePathFromVxURL(p_vxUrl);
56+
57+
return PathUtils::fileName(filePath);
58+
}
59+
5360
QString VxUrlUtils::getSignatureFromFilePath(const QString &p_filePath)
5461
{
5562
QFileInfo fileInfo(p_filePath);
@@ -107,8 +114,17 @@ QString VxUrlUtils::getFilePathFromSignature(const QString &p_startPath, const Q
107114
// Find the file with the specified signature in all vx.json files under the specified directory
108115
QDirIterator it(p_startPath, {"vx.json"}, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
109116

117+
const QString rootPath = VNoteX::getInst().getNotebookMgr().getCurrentNotebook()->getRootFolderAbsolutePath();
118+
const QString recycleBinPath = PathUtils::concatenateFilePath(rootPath, "vx_recycle_bin");
119+
110120
while (it.hasNext()) {
111121
const QString vxPath = it.next();
122+
123+
// skip vx.json in recycle bin
124+
if (vxPath.endsWith("vx_recycle_bin/vx.json") || vxPath.startsWith(recycleBinPath)) {
125+
continue;
126+
}
127+
112128
QFile vxFile(vxPath);
113129
if (!vxFile.open(QIODevice::ReadOnly)) {
114130
continue;

src/utils/vxurlutils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ namespace vnotex
2121
// Get signature from vxUrl.
2222
static QString getSignatureFromVxURL(const QString &p_vxUrl);
2323

24+
// Get file name from vxUrl.
25+
static QString getFileNameFromVxURL(const QString &p_vxUrl);
26+
2427
// Get file path from vxUrl.
2528
static QString getFilePathFromVxURL(const QString &p_vxUrl);
2629

0 commit comments

Comments
 (0)