Am Freitag, dem 01.04.2022 um 09:35 +0200 schrieb Jürgen Spitzmüller:
> I have a GUI ready, but it doesn't work. I am not sure I understand
> how
> this is supposed to be used. If I have a text file with "test
> \textbf{test} test" and search for "test", the bold string is found
> no
> matter what I do (e.g., also if I do "search-ignore series false"
> before searching and no matter whether "Ignore format" is checked in
> the dialog or not).
> 
> What am I doing wrong?

FYI attached is the patch. It still does not work at all. I am stuck.

-- 
Jürgen
diff --git a/src/frontends/qt/FindAndReplace.cpp b/src/frontends/qt/FindAndReplace.cpp
index ab61e1ab73..074cf78ee9 100644
--- a/src/frontends/qt/FindAndReplace.cpp
+++ b/src/frontends/qt/FindAndReplace.cpp
@@ -469,10 +469,48 @@ bool FindAndReplaceWidget::findAndReplace(
 	FindAndReplaceOptions opt(find_buf_name, casesensitive, matchword,
 				  !backwards, expandmacros, ignoreformat,
 				  repl_buf_name, keep_case, scope, restr);
+	
+	if (ignoreformat) {
+		// Formats to ignore
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("language",
+					  ignoreLanguageCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("color",
+					  ignoreColorCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("family",
+					  ignoreFFamilyCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("series",
+					  ignoreFSeriesCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("shape",
+					  ignoreFShapeCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("markup",
+					  ignoreMarkupCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("underline",
+					  ignoreUnderlineCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("strike",
+					  ignoreStrikeCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("deleted",
+					  ignoreDeletedCB->isChecked())));
+		lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("sectioning",
+					  ignoreSectioningCB->isChecked())));
+	}
+	lyx::dispatch(FuncRequest(LFUN_SEARCH_IGNORE, checkState("non-output-content",
+				  ignoreNonOutputCB->isChecked())));
+	
 	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)
 {
 	if (! view_.currentMainWorkArea()) {
@@ -492,7 +530,7 @@ bool FindAndReplaceWidget::findAndReplace(bool backwards, bool replace, bool rep
 		wordsCB->isChecked(),
 		backwards,
 		expandMacrosCB->isChecked(),
-		ignoreFormatCB->isChecked(),
+		ignoreFormatGB->isChecked(),
 		replace,
 		keepCaseCB->isChecked(),
 		replace_all);
@@ -532,6 +570,33 @@ void FindAndReplaceWidget::on_searchbackCB_clicked()
 }
 
 
+void FindAndReplaceWidget::setFormatIgnores(bool const b)
+{
+	ignoreLanguageCB->setChecked(b);
+	ignoreColorCB->setChecked(b);
+	ignoreFFamilyCB->setChecked(b);
+	ignoreFSeriesCB->setChecked(b);
+	ignoreFShapeCB->setChecked(b);
+	ignoreMarkupCB->setChecked(b);
+	ignoreUnderlineCB->setChecked(b);
+	ignoreStrikeCB->setChecked(b);
+	ignoreDeletedCB->setChecked(b);
+	ignoreSectioningCB->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
 static void copy_params(BufferView const & bv, BufferView & dest_bv) {
 	Buffer const & doc_buf = bv.buffer();
@@ -584,8 +649,9 @@ void FindAndReplace::updateView()
 
 
 FindAndReplace::FindAndReplace(GuiView & parent,
-		Qt::DockWidgetArea area, Qt::WindowFlags flags)
-	: DockView(parent, "findreplaceadv", qt_("Advanced Find and Replace"),
+			       Qt::DockWidgetArea area,
+			       Qt::WindowFlags flags)
+    : DockView(parent, "findreplaceadv", qt_("Advanced Find and Replace"),
 		   area, flags)
 {
 	widget_ = new FindAndReplaceWidget(parent);
diff --git a/src/frontends/qt/FindAndReplace.h b/src/frontends/qt/FindAndReplace.h
index 0ffc39d458..7ea70a97ed 100644
--- a/src/frontends/qt/FindAndReplace.h
+++ b/src/frontends/qt/FindAndReplace.h
@@ -16,6 +16,7 @@
 // This is needed so that ui_FindAndReplaceUi.h can find qt_()
 #include "qt_helpers.h"
 #include "ui_FindAndReplaceUi.h"
+#include "support/docstring.h"
 
 #include <string>
 
@@ -65,12 +66,18 @@ private:
 	void virtual hideEvent(QHideEvent *ev) override;
 
 	void hideDialog();
+	
+	void setFormatIgnores(bool const b);
+	
+	docstring const checkState(std::string const s, bool const b);
 
 protected Q_SLOTS:
 	void on_findNextPB_clicked();
 	void on_replacePB_clicked();
 	void on_replaceallPB_clicked();
 	void on_searchbackCB_clicked();
+	void on_selectAllPB_clicked();
+	void on_deselectAllPB_clicked();
 };
 
 
diff --git a/src/frontends/qt/ui/FindAndReplaceUi.ui b/src/frontends/qt/ui/FindAndReplaceUi.ui
index 58a16eb245..4b33ce0263 100644
--- a/src/frontends/qt/ui/FindAndReplaceUi.ui
+++ b/src/frontends/qt/ui/FindAndReplaceUi.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>374</width>
-    <height>380</height>
+    <height>638</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -263,7 +263,7 @@
    <attribute name="title">
     <string>Settin&amp;gs</string>
    </attribute>
-   <layout class="QVBoxLayout" name="dynamicLayoutAdvanced_" stretch="0,0,1">
+   <layout class="QVBoxLayout" name="dynamicLayoutAdvanced_" stretch="0,0,0,1">
     <item>
      <widget class="QGroupBox" name="groupBox_2">
       <property name="enabled">
@@ -365,42 +365,26 @@
        <enum>QLayout::SetMinimumSize</enum>
       </property>
       <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&amp;ly in maths</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0">
-       <widget class="QCheckBox" name="ignoreFormatCB">
+       <widget class="QCheckBox" name="expandMacrosCB">
         <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>
+         <bool>false</bool>
         </property>
         <property name="text">
-         <string>I&amp;gnore format</string>
-        </property>
-        <property name="checked">
-         <bool>true</bool>
+         <string>E&amp;xpand macros</string>
         </property>
        </widget>
       </item>
-      <item row="4" column="0">
-       <widget class="QCheckBox" name="expandMacrosCB">
-        <property name="enabled">
-         <bool>false</bool>
+      <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>E&amp;xpand macros</string>
+         <string>Search on&amp;ly in maths</string>
         </property>
        </widget>
       </item>
-      <item row="2" column="0">
+      <item row="1" column="0">
        <widget class="QCheckBox" name="keepCaseCB">
         <property name="toolTip">
          <string>Keep the case of the replacement's first letter as in each matching text first letter</string>
@@ -423,8 +407,114 @@
         </property>
        </spacer>
       </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 &amp;non-output content</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </item>
+    <item>
+     <widget class="QGroupBox" name="ignoreFormatGB">
+      <property name="title">
+       <string>I&amp;gnore formatting</string>
+      </property>
+      <property name="checkable">
+       <bool>true</bool>
+      </property>
+      <layout class="QGridLayout" name="gridLayout_4">
+       <item row="0" column="0">
+        <widget class="QCheckBox" name="ignoreLanguageCB">
+         <property name="text">
+          <string>Language</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1">
+        <widget class="QCheckBox" name="ignoreMarkupCB">
+         <property name="text">
+          <string>Emph/noun</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QCheckBox" name="ignoreColorCB">
+         <property name="text">
+          <string>Font color</string>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <widget class="QCheckBox" name="ignoreUnderlineCB">
+         <property name="text">
+          <string>Underlining</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0">
+        <widget class="QCheckBox" name="ignoreFFamilyCB">
+         <property name="text">
+          <string>Font family</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="1">
+        <widget class="QCheckBox" name="ignoreStrikeCB">
+         <property name="text">
+          <string>Strike-through</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0">
+        <widget class="QCheckBox" name="ignoreFSeriesCB">
+         <property name="text">
+          <string>Font series</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1">
+        <widget class="QCheckBox" name="ignoreDeletedCB">
+         <property name="text">
+          <string>Deletion (change)</string>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="0">
+        <widget class="QCheckBox" name="ignoreFShapeCB">
+         <property name="text">
+          <string>Font shape</string>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="1">
+        <widget class="QCheckBox" name="ignoreSectioningCB">
+         <property name="text">
+          <string>Sectioning markup</string>
+         </property>
+        </widget>
+       </item>
+       <item row="5" column="0">
+        <widget class="QPushButton" name="selectAllPB">
+         <property name="text">
+          <string>Select all</string>
+         </property>
+        </widget>
+       </item>
+       <item row="5" column="1">
+        <widget class="QPushButton" name="deselectAllPB">
+         <property name="text">
+          <string>Deselect all</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </item>
     <item>
      <spacer name="verticalSpacer_2">
       <property name="orientation">

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to