mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +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;
|
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);
|
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.
|
// Regular expression for image link.
|
||||||
// 
|
// 
|
||||||
// Captured texts (need to be trimmed):
|
// Captured texts (need to be trimmed):
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "vnotebook.h"
|
#include "vnotebook.h"
|
||||||
#include "vuetitlecontentpanel.h"
|
#include "vuetitlecontentpanel.h"
|
||||||
#include "vhistorylist.h"
|
#include "vhistorylist.h"
|
||||||
|
#include "vuniversalentry.h"
|
||||||
|
|
||||||
extern VMainWindow *g_mainWin;
|
extern VMainWindow *g_mainWin;
|
||||||
|
|
||||||
@ -173,8 +174,12 @@ void VListUE::addResultItem(const QSharedPointer<VSearchResultItem> &p_item)
|
|||||||
QString first, second;
|
QString first, second;
|
||||||
if (p_item->m_text.isEmpty()) {
|
if (p_item->m_text.isEmpty()) {
|
||||||
first = p_item->m_path;
|
first = p_item->m_path;
|
||||||
|
} else {
|
||||||
|
if (p_item->m_type != VSearchResultItem::Notebook) {
|
||||||
|
first = VUniversalEntry::fileNameWithDir(p_item->m_text, p_item->m_path);
|
||||||
} else {
|
} else {
|
||||||
first = p_item->m_text;
|
first = p_item->m_text;
|
||||||
|
}
|
||||||
second = p_item->m_path;
|
second = p_item->m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "vdirectorytree.h"
|
#include "vdirectorytree.h"
|
||||||
#include "veditarea.h"
|
#include "veditarea.h"
|
||||||
#include "vexplorer.h"
|
#include "vexplorer.h"
|
||||||
|
#include "vuniversalentry.h"
|
||||||
|
|
||||||
extern VNote *g_vnote;
|
extern VNote *g_vnote;
|
||||||
|
|
||||||
@ -741,8 +742,12 @@ void VSearchUE::appendItemToList(const QSharedPointer<VSearchResultItem> &p_item
|
|||||||
QString first, second;
|
QString first, second;
|
||||||
if (p_item->m_text.isEmpty()) {
|
if (p_item->m_text.isEmpty()) {
|
||||||
first = p_item->m_path;
|
first = p_item->m_path;
|
||||||
|
} else {
|
||||||
|
if (p_item->m_type != VSearchResultItem::Notebook) {
|
||||||
|
first = VUniversalEntry::fileNameWithDir(p_item->m_text, p_item->m_path);
|
||||||
} else {
|
} else {
|
||||||
first = p_item->m_text;
|
first = p_item->m_text;
|
||||||
|
}
|
||||||
second = p_item->m_path;
|
second = p_item->m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -782,7 +787,15 @@ void VSearchUE::appendItemToTree(const QSharedPointer<VSearchResultItem> &p_item
|
|||||||
|
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(m_treeWidget);
|
QTreeWidgetItem *item = new QTreeWidgetItem(m_treeWidget);
|
||||||
item->setData(0, Qt::UserRole, m_data.size() - 1);
|
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);
|
item->setToolTip(0, p_item->m_path);
|
||||||
|
|
||||||
switch (p_item->m_type) {
|
switch (p_item->m_type) {
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include <QAtomicInt>
|
#include <QAtomicInt>
|
||||||
|
|
||||||
#include "vmetawordlineedit.h"
|
#include "vmetawordlineedit.h"
|
||||||
#include "utils/vutils.h"
|
|
||||||
#include "vlistwidget.h"
|
#include "vlistwidget.h"
|
||||||
#include "vpalette.h"
|
#include "vpalette.h"
|
||||||
#include "vlistfolderue.h"
|
#include "vlistfolderue.h"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <QAtomicInt>
|
#include <QAtomicInt>
|
||||||
|
|
||||||
#include "iuniversalentry.h"
|
#include "iuniversalentry.h"
|
||||||
|
#include "utils/vutils.h"
|
||||||
|
|
||||||
class VMetaWordLineEdit;
|
class VMetaWordLineEdit;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
@ -53,6 +54,8 @@ public:
|
|||||||
// @p_id to distinguish.
|
// @p_id to distinguish.
|
||||||
void registerEntry(QChar p_key, IUniversalEntry *p_entry, int p_id = 0);
|
void registerEntry(QChar p_key, IUniversalEntry *p_entry, int p_id = 0);
|
||||||
|
|
||||||
|
static QString fileNameWithDir(const QString &p_name, const QString &p_path);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Exit Universal Entry.
|
// Exit Universal Entry.
|
||||||
void exited();
|
void exited();
|
||||||
@ -125,4 +128,8 @@ private:
|
|||||||
bool m_pendingCommand;
|
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
|
#endif // VUNIVERSALENTRY_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user