mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
UniversalEntry: add y to list and search outline of current note
This commit is contained in:
parent
9289a634b5
commit
7de9eab039
@ -39,7 +39,17 @@ public:
|
|||||||
virtual void clear(int p_id) = 0;
|
virtual void clear(int p_id) = 0;
|
||||||
|
|
||||||
// UE is hidden by the user.
|
// UE is hidden by the user.
|
||||||
virtual void entryHidden(int p_id) = 0;
|
virtual void entryHidden(int p_id)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UE is shown by the user.
|
||||||
|
virtual void entryShown(int p_id, const QString &p_cmd)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
Q_UNUSED(p_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
// Select next item.
|
// Select next item.
|
||||||
virtual void selectNextItem(int p_id, bool p_forward) = 0;
|
virtual void selectNextItem(int p_id, bool p_forward) = 0;
|
||||||
|
@ -121,7 +121,8 @@ SOURCES += main.cpp\
|
|||||||
vuniversalentry.cpp \
|
vuniversalentry.cpp \
|
||||||
vlistwidgetdoublerows.cpp \
|
vlistwidgetdoublerows.cpp \
|
||||||
vdoublerowitemwidget.cpp \
|
vdoublerowitemwidget.cpp \
|
||||||
vsearchue.cpp
|
vsearchue.cpp \
|
||||||
|
voutlineue.cpp
|
||||||
|
|
||||||
HEADERS += vmainwindow.h \
|
HEADERS += vmainwindow.h \
|
||||||
vdirectorytree.h \
|
vdirectorytree.h \
|
||||||
@ -233,7 +234,8 @@ HEADERS += vmainwindow.h \
|
|||||||
iuniversalentry.h \
|
iuniversalentry.h \
|
||||||
vlistwidgetdoublerows.h \
|
vlistwidgetdoublerows.h \
|
||||||
vdoublerowitemwidget.h \
|
vdoublerowitemwidget.h \
|
||||||
vsearchue.h
|
vsearchue.h \
|
||||||
|
voutlineue.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
vnote.qrc \
|
vnote.qrc \
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "vsearcher.h"
|
#include "vsearcher.h"
|
||||||
#include "vuniversalentry.h"
|
#include "vuniversalentry.h"
|
||||||
#include "vsearchue.h"
|
#include "vsearchue.h"
|
||||||
|
#include "voutlineue.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
@ -3209,6 +3210,7 @@ void VMainWindow::initUniversalEntry()
|
|||||||
m_ue->registerEntry('t', searchUE, VSearchUE::Name_Note_Buffer);
|
m_ue->registerEntry('t', searchUE, VSearchUE::Name_Note_Buffer);
|
||||||
m_ue->registerEntry('g', searchUE, VSearchUE::Content_Note_Buffer);
|
m_ue->registerEntry('g', searchUE, VSearchUE::Content_Note_Buffer);
|
||||||
m_ue->registerEntry('b', searchUE, VSearchUE::Outline_Note_Buffer);
|
m_ue->registerEntry('b', searchUE, VSearchUE::Outline_Note_Buffer);
|
||||||
|
m_ue->registerEntry('y', new VOutlineUE(this), 0);
|
||||||
m_ue->registerEntry('h', searchUE, VSearchUE::Path_FolderNote_AllNotebook);
|
m_ue->registerEntry('h', searchUE, VSearchUE::Path_FolderNote_AllNotebook);
|
||||||
m_ue->registerEntry('n', searchUE, VSearchUE::Path_FolderNote_CurrentNotebook);
|
m_ue->registerEntry('n', searchUE, VSearchUE::Path_FolderNote_CurrentNotebook);
|
||||||
}
|
}
|
||||||
|
@ -35,48 +35,50 @@ void VOutline::updateOutline(const VTableOfContent &p_outline)
|
|||||||
|
|
||||||
m_outline = p_outline;
|
m_outline = p_outline;
|
||||||
|
|
||||||
updateTreeFromOutline();
|
updateTreeFromOutline(this, m_outline);
|
||||||
|
|
||||||
expandTree();
|
expandTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VOutline::updateTreeFromOutline()
|
void VOutline::updateTreeFromOutline(QTreeWidget *p_treeWidget,
|
||||||
|
const VTableOfContent &p_outline)
|
||||||
{
|
{
|
||||||
clear();
|
p_treeWidget->clear();
|
||||||
|
|
||||||
if (m_outline.isEmpty()) {
|
if (p_outline.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<VTableOfContentItem> &headers = m_outline.getTable();
|
const QVector<VTableOfContentItem> &headers = p_outline.getTable();
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
updateTreeByLevel(headers, idx, NULL, NULL, 1);
|
updateTreeByLevel(p_treeWidget, headers, idx, NULL, NULL, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VOutline::updateTreeByLevel(const QVector<VTableOfContentItem> &headers,
|
void VOutline::updateTreeByLevel(QTreeWidget *p_treeWidget,
|
||||||
int &index,
|
const QVector<VTableOfContentItem> &p_headers,
|
||||||
QTreeWidgetItem *parent,
|
int &p_index,
|
||||||
QTreeWidgetItem *last,
|
QTreeWidgetItem *p_parent,
|
||||||
int level)
|
QTreeWidgetItem *p_last,
|
||||||
|
int p_level)
|
||||||
{
|
{
|
||||||
while (index < headers.size()) {
|
while (p_index < p_headers.size()) {
|
||||||
const VTableOfContentItem &header = headers[index];
|
const VTableOfContentItem &header = p_headers[p_index];
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
if (header.m_level == level) {
|
if (header.m_level == p_level) {
|
||||||
if (parent) {
|
if (p_parent) {
|
||||||
item = new QTreeWidgetItem(parent);
|
item = new QTreeWidgetItem(p_parent);
|
||||||
} else {
|
} else {
|
||||||
item = new QTreeWidgetItem(this);
|
item = new QTreeWidgetItem(p_treeWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
fillItem(item, header);
|
fillItem(item, header);
|
||||||
|
|
||||||
last = item;
|
p_last = item;
|
||||||
++index;
|
++p_index;
|
||||||
} else if (header.m_level < level) {
|
} else if (header.m_level < p_level) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
updateTreeByLevel(headers, index, last, NULL, level + 1);
|
updateTreeByLevel(p_treeWidget, p_headers, p_index, p_last, NULL, p_level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +112,7 @@ void VOutline::handleCurrentItemChanged(QTreeWidgetItem *p_curItem,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VTableOfContentItem *header = getHeaderFromItem(p_curItem);
|
const VTableOfContentItem *header = getHeaderFromItem(p_curItem, m_outline);
|
||||||
Q_ASSERT(header);
|
Q_ASSERT(header);
|
||||||
m_currentHeader.update(m_outline.getFile(), header->m_index);
|
m_currentHeader.update(m_outline.getFile(), header->m_index);
|
||||||
|
|
||||||
@ -129,45 +131,50 @@ void VOutline::updateCurrentHeader(const VHeaderPointer &p_header)
|
|||||||
// Item change should not emit the signal.
|
// Item change should not emit the signal.
|
||||||
m_muted = true;
|
m_muted = true;
|
||||||
m_currentHeader = p_header;
|
m_currentHeader = p_header;
|
||||||
selectHeader(m_currentHeader);
|
selectHeader(this, m_outline, m_currentHeader);
|
||||||
m_muted = false;
|
m_muted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VOutline::selectHeader(const VHeaderPointer &p_header)
|
void VOutline::selectHeader(QTreeWidget *p_treeWidget,
|
||||||
|
const VTableOfContent &p_outline,
|
||||||
|
const VHeaderPointer &p_header)
|
||||||
{
|
{
|
||||||
setCurrentItem(NULL);
|
p_treeWidget->setCurrentItem(NULL);
|
||||||
|
|
||||||
if (!m_outline.getItem(p_header)) {
|
if (!p_outline.getItem(p_header)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nrTop = topLevelItemCount();
|
int nrTop = p_treeWidget->topLevelItemCount();
|
||||||
for (int i = 0; i < nrTop; ++i) {
|
for (int i = 0; i < nrTop; ++i) {
|
||||||
if (selectHeaderOne(topLevelItem(i), p_header)) {
|
if (selectHeaderOne(p_treeWidget, p_treeWidget->topLevelItem(i), p_outline, p_header)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VOutline::selectHeaderOne(QTreeWidgetItem *p_item, const VHeaderPointer &p_header)
|
bool VOutline::selectHeaderOne(QTreeWidget *p_treeWidget,
|
||||||
|
QTreeWidgetItem *p_item,
|
||||||
|
const VTableOfContent &p_outline,
|
||||||
|
const VHeaderPointer &p_header)
|
||||||
{
|
{
|
||||||
if (!p_item) {
|
if (!p_item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VTableOfContentItem *header = getHeaderFromItem(p_item);
|
const VTableOfContentItem *header = getHeaderFromItem(p_item, p_outline);
|
||||||
if (!header) {
|
if (!header) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header->isMatched(p_header)) {
|
if (header->isMatched(p_header)) {
|
||||||
setCurrentItem(p_item);
|
p_treeWidget->setCurrentItem(p_item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nrChild = p_item->childCount();
|
int nrChild = p_item->childCount();
|
||||||
for (int i = 0; i < nrChild; ++i) {
|
for (int i = 0; i < nrChild; ++i) {
|
||||||
if (selectHeaderOne(p_item->child(i), p_header)) {
|
if (selectHeaderOne(p_treeWidget, p_item->child(i), p_outline, p_header)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,8 +242,9 @@ bool VOutline::handleKeyNavigation(int p_key, bool &p_succeed)
|
|||||||
p_succeed);
|
p_succeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
const VTableOfContentItem *VOutline::getHeaderFromItem(QTreeWidgetItem *p_item) const
|
const VTableOfContentItem *VOutline::getHeaderFromItem(QTreeWidgetItem *p_item,
|
||||||
|
const VTableOfContent &p_outline)
|
||||||
{
|
{
|
||||||
int index = p_item->data(0, Qt::UserRole).toInt();
|
int index = p_item->data(0, Qt::UserRole).toInt();
|
||||||
return m_outline.getItem(index);
|
return p_outline.getItem(index);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,18 @@ public:
|
|||||||
void showNavigation() Q_DECL_OVERRIDE;
|
void showNavigation() Q_DECL_OVERRIDE;
|
||||||
bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
|
bool handleKeyNavigation(int p_key, bool &p_succeed) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
// Update tree according to outline.
|
||||||
|
static void updateTreeFromOutline(QTreeWidget *p_treeWidget, const VTableOfContent &p_outline);
|
||||||
|
|
||||||
|
// Set the item corresponding to @p_header as current item.
|
||||||
|
static void selectHeader(QTreeWidget *p_treeWidget,
|
||||||
|
const VTableOfContent &p_outline,
|
||||||
|
const VHeaderPointer &p_header);
|
||||||
|
|
||||||
|
// Return NULL if no corresponding header in outline.
|
||||||
|
static const VTableOfContentItem *getHeaderFromItem(QTreeWidgetItem *p_item,
|
||||||
|
const VTableOfContent &p_outline);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Emit when current item changed by user and header of that item is not empty.
|
// Emit when current item changed by user and header of that item is not empty.
|
||||||
// Do not worry about infinite recursion.
|
// Do not worry about infinite recursion.
|
||||||
@ -46,28 +58,23 @@ private slots:
|
|||||||
void handleCurrentItemChanged(QTreeWidgetItem *p_curItem, QTreeWidgetItem *p_preItem);
|
void handleCurrentItemChanged(QTreeWidgetItem *p_curItem, QTreeWidgetItem *p_preItem);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Update tree according to outline.
|
|
||||||
void updateTreeFromOutline();
|
|
||||||
|
|
||||||
// @index: the index in @headers.
|
// @index: the index in @headers.
|
||||||
void updateTreeByLevel(const QVector<VTableOfContentItem> &headers,
|
static void updateTreeByLevel(QTreeWidget *p_treeWidget,
|
||||||
int &index,
|
const QVector<VTableOfContentItem> &p_headers,
|
||||||
QTreeWidgetItem *parent,
|
int &p_index,
|
||||||
QTreeWidgetItem *last,
|
QTreeWidgetItem *p_parent,
|
||||||
int level);
|
QTreeWidgetItem *p_last,
|
||||||
|
int p_level);
|
||||||
|
|
||||||
|
// Fill the info of @p_item.
|
||||||
|
static void fillItem(QTreeWidgetItem *p_item, const VTableOfContentItem &p_header);
|
||||||
|
|
||||||
void expandTree();
|
void expandTree();
|
||||||
|
|
||||||
// Set the item corresponding to @p_header as current item.
|
static bool selectHeaderOne(QTreeWidget *p_treeWidget,
|
||||||
void selectHeader(const VHeaderPointer &p_header);
|
QTreeWidgetItem *p_item,
|
||||||
|
const VTableOfContent &p_outline,
|
||||||
bool selectHeaderOne(QTreeWidgetItem *p_item, const VHeaderPointer &p_header);
|
const VHeaderPointer &p_header);
|
||||||
|
|
||||||
// Fill the info of @p_item.
|
|
||||||
void fillItem(QTreeWidgetItem *p_item, const VTableOfContentItem &p_header);
|
|
||||||
|
|
||||||
// Return NULL if no corresponding header in outline.
|
|
||||||
const VTableOfContentItem *getHeaderFromItem(QTreeWidgetItem *p_item) const;
|
|
||||||
|
|
||||||
VTableOfContent m_outline;
|
VTableOfContent m_outline;
|
||||||
|
|
||||||
|
234
src/voutlineue.cpp
Normal file
234
src/voutlineue.cpp
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
#include "voutlineue.h"
|
||||||
|
|
||||||
|
#include <QTreeWidgetItem>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
|
#include "vtreewidget.h"
|
||||||
|
#include "vlistwidget.h"
|
||||||
|
#include "voutline.h"
|
||||||
|
#include "vmainwindow.h"
|
||||||
|
#include "vedittab.h"
|
||||||
|
#include "veditarea.h"
|
||||||
|
#include "vsearchconfig.h"
|
||||||
|
#include "vtableofcontent.h"
|
||||||
|
|
||||||
|
extern VMainWindow *g_mainWin;
|
||||||
|
|
||||||
|
VOutlineUE::VOutlineUE(QObject *p_parent)
|
||||||
|
: IUniversalEntry(p_parent),
|
||||||
|
m_listWidget(NULL),
|
||||||
|
m_treeWidget(NULL),
|
||||||
|
m_listOutline(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString VOutlineUE::description(int p_id) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
|
||||||
|
return tr("List and search the outline of current note");
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::init()
|
||||||
|
{
|
||||||
|
if (m_initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT(m_widgetParent);
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
|
|
||||||
|
m_listWidget = new VListWidget(m_widgetParent);
|
||||||
|
m_listWidget->setFitContent(true);
|
||||||
|
m_listWidget->hide();
|
||||||
|
connect(m_listWidget, SIGNAL(itemActivated(QListWidgetItem *)),
|
||||||
|
this, SLOT(activateItem(QListWidgetItem *)));
|
||||||
|
|
||||||
|
m_treeWidget = new VTreeWidget(m_widgetParent);
|
||||||
|
m_treeWidget->setColumnCount(1);
|
||||||
|
m_treeWidget->setHeaderHidden(true);
|
||||||
|
m_treeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
m_treeWidget->setExpandsOnDoubleClick(false);
|
||||||
|
m_treeWidget->setFitContent(true);
|
||||||
|
m_treeWidget->hide();
|
||||||
|
|
||||||
|
connect(m_treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
|
||||||
|
this, SLOT(activateItem(QTreeWidgetItem *, int)));
|
||||||
|
connect(m_treeWidget, &VTreeWidget::itemExpanded,
|
||||||
|
this, &VOutlineUE::widgetUpdated);
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *VOutlineUE::widget(int p_id)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
init();
|
||||||
|
|
||||||
|
if (m_listOutline) {
|
||||||
|
return m_treeWidget;
|
||||||
|
} else {
|
||||||
|
return m_listWidget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::processCommand(int p_id, const QString &p_cmd)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
clear(-1);
|
||||||
|
|
||||||
|
emit stateUpdated(State::Busy);
|
||||||
|
|
||||||
|
VEditTab *tab = g_mainWin->getCurrentTab();
|
||||||
|
if (p_cmd.isEmpty()) {
|
||||||
|
// List the outline.
|
||||||
|
m_listOutline = true;
|
||||||
|
|
||||||
|
if (tab) {
|
||||||
|
const VTableOfContent &outline = tab->getOutline();
|
||||||
|
VOutline::updateTreeFromOutline(m_treeWidget, outline);
|
||||||
|
m_treeWidget->expandAll();
|
||||||
|
|
||||||
|
const VHeaderPointer &header = tab->getCurrentHeader();
|
||||||
|
if (outline.isMatched(header)) {
|
||||||
|
VOutline::selectHeader(m_treeWidget, outline, header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Search the outline.
|
||||||
|
m_listOutline = false;
|
||||||
|
|
||||||
|
VSearchConfig config(VSearchConfig::CurrentNote,
|
||||||
|
VSearchConfig::Content,
|
||||||
|
VSearchConfig::Note,
|
||||||
|
VSearchConfig::Internal,
|
||||||
|
VSearchConfig::NoneOption,
|
||||||
|
p_cmd,
|
||||||
|
QString());
|
||||||
|
|
||||||
|
if (tab) {
|
||||||
|
const VTableOfContent &outline = tab->getOutline();
|
||||||
|
const QVector<VTableOfContentItem> &table = outline.getTable();
|
||||||
|
for (auto const & it : table) {
|
||||||
|
if (it.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config.m_token.matched(it.m_name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add item to list.
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(it.m_name, m_listWidget);
|
||||||
|
item->setData(Qt::UserRole, it.m_index);
|
||||||
|
item->setToolTip(it.m_name);
|
||||||
|
|
||||||
|
if (!m_listWidget->currentItem()) {
|
||||||
|
m_listWidget->setCurrentItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit stateUpdated(State::Success);
|
||||||
|
updateWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::updateWidget()
|
||||||
|
{
|
||||||
|
QWidget *wid = m_listWidget;
|
||||||
|
if (m_listOutline) {
|
||||||
|
if (m_treeWidget->topLevelItemCount() > 0) {
|
||||||
|
m_treeWidget->resizeColumnToContents(0);
|
||||||
|
} else {
|
||||||
|
QTreeWidgetItem *item = new QTreeWidgetItem(m_treeWidget, QStringList("test"));
|
||||||
|
m_treeWidget->resizeColumnToContents(0);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
wid = m_listWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
wid->updateGeometry();
|
||||||
|
emit widgetUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::clear(int p_id)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
m_treeWidget->clearAll();
|
||||||
|
m_listWidget->clearAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::entryHidden(int p_id)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
clear(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::entryShown(int p_id, const QString &p_cmd)
|
||||||
|
{
|
||||||
|
processCommand(p_id, p_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::selectNextItem(int p_id, bool p_forward)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
|
||||||
|
if (m_listOutline) {
|
||||||
|
m_treeWidget->selectNextItem(p_forward);
|
||||||
|
} else {
|
||||||
|
m_listWidget->selectNextItem(p_forward);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::activate(int p_id)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
if (m_listOutline) {
|
||||||
|
activateItem(m_treeWidget->currentItem(), 0);
|
||||||
|
} else {
|
||||||
|
activateItem(m_listWidget->currentItem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::askToStop(int p_id)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::activateItem(QListWidgetItem *p_item)
|
||||||
|
{
|
||||||
|
if (!p_item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int idx = p_item->data(Qt::UserRole).toInt();
|
||||||
|
|
||||||
|
emit requestHideUniversalEntry();
|
||||||
|
|
||||||
|
VHeaderPointer hp(g_mainWin->getCurrentFile(), idx);
|
||||||
|
g_mainWin->getEditArea()->scrollToHeader(hp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOutlineUE::activateItem(QTreeWidgetItem *p_item, int p_col)
|
||||||
|
{
|
||||||
|
Q_UNUSED(p_col);
|
||||||
|
if (!p_item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VEditTab *tab = g_mainWin->getCurrentTab();
|
||||||
|
Q_ASSERT(tab);
|
||||||
|
const VTableOfContent &outline = tab->getOutline();
|
||||||
|
const VTableOfContentItem *header = VOutline::getHeaderFromItem(p_item, outline);
|
||||||
|
Q_ASSERT(header);
|
||||||
|
if (!header->isEmpty()) {
|
||||||
|
emit requestHideUniversalEntry();
|
||||||
|
|
||||||
|
VHeaderPointer hp(outline.getFile(), header->m_index);
|
||||||
|
g_mainWin->getEditArea()->scrollToHeader(hp);
|
||||||
|
}
|
||||||
|
}
|
54
src/voutlineue.h
Normal file
54
src/voutlineue.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#ifndef VOUTLINEUE_H
|
||||||
|
#define VOUTLINEUE_H
|
||||||
|
|
||||||
|
#include "iuniversalentry.h"
|
||||||
|
|
||||||
|
class VListWidget;
|
||||||
|
class QListWidgetItem;
|
||||||
|
class VTreeWidget;
|
||||||
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
|
// Universal Entry to list and search outline of current note.
|
||||||
|
class VOutlineUE : public IUniversalEntry
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit VOutlineUE(QObject *p_parent = nullptr);
|
||||||
|
|
||||||
|
QString description(int p_id) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
QWidget *widget(int p_id) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void processCommand(int p_id, const QString &p_cmd) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void clear(int p_id) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void entryHidden(int p_id) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void entryShown(int p_id, const QString &p_cmd) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void selectNextItem(int p_id, bool p_forward) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void activate(int p_id) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void askToStop(int p_id) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void init() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void activateItem(QListWidgetItem *p_item);
|
||||||
|
|
||||||
|
void activateItem(QTreeWidgetItem *p_item, int p_col);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateWidget();
|
||||||
|
|
||||||
|
VListWidget *m_listWidget;
|
||||||
|
|
||||||
|
VTreeWidget *m_treeWidget;
|
||||||
|
|
||||||
|
bool m_listOutline;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VOUTLINEUE_H
|
@ -25,7 +25,8 @@ QSharedPointer<VSearchResult> VSearch::search(const QVector<VFile *> &p_files)
|
|||||||
|
|
||||||
QSharedPointer<VSearchResult> result(new VSearchResult(this));
|
QSharedPointer<VSearchResult> result(new VSearchResult(this));
|
||||||
|
|
||||||
if (p_files.isEmpty()) {
|
if (p_files.isEmpty() || m_config->isEmpty()) {
|
||||||
|
result->m_state = VSearchState::Success;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +65,8 @@ QSharedPointer<VSearchResult> VSearch::search(VDirectory *p_directory)
|
|||||||
|
|
||||||
QSharedPointer<VSearchResult> result(new VSearchResult(this));
|
QSharedPointer<VSearchResult> result(new VSearchResult(this));
|
||||||
|
|
||||||
if (!p_directory) {
|
if (!p_directory || m_config->isEmpty()) {
|
||||||
|
result->m_state = VSearchState::Success;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +97,8 @@ QSharedPointer<VSearchResult> VSearch::search(const QVector<VNotebook *> &p_note
|
|||||||
|
|
||||||
QSharedPointer<VSearchResult> result(new VSearchResult(this));
|
QSharedPointer<VSearchResult> result(new VSearchResult(this));
|
||||||
|
|
||||||
if (p_notebooks.isEmpty()) {
|
if (p_notebooks.isEmpty() || m_config->isEmpty()) {
|
||||||
|
result->m_state = VSearchState::Success;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,6 +319,10 @@ struct VSearchConfig
|
|||||||
args.removeAt(i);
|
args.removeAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_token.m_caseSensitivity = cs;
|
m_token.m_caseSensitivity = cs;
|
||||||
m_contentToken.m_caseSensitivity = cs;
|
m_contentToken.m_caseSensitivity = cs;
|
||||||
|
|
||||||
@ -380,6 +384,11 @@ struct VSearchConfig
|
|||||||
m_contentToken.m_op = op;
|
m_contentToken.m_op = op;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isEmpty() const
|
||||||
|
{
|
||||||
|
return m_token.tokenSize() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList toConfig() const
|
QStringList toConfig() const
|
||||||
{
|
{
|
||||||
QStringList str;
|
QStringList str;
|
||||||
|
@ -58,7 +58,7 @@ QString VSearchUE::description(int p_id) const
|
|||||||
return tr("Search the content of notes in current folder");
|
return tr("Search the content of notes in current folder");
|
||||||
|
|
||||||
case ID::Name_Note_Buffer:
|
case ID::Name_Note_Buffer:
|
||||||
return tr("List and search buffer (opened notes)");
|
return tr("List and search the name of opened notes in buffer");
|
||||||
|
|
||||||
case ID::Content_Note_Buffer:
|
case ID::Content_Note_Buffer:
|
||||||
return tr("Search the content of opened notes in buffer");
|
return tr("Search the content of opened notes in buffer");
|
||||||
@ -110,7 +110,6 @@ void VSearchUE::init()
|
|||||||
m_treeWidget->setColumnCount(1);
|
m_treeWidget->setColumnCount(1);
|
||||||
m_treeWidget->setHeaderHidden(true);
|
m_treeWidget->setHeaderHidden(true);
|
||||||
m_treeWidget->setExpandsOnDoubleClick(false);
|
m_treeWidget->setExpandsOnDoubleClick(false);
|
||||||
m_treeWidget->setSimpleSearchMatchFlags(m_treeWidget->getSimpleSearchMatchFlags() & ~Qt::MatchRecursive);
|
|
||||||
m_treeWidget->setFitContent(true);
|
m_treeWidget->setFitContent(true);
|
||||||
m_treeWidget->hide();
|
m_treeWidget->hide();
|
||||||
connect(m_treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
|
connect(m_treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
|
||||||
@ -249,12 +248,11 @@ void VSearchUE::searchNameOfAllNotebooks(const QString &p_cmd)
|
|||||||
} else {
|
} else {
|
||||||
// Do a fuzzy search against the name of the notebooks.
|
// Do a fuzzy search against the name of the notebooks.
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::Fuzzy;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::AllNotebooks,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::AllNotebooks,
|
||||||
VSearchConfig::Name,
|
VSearchConfig::Name,
|
||||||
VSearchConfig::Notebook,
|
VSearchConfig::Notebook,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::Fuzzy,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -271,12 +269,11 @@ void VSearchUE::searchNameOfFolderNoteInAllNotebooks(const QString &p_cmd)
|
|||||||
emit stateUpdated(State::Success);
|
emit stateUpdated(State::Success);
|
||||||
} else {
|
} else {
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::AllNotebooks,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::AllNotebooks,
|
||||||
VSearchConfig::Name,
|
VSearchConfig::Name,
|
||||||
VSearchConfig::Folder | VSearchConfig::Note,
|
VSearchConfig::Folder | VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -292,12 +289,11 @@ void VSearchUE::searchContentOfNoteInAllNotebooks(const QString &p_cmd)
|
|||||||
emit stateUpdated(State::Success);
|
emit stateUpdated(State::Success);
|
||||||
} else {
|
} else {
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::AllNotebooks,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::AllNotebooks,
|
||||||
VSearchConfig::Content,
|
VSearchConfig::Content,
|
||||||
VSearchConfig::Note,
|
VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -315,12 +311,11 @@ void VSearchUE::searchNameOfFolderNoteInCurrentNotebook(const QString &p_cmd)
|
|||||||
QVector<VNotebook *> notebooks;
|
QVector<VNotebook *> notebooks;
|
||||||
notebooks.append(g_mainWin->getNotebookSelector()->currentNotebook());
|
notebooks.append(g_mainWin->getNotebookSelector()->currentNotebook());
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentNotebook,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentNotebook,
|
||||||
VSearchConfig::Name,
|
VSearchConfig::Name,
|
||||||
VSearchConfig::Folder | VSearchConfig::Note,
|
VSearchConfig::Folder | VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -338,12 +333,11 @@ void VSearchUE::searchContentOfNoteInCurrentNotebook(const QString &p_cmd)
|
|||||||
QVector<VNotebook *> notebooks;
|
QVector<VNotebook *> notebooks;
|
||||||
notebooks.append(g_mainWin->getNotebookSelector()->currentNotebook());
|
notebooks.append(g_mainWin->getNotebookSelector()->currentNotebook());
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentNotebook,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentNotebook,
|
||||||
VSearchConfig::Content,
|
VSearchConfig::Content,
|
||||||
VSearchConfig::Note,
|
VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -360,12 +354,11 @@ void VSearchUE::searchNameOfFolderNoteInCurrentFolder(const QString &p_cmd)
|
|||||||
} else {
|
} else {
|
||||||
VDirectory *dir = g_mainWin->getDirectoryTree()->currentDirectory();
|
VDirectory *dir = g_mainWin->getDirectoryTree()->currentDirectory();
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentFolder,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentFolder,
|
||||||
VSearchConfig::Name,
|
VSearchConfig::Name,
|
||||||
VSearchConfig::Folder | VSearchConfig::Note,
|
VSearchConfig::Folder | VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -382,12 +375,11 @@ void VSearchUE::searchContentOfNoteInCurrentFolder(const QString &p_cmd)
|
|||||||
} else {
|
} else {
|
||||||
VDirectory *dir = g_mainWin->getDirectoryTree()->currentDirectory();
|
VDirectory *dir = g_mainWin->getDirectoryTree()->currentDirectory();
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentFolder,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentFolder,
|
||||||
VSearchConfig::Content,
|
VSearchConfig::Content,
|
||||||
VSearchConfig::Note,
|
VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -425,12 +417,11 @@ void VSearchUE::searchNameOfBuffer(const QString &p_cmd)
|
|||||||
emit stateUpdated(State::Success);
|
emit stateUpdated(State::Success);
|
||||||
} else {
|
} else {
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::OpenedNotes,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::OpenedNotes,
|
||||||
VSearchConfig::Name,
|
VSearchConfig::Name,
|
||||||
VSearchConfig::Note,
|
VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -446,12 +437,11 @@ void VSearchUE::searchContentOfBuffer(const QString &p_cmd)
|
|||||||
emit stateUpdated(State::Success);
|
emit stateUpdated(State::Success);
|
||||||
} else {
|
} else {
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::OpenedNotes,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::OpenedNotes,
|
||||||
VSearchConfig::Content,
|
VSearchConfig::Content,
|
||||||
VSearchConfig::Note,
|
VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -467,12 +457,11 @@ void VSearchUE::searchOutlineOfBuffer(const QString &p_cmd)
|
|||||||
emit stateUpdated(State::Success);
|
emit stateUpdated(State::Success);
|
||||||
} else {
|
} else {
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::OpenedNotes,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::OpenedNotes,
|
||||||
VSearchConfig::Outline,
|
VSearchConfig::Outline,
|
||||||
VSearchConfig::Note,
|
VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -488,12 +477,11 @@ void VSearchUE::searchPathOfFolderNoteInAllNotebooks(const QString &p_cmd)
|
|||||||
emit stateUpdated(State::Success);
|
emit stateUpdated(State::Success);
|
||||||
} else {
|
} else {
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::AllNotebooks,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::AllNotebooks,
|
||||||
VSearchConfig::Path,
|
VSearchConfig::Path,
|
||||||
VSearchConfig::Folder | VSearchConfig::Note,
|
VSearchConfig::Folder | VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -511,12 +499,11 @@ void VSearchUE::searchPathOfFolderNoteInCurrentNotebook(const QString &p_cmd)
|
|||||||
QVector<VNotebook *> notebooks;
|
QVector<VNotebook *> notebooks;
|
||||||
notebooks.append(g_mainWin->getNotebookSelector()->currentNotebook());
|
notebooks.append(g_mainWin->getNotebookSelector()->currentNotebook());
|
||||||
m_search->clear();
|
m_search->clear();
|
||||||
VSearchConfig::Option opt = VSearchConfig::NoneOption;
|
|
||||||
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentNotebook,
|
QSharedPointer<VSearchConfig> config(new VSearchConfig(VSearchConfig::CurrentNotebook,
|
||||||
VSearchConfig::Path,
|
VSearchConfig::Path,
|
||||||
VSearchConfig::Folder | VSearchConfig::Note,
|
VSearchConfig::Folder | VSearchConfig::Note,
|
||||||
VSearchConfig::Internal,
|
VSearchConfig::Internal,
|
||||||
opt,
|
VSearchConfig::NoneOption,
|
||||||
p_cmd,
|
p_cmd,
|
||||||
QString()));
|
QString()));
|
||||||
m_search->setConfig(config);
|
m_search->setConfig(config);
|
||||||
@ -535,11 +522,6 @@ void VSearchUE::clear(int p_id)
|
|||||||
m_treeWidget->clearAll();
|
m_treeWidget->clearAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VSearchUE::entryHidden(int p_id)
|
|
||||||
{
|
|
||||||
Q_UNUSED(p_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VSearchUE::handleSearchItemAdded(const QSharedPointer<VSearchResultItem> &p_item)
|
void VSearchUE::handleSearchItemAdded(const QSharedPointer<VSearchResultItem> &p_item)
|
||||||
{
|
{
|
||||||
static int itemAdded = 0;
|
static int itemAdded = 0;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef VSEARCHUE_H
|
#ifndef VSEARCHUE_H
|
||||||
#define VSEARCHUE_H
|
#define VSEARCHUE_H
|
||||||
|
|
||||||
|
|
||||||
#include "iuniversalentry.h"
|
#include "iuniversalentry.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
@ -14,7 +13,7 @@ class VTreeWidget;
|
|||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
|
|
||||||
// Universal Entry to list and search all the notebooks.
|
// Universal Entry using VSearch.
|
||||||
class VSearchUE : public IUniversalEntry
|
class VSearchUE : public IUniversalEntry
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -68,8 +67,6 @@ public:
|
|||||||
|
|
||||||
void clear(int p_id) Q_DECL_OVERRIDE;
|
void clear(int p_id) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void entryHidden(int p_id) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
void selectNextItem(int p_id, bool p_forward) Q_DECL_OVERRIDE;
|
void selectNextItem(int p_id, bool p_forward) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void activate(int p_id) Q_DECL_OVERRIDE;
|
void activate(int p_id) Q_DECL_OVERRIDE;
|
||||||
|
@ -235,8 +235,7 @@ QGraphicsOpacityEffect *VTreeWidget::getSearchInputEffect() const
|
|||||||
|
|
||||||
static QTreeWidgetItem *lastItemOfTree(QTreeWidgetItem *p_item)
|
static QTreeWidgetItem *lastItemOfTree(QTreeWidgetItem *p_item)
|
||||||
{
|
{
|
||||||
if (p_item->isExpanded()) {
|
if (p_item->isExpanded() && p_item->childCount() > 0) {
|
||||||
Q_ASSERT(p_item->childCount() > 0);
|
|
||||||
return p_item->child(p_item->childCount() - 1);
|
return p_item->child(p_item->childCount() - 1);
|
||||||
} else {
|
} else {
|
||||||
return p_item;
|
return p_item;
|
||||||
@ -306,7 +305,7 @@ QTreeWidgetItem *VTreeWidget::nextItem(QTreeWidgetItem *p_item, bool p_forward)
|
|||||||
{
|
{
|
||||||
QTreeWidgetItem *nItem = NULL;
|
QTreeWidgetItem *nItem = NULL;
|
||||||
if (p_forward) {
|
if (p_forward) {
|
||||||
if (p_item->isExpanded()) {
|
if (p_item->isExpanded() && p_item->childCount() > 0) {
|
||||||
nItem = p_item->child(0);
|
nItem = p_item->child(0);
|
||||||
} else {
|
} else {
|
||||||
while (!nItem && p_item) {
|
while (!nItem && p_item) {
|
||||||
|
@ -147,6 +147,11 @@ void VUniversalEntry::showEvent(QShowEvent *p_event)
|
|||||||
activateWindow();
|
activateWindow();
|
||||||
|
|
||||||
m_cmdEdit->setFocus();
|
m_cmdEdit->setFocus();
|
||||||
|
m_cmdEdit->selectAll();
|
||||||
|
|
||||||
|
if (m_lastEntry) {
|
||||||
|
m_lastEntry->m_entry->entryShown(m_lastEntry->m_id, getCommandFromEdit());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VUniversalEntry::setAvailableRect(const QRect &p_rect)
|
void VUniversalEntry::setAvailableRect(const QRect &p_rect)
|
||||||
@ -168,7 +173,12 @@ void VUniversalEntry::registerEntry(QChar p_key, IUniversalEntry *p_entry, int p
|
|||||||
p_entry->setWidgetParent(this);
|
p_entry->setWidgetParent(this);
|
||||||
connect(p_entry, &IUniversalEntry::widgetUpdated,
|
connect(p_entry, &IUniversalEntry::widgetUpdated,
|
||||||
this, [this]() {
|
this, [this]() {
|
||||||
m_container->adjustSizeByWidget();
|
if (m_lastEntry) {
|
||||||
|
m_container->setWidget(m_lastEntry->m_entry->widget(m_lastEntry->m_id));
|
||||||
|
} else {
|
||||||
|
m_container->adjustSizeByWidget();
|
||||||
|
}
|
||||||
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
});
|
});
|
||||||
connect(p_entry, &IUniversalEntry::stateUpdated,
|
connect(p_entry, &IUniversalEntry::stateUpdated,
|
||||||
@ -358,3 +368,9 @@ void VUniversalEntry::updateState(IUniversalEntry::State p_state)
|
|||||||
m_cmdEdit->setStyleSheet(QString("border-color: %1;").arg(fg));
|
m_cmdEdit->setStyleSheet(QString("border-color: %1;").arg(fg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString VUniversalEntry::getCommandFromEdit() const
|
||||||
|
{
|
||||||
|
QString cmd = m_cmdEdit->getEvaluatedText();
|
||||||
|
return cmd.mid(1);
|
||||||
|
}
|
||||||
|
@ -93,6 +93,8 @@ private:
|
|||||||
|
|
||||||
void updateState(IUniversalEntry::State p_state);
|
void updateState(IUniversalEntry::State p_state);
|
||||||
|
|
||||||
|
QString getCommandFromEdit() const;
|
||||||
|
|
||||||
VMetaWordLineEdit *m_cmdEdit;
|
VMetaWordLineEdit *m_cmdEdit;
|
||||||
|
|
||||||
VUniversalEntryContainer *m_container;
|
VUniversalEntryContainer *m_container;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user