mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
UniversalEntry: add parent directory name before item name in the result
This commit is contained in:
parent
4b0152c606
commit
5d4b450fab
@ -1770,3 +1770,12 @@ QUrl VUtils::pathToUrl(const QString &p_path)
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
QString VUtils::parentDirName(const QString &p_path)
|
||||
{
|
||||
if (p_path.isEmpty()) {
|
||||
return p_path;
|
||||
}
|
||||
|
||||
return QFileInfo(p_path).dir().dirName();
|
||||
}
|
||||
|
@ -374,6 +374,10 @@ public:
|
||||
|
||||
static QUrl pathToUrl(const QString &p_path);
|
||||
|
||||
// Return the name of the parent directory of @p_path.
|
||||
// @p_path: file path of file or dir.
|
||||
static QString parentDirName(const QString &p_path);
|
||||
|
||||
// Regular expression for image link.
|
||||
// 
|
||||
// Captured texts (need to be trimmed):
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "vnotebook.h"
|
||||
#include "vuetitlecontentpanel.h"
|
||||
#include "vhistorylist.h"
|
||||
#include "vuniversalentry.h"
|
||||
|
||||
extern VMainWindow *g_mainWin;
|
||||
|
||||
@ -174,7 +175,11 @@ void VListUE::addResultItem(const QSharedPointer<VSearchResultItem> &p_item)
|
||||
if (p_item->m_text.isEmpty()) {
|
||||
first = p_item->m_path;
|
||||
} else {
|
||||
first = p_item->m_text;
|
||||
if (p_item->m_type != VSearchResultItem::Notebook) {
|
||||
first = VUniversalEntry::fileNameWithDir(p_item->m_text, p_item->m_path);
|
||||
} else {
|
||||
first = p_item->m_text;
|
||||
}
|
||||
second = p_item->m_path;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "vdirectorytree.h"
|
||||
#include "veditarea.h"
|
||||
#include "vexplorer.h"
|
||||
#include "vuniversalentry.h"
|
||||
|
||||
extern VNote *g_vnote;
|
||||
|
||||
@ -742,7 +743,11 @@ void VSearchUE::appendItemToList(const QSharedPointer<VSearchResultItem> &p_item
|
||||
if (p_item->m_text.isEmpty()) {
|
||||
first = p_item->m_path;
|
||||
} else {
|
||||
first = p_item->m_text;
|
||||
if (p_item->m_type != VSearchResultItem::Notebook) {
|
||||
first = VUniversalEntry::fileNameWithDir(p_item->m_text, p_item->m_path);
|
||||
} else {
|
||||
first = p_item->m_text;
|
||||
}
|
||||
second = p_item->m_path;
|
||||
}
|
||||
|
||||
@ -782,7 +787,15 @@ void VSearchUE::appendItemToTree(const QSharedPointer<VSearchResultItem> &p_item
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(m_treeWidget);
|
||||
item->setData(0, Qt::UserRole, m_data.size() - 1);
|
||||
item->setText(0, p_item->m_text.isEmpty() ? p_item->m_path : p_item->m_text);
|
||||
QString text;
|
||||
if (p_item->m_text.isEmpty()) {
|
||||
text = p_item->m_path;
|
||||
} else if (p_item->m_type != VSearchResultItem::Notebook) {
|
||||
text = VUniversalEntry::fileNameWithDir(p_item->m_text, p_item->m_path);
|
||||
} else {
|
||||
text = p_item->m_text;
|
||||
}
|
||||
item->setText(0, text);
|
||||
item->setToolTip(0, p_item->m_path);
|
||||
|
||||
switch (p_item->m_type) {
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <QAtomicInt>
|
||||
|
||||
#include "vmetawordlineedit.h"
|
||||
#include "utils/vutils.h"
|
||||
#include "vlistwidget.h"
|
||||
#include "vpalette.h"
|
||||
#include "vlistfolderue.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <QAtomicInt>
|
||||
|
||||
#include "iuniversalentry.h"
|
||||
#include "utils/vutils.h"
|
||||
|
||||
class VMetaWordLineEdit;
|
||||
class QVBoxLayout;
|
||||
@ -53,6 +54,8 @@ public:
|
||||
// @p_id to distinguish.
|
||||
void registerEntry(QChar p_key, IUniversalEntry *p_entry, int p_id = 0);
|
||||
|
||||
static QString fileNameWithDir(const QString &p_name, const QString &p_path);
|
||||
|
||||
signals:
|
||||
// Exit Universal Entry.
|
||||
void exited();
|
||||
@ -125,4 +128,8 @@ private:
|
||||
bool m_pendingCommand;
|
||||
};
|
||||
|
||||
inline QString VUniversalEntry::fileNameWithDir(const QString &p_name, const QString &p_path)
|
||||
{
|
||||
return VUtils::parentDirName(p_path) + " / " + p_name;
|
||||
}
|
||||
#endif // VUNIVERSALENTRY_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user