mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 21:05:12 +00:00
Add GUI for search-ignore
This commit is contained in:
parent
cbe2f61396
commit
c0a3d654ff
@ -421,7 +421,7 @@ bool FindAndReplaceWidget::findAndReplaceScope(FindAndReplaceOptions & opt, bool
|
|||||||
/// Return true if a match was found
|
/// Return true if a match was found
|
||||||
bool FindAndReplaceWidget::findAndReplace(
|
bool FindAndReplaceWidget::findAndReplace(
|
||||||
bool casesensitive, bool matchword, bool backwards,
|
bool casesensitive, bool matchword, bool backwards,
|
||||||
bool expandmacros, bool ignoreformat, bool replace,
|
bool expandmacros, bool adhereformat, bool replace,
|
||||||
bool keep_case, bool replace_all)
|
bool keep_case, bool replace_all)
|
||||||
{
|
{
|
||||||
Buffer & find_buf = find_work_area_->bufferView().buffer();
|
Buffer & find_buf = find_work_area_->bufferView().buffer();
|
||||||
@ -460,19 +460,59 @@ bool FindAndReplaceWidget::findAndReplace(
|
|||||||
<< ", matchword=" << matchword
|
<< ", matchword=" << matchword
|
||||||
<< ", backwards=" << backwards
|
<< ", backwards=" << backwards
|
||||||
<< ", expandmacros=" << expandmacros
|
<< ", expandmacros=" << expandmacros
|
||||||
<< ", ignoreformat=" << ignoreformat
|
<< ", adhereformat=" << adhereformat
|
||||||
<< ", repl_buf_name" << repl_buf_name
|
<< ", repl_buf_name" << repl_buf_name
|
||||||
<< ", keep_case=" << keep_case
|
<< ", keep_case=" << keep_case
|
||||||
<< ", scope=" << scope
|
<< ", scope=" << scope
|
||||||
<< ", restr=" << restr);
|
<< ", restr=" << restr);
|
||||||
|
|
||||||
FindAndReplaceOptions opt(find_buf_name, casesensitive, matchword,
|
FindAndReplaceOptions opt(find_buf_name, casesensitive, matchword,
|
||||||
!backwards, expandmacros, ignoreformat,
|
!backwards, expandmacros, !adhereformat,
|
||||||
repl_buf_name, keep_case, scope, restr);
|
repl_buf_name, keep_case, scope, restr);
|
||||||
|
|
||||||
|
if (adhereformat) {
|
||||||
|
// Formats to adhere
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("language",
|
||||||
|
!adhereLanguageCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("color",
|
||||||
|
!adhereColorCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("family",
|
||||||
|
!adhereFFamilyCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("series",
|
||||||
|
!adhereFSeriesCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("shape",
|
||||||
|
!adhereFShapeCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("size",
|
||||||
|
!adhereFSizeCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("markup",
|
||||||
|
!adhereMarkupCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("underline",
|
||||||
|
!adhereUnderlineCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("strike",
|
||||||
|
!adhereStrikeCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("deleted",
|
||||||
|
!adhereDeletedCB->isChecked())));
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("sectioning",
|
||||||
|
!adhereSectioningCB->isChecked())));
|
||||||
|
}
|
||||||
|
lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("non-output-content",
|
||||||
|
ignoreNonOutputCB->isChecked())));
|
||||||
|
|
||||||
return findAndReplaceScope(opt, replace_all);
|
return findAndReplaceScope(opt, replace_all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
docstring const FindAndReplaceWidget::checkState(string const s, bool const b)
|
||||||
|
{
|
||||||
|
docstring res = from_ascii(s) + from_ascii(" ");
|
||||||
|
if (b)
|
||||||
|
res += from_ascii("true");
|
||||||
|
else
|
||||||
|
res += from_ascii("false");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FindAndReplaceWidget::findAndReplace(bool backwards, bool replace, bool replace_all)
|
bool FindAndReplaceWidget::findAndReplace(bool backwards, bool replace, bool replace_all)
|
||||||
{
|
{
|
||||||
if (! view_.currentMainWorkArea()) {
|
if (! view_.currentMainWorkArea()) {
|
||||||
@ -492,7 +532,7 @@ bool FindAndReplaceWidget::findAndReplace(bool backwards, bool replace, bool rep
|
|||||||
wordsCB->isChecked(),
|
wordsCB->isChecked(),
|
||||||
backwards,
|
backwards,
|
||||||
expandMacrosCB->isChecked(),
|
expandMacrosCB->isChecked(),
|
||||||
ignoreFormatCB->isChecked(),
|
adhereFormatGB->isChecked(),
|
||||||
replace,
|
replace,
|
||||||
keepCaseCB->isChecked(),
|
keepCaseCB->isChecked(),
|
||||||
replace_all);
|
replace_all);
|
||||||
@ -532,6 +572,34 @@ void FindAndReplaceWidget::on_searchbackCB_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FindAndReplaceWidget::setFormatIgnores(bool const b)
|
||||||
|
{
|
||||||
|
adhereLanguageCB->setChecked(b);
|
||||||
|
adhereColorCB->setChecked(b);
|
||||||
|
adhereFFamilyCB->setChecked(b);
|
||||||
|
adhereFSeriesCB->setChecked(b);
|
||||||
|
adhereFShapeCB->setChecked(b);
|
||||||
|
adhereFSizeCB->setChecked(b);
|
||||||
|
adhereMarkupCB->setChecked(b);
|
||||||
|
adhereUnderlineCB->setChecked(b);
|
||||||
|
adhereStrikeCB->setChecked(b);
|
||||||
|
adhereDeletedCB->setChecked(b);
|
||||||
|
adhereSectioningCB->setChecked(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FindAndReplaceWidget::on_selectAllPB_clicked()
|
||||||
|
{
|
||||||
|
setFormatIgnores(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FindAndReplaceWidget::on_deselectAllPB_clicked()
|
||||||
|
{
|
||||||
|
setFormatIgnores(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Copy selected elements from bv's BufferParams to the dest_bv's
|
// Copy selected elements from bv's BufferParams to the dest_bv's
|
||||||
static void copy_params(BufferView const & bv, BufferView & dest_bv) {
|
static void copy_params(BufferView const & bv, BufferView & dest_bv) {
|
||||||
Buffer const & doc_buf = bv.buffer();
|
Buffer const & doc_buf = bv.buffer();
|
||||||
@ -584,8 +652,9 @@ void FindAndReplace::updateView()
|
|||||||
|
|
||||||
|
|
||||||
FindAndReplace::FindAndReplace(GuiView & parent,
|
FindAndReplace::FindAndReplace(GuiView & parent,
|
||||||
Qt::DockWidgetArea area, Qt::WindowFlags flags)
|
Qt::DockWidgetArea area,
|
||||||
: DockView(parent, "findreplaceadv", qt_("Advanced Find and Replace"),
|
Qt::WindowFlags flags)
|
||||||
|
: DockView(parent, "findreplaceadv", qt_("Advanced Find and Replace"),
|
||||||
area, flags)
|
area, flags)
|
||||||
{
|
{
|
||||||
widget_ = new FindAndReplaceWidget(parent);
|
widget_ = new FindAndReplaceWidget(parent);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
// This is needed so that ui_FindAndReplaceUi.h can find qt_()
|
// This is needed so that ui_FindAndReplaceUi.h can find qt_()
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "ui_FindAndReplaceUi.h"
|
#include "ui_FindAndReplaceUi.h"
|
||||||
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -66,11 +67,17 @@ private:
|
|||||||
|
|
||||||
void hideDialog();
|
void hideDialog();
|
||||||
|
|
||||||
|
void setFormatIgnores(bool const b);
|
||||||
|
|
||||||
|
docstring const checkState(std::string const s, bool const b);
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void on_findNextPB_clicked();
|
void on_findNextPB_clicked();
|
||||||
void on_replacePB_clicked();
|
void on_replacePB_clicked();
|
||||||
void on_replaceallPB_clicked();
|
void on_replaceallPB_clicked();
|
||||||
void on_searchbackCB_clicked();
|
void on_searchbackCB_clicked();
|
||||||
|
void on_selectAllPB_clicked();
|
||||||
|
void on_deselectAllPB_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>374</width>
|
<width>374</width>
|
||||||
<height>380</height>
|
<height>664</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -263,7 +263,7 @@
|
|||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Settin&gs</string>
|
<string>Settin&gs</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="dynamicLayoutAdvanced_" stretch="0,0,1">
|
<layout class="QVBoxLayout" name="dynamicLayoutAdvanced_" stretch="0,0,0,1">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -365,32 +365,6 @@
|
|||||||
<enum>QLayout::SetMinimumSize</enum>
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
</property>
|
</property>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QCheckBox" name="OnlyMaths">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Restrict search to math environments only</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Search on&ly in maths</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QCheckBox" name="ignoreFormatCB">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>If unchecked, the search will be limited to occurrences of the selected text and paragraph style</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>I&gnore format</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QCheckBox" name="expandMacrosCB">
|
<widget class="QCheckBox" name="expandMacrosCB">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -401,6 +375,16 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="OnlyMaths">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Restrict search to math environments only</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Search on&ly in maths</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
<widget class="QCheckBox" name="keepCaseCB">
|
<widget class="QCheckBox" name="keepCaseCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Keep the case of the replacement's first letter as in each matching text first letter</string>
|
<string>Keep the case of the replacement's first letter as in each matching text first letter</string>
|
||||||
@ -423,8 +407,127 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QCheckBox" name="ignoreNonOutputCB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Do not search in content that is not output (e.g., notes)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Ignore &non-output content</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="adhereFormatGB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>If the search string is formatted in a non-default way, only find strings formatted like the search string in the checked respects</string>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Ad&here to search string formatting of</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="adhereStrikeCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Strike-through</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QCheckBox" name="adhereFSeriesCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font series</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="adhereColorCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QCheckBox" name="adhereMarkupCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Emph/noun</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QPushButton" name="deselectAllPB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Deselect all</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="adhereFFamilyCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font family</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="adhereLanguageCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Language</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QCheckBox" name="adhereSectioningCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sectioning markup</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QCheckBox" name="adhereDeletedCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Deletion (change)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="adhereUnderlineCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Underlining</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QCheckBox" name="adhereFShapeCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font shape</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QPushButton" name="selectAllPB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select all</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QCheckBox" name="adhereFSizeCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Font size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Loading…
Reference in New Issue
Block a user