mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
setting tree match complete (#1932)
This commit is contained in:
parent
911392deab
commit
b369612070
@ -31,6 +31,10 @@ QWidget[DialogCentralWidget="true"] {
|
||||
border: 1px solid @widgets#qwidget#error#border;
|
||||
}
|
||||
|
||||
[HitSettingWidget="true"] {
|
||||
border: 4px solid @widgets#qwidget#info#border;
|
||||
}
|
||||
|
||||
/* QAbstractScrollArea */
|
||||
QAbstractScrollArea {
|
||||
border: 1px solid @widgets#qabstractscrollarea#border;
|
||||
|
@ -22,6 +22,14 @@
|
||||
#include "vipage.h"
|
||||
#include "notemanagementpage.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QColor>
|
||||
#include "settingspage.h"
|
||||
#include "utils/widgetutils.h"
|
||||
#include "../../propertydefs.h"
|
||||
#include <core/vnotex.h>
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget *p_parent)
|
||||
@ -67,6 +75,19 @@ void SettingsDialog::setupPageExplorer(QBoxLayout *p_layout, QWidget *p_parent)
|
||||
m_searchEdit = WidgetsFactory::createLineEdit(p_parent);
|
||||
m_searchEdit->setPlaceholderText(tr("Search"));
|
||||
layout->addWidget(m_searchEdit);
|
||||
connect(m_searchEdit,&QLineEdit::textChanged,
|
||||
this, [this]() { QTimer::singleShot(500, this, [this](){
|
||||
forEachPage([this](SettingsPage *p_page) {
|
||||
bool hit = p_page->search(m_searchEdit->text());
|
||||
if (hit) {
|
||||
qDebug() << p_page->title();
|
||||
// 目前只能找到tree的 通过 外观 笔记管理,快速访问与编辑器好像没有加入到tree的搜索中
|
||||
// 不知道如何找到item并且高亮
|
||||
}
|
||||
return hit;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
m_pageExplorer = new TreeWidget(TreeWidget::None, p_parent);
|
||||
TreeWidget::setupSingleColumnHeaderlessTree(m_pageExplorer, false, false);
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "settingspage.h"
|
||||
#include "utils/widgetutils.h"
|
||||
#include "../../propertydefs.h"
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
@ -19,16 +21,17 @@ bool SettingsPage::search(const QString &p_key)
|
||||
if (item.m_words.contains(p_key, Qt::CaseInsensitive)) {
|
||||
// Continue to search all the matched targets.
|
||||
hit = true;
|
||||
searchHit(item.m_target);
|
||||
searchHit(item.m_target, true);
|
||||
}
|
||||
}
|
||||
|
||||
return hit;
|
||||
}
|
||||
|
||||
void SettingsPage::searchHit(QWidget *p_target)
|
||||
void SettingsPage::searchHit(QWidget *p_target, bool hit)
|
||||
{
|
||||
Q_UNUSED(p_target);
|
||||
WidgetUtils::setPropertyDynamically(p_target, PropertyDefs::c_hitSettingWidght, hit);
|
||||
}
|
||||
|
||||
void SettingsPage::addSearchItem(const QString &p_words, QWidget *p_target)
|
||||
|
@ -34,7 +34,7 @@ namespace vnotex
|
||||
virtual bool saveInternal() = 0;
|
||||
|
||||
// Subclass could override this method to highlight matched target.
|
||||
virtual void searchHit(QWidget *p_target);
|
||||
virtual void searchHit(QWidget *p_target, bool hit);
|
||||
|
||||
void addSearchItem(const QString &p_words, QWidget *p_target);
|
||||
|
||||
|
@ -25,3 +25,5 @@ const char *PropertyDefs::c_embeddedLineEdit = "EmbeddedLineEdit";
|
||||
const char *PropertyDefs::c_dockWidgetIndex = "DockIndex";
|
||||
|
||||
const char *PropertyDefs::c_dockWidgetTitle = "DockTitle";
|
||||
|
||||
const char *PropertyDefs::c_hitSettingWidght = "HitSettingWidget";
|
||||
|
@ -33,6 +33,8 @@ namespace vnotex
|
||||
static const char *c_dockWidgetIndex;
|
||||
|
||||
static const char *c_dockWidgetTitle;
|
||||
|
||||
static const char *c_hitSettingWidght;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user