Abdelrazak Younes ha scritto:
On 21/12/2008 20:17, Tommaso Cucinotta wrote:
- recovers the eventFilter functionality back, so as to catch
 "Enter" or "Esc" key presses while in the Search Work Area
Well, I explicitly got rid of this thanks to the initialiseParams() method which takes care of focus. Your patch is undoing that. About the Enter key catching, I am not sure this is desired as one may want to search for multiple lines text. I'd be OK with alt+Return though...
About the Esc key, maybe...
In the attached patch, the initialiseParams() stuff is back as from your modifications.

Focus on dialog pop-up (C-S-f) is now fixed, only when you wrap-around focus goes
to the mainworkarea who knows why.

Concerning the Ui, probably how to arrange buttons is just a matter of taste, rather than of actual usability. The important thing is that the corresponding
functions work, the rest is just cosmetics. For the multi-paragraph search,
we should check how it would (be supposed to) work. The Enter triggering
search-next was just meant to mimic the usual behaviour as users find it in
any text editor, but Alt+RET or C-S-RET would easily play the same role.

Bye,

   T.

ps: I know, the attached patch does not comply to any of the envisioned
       1) and 2) options :-)

--
Tommaso Cucinotta, Computer Engineering PhD, Researcher
ReTiS Lab, Scuola Superiore Sant'Anna, Pisa, Italy
Tel +39 050 882 024, Fax +39 050 882 003
http://feanor.sssup.it/~tommaso

Proprietà modificate su: src/frontends/qt4
___________________________________________________________________
Modified: svn:ignore
   - Makefile
Makefile.in
libqt4.la
.deps
.libs
*_moc.cpp
*.lo
pch.h.gch.dep
pch.h.gch

   + Makefile
Makefile.in
libqt4.la
.deps
.libs
*_moc.cpp
*.lo
pch.h.gch.dep
pch.h.gch

moc_*.cpp

ui_*Ui.h

Resources.qrc

Resources.cpp

stRfMFBn


Index: src/frontends/qt4/ui/FindAndReplaceUi.ui
===================================================================
--- src/frontends/qt4/ui/FindAndReplaceUi.ui	(revisione 27945)
+++ src/frontends/qt4/ui/FindAndReplaceUi.ui	(copia locale)
@@ -6,11 +6,11 @@
     <x>0</x>
     <y>0</y>
     <width>240</width>
-    <height>432</height>
+    <height>400</height>
    </rect>
   </property>
   <property name="sizePolicy" >
-   <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+   <sizepolicy vsizetype="Expanding" hsizetype="MinimumExpanding" >
     <horstretch>0</horstretch>
     <verstretch>0</verstretch>
    </sizepolicy>
@@ -33,307 +33,353 @@
   <property name="toolTip" >
    <string/>
   </property>
-  <widget class="QWidget" name="" >
+  <widget class="QTabWidget" name="tabWidget" >
    <property name="geometry" >
     <rect>
-     <x>20</x>
-     <y>20</y>
-     <width>212</width>
-     <height>404</height>
+     <x>0</x>
+     <y>0</y>
+     <width>231</width>
+     <height>381</height>
     </rect>
    </property>
-   <layout class="QGridLayout" name="gridLayout" >
-    <item row="0" column="0" colspan="3" >
-     <widget class="lyx::frontend::EmbeddedWorkArea" name="find_work_area_" >
-      <property name="widgetResizable" >
-       <bool>true</bool>
+   <property name="sizePolicy" >
+    <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
+     <horstretch>0</horstretch>
+     <verstretch>0</verstretch>
+    </sizepolicy>
+   </property>
+   <property name="currentIndex" >
+    <number>0</number>
+   </property>
+   <widget class="QWidget" name="tab_3" >
+    <property name="sizePolicy" >
+     <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
+      <horstretch>0</horstretch>
+      <verstretch>0</verstretch>
+     </sizepolicy>
+    </property>
+    <attribute name="title" >
+     <string>Basic</string>
+    </attribute>
+    <widget class="QWidget" name="layoutWidget" >
+     <property name="geometry" >
+      <rect>
+       <x>0</x>
+       <y>0</y>
+       <width>227</width>
+       <height>351</height>
+      </rect>
+     </property>
+     <layout class="QGridLayout" name="gridLayout" >
+      <property name="sizeConstraint" >
+       <enum>QLayout::SetNoConstraint</enum>
       </property>
-      <widget class="QWidget" name="scrollAreaWidgetContents" >
-       <property name="geometry" >
-        <rect>
-         <x>0</x>
-         <y>0</y>
-         <width>208</width>
-         <height>69</height>
-        </rect>
-       </property>
-      </widget>
-     </widget>
-    </item>
-    <item row="1" column="0" colspan="2" >
-     <widget class="QCheckBox" name="expandMacrosCB" >
-      <property name="enabled" >
-       <bool>false</bool>
-      </property>
-      <property name="text" >
-       <string>&amp;Expand macros</string>
-      </property>
-     </widget>
-    </item>
-    <item row="1" column="2" >
-     <widget class="QCheckBox" name="caseCB" >
-      <property name="text" >
-       <string>Case &amp;sensitive</string>
-      </property>
-     </widget>
-    </item>
-    <item row="2" column="0" colspan="2" >
-     <widget class="QCheckBox" name="wordsCB" >
-      <property name="enabled" >
-       <bool>false</bool>
-      </property>
-      <property name="text" >
-       <string>Whole words onl&amp;y</string>
-      </property>
-     </widget>
-    </item>
-    <item row="2" column="2" >
-     <widget class="QCheckBox" name="ignoreFormatCB" >
-      <property name="enabled" >
-       <bool>true</bool>
-      </property>
-      <property name="text" >
-       <string>Ignore For&amp;mat</string>
-      </property>
-      <property name="checked" >
-       <bool>true</bool>
-      </property>
-     </widget>
-    </item>
-    <item row="3" column="0" colspan="2" >
-     <widget class="QPushButton" name="findNextPB" >
-      <property name="enabled" >
-       <bool>true</bool>
-      </property>
-      <property name="text" >
-       <string>Find &amp;Next</string>
-      </property>
-      <property name="default" >
-       <bool>true</bool>
-      </property>
-     </widget>
-    </item>
-    <item row="3" column="2" >
-     <widget class="QPushButton" name="findPrevPB" >
-      <property name="enabled" >
-       <bool>true</bool>
-      </property>
-      <property name="text" >
-       <string>Find &amp;Prev</string>
-      </property>
-      <property name="default" >
-       <bool>true</bool>
-      </property>
-     </widget>
-    </item>
-    <item row="5" column="0" >
-     <widget class="QPushButton" name="replacePB" >
-      <property name="enabled" >
-       <bool>false</bool>
-      </property>
-      <property name="text" >
-       <string>&amp;Replace</string>
-      </property>
-     </widget>
-    </item>
-    <item row="6" column="0" >
-     <widget class="QPushButton" name="replaceallPB" >
-      <property name="enabled" >
-       <bool>false</bool>
-      </property>
-      <property name="text" >
-       <string>Replace &amp;All</string>
-      </property>
-     </widget>
-    </item>
-    <item row="6" column="1" colspan="2" >
-     <widget class="QPushButton" name="closePB" >
-      <property name="text" >
-       <string>&amp;Close</string>
-      </property>
-     </widget>
-    </item>
-    <item row="7" column="0" >
-     <widget class="QGroupBox" name="groupBox_2" >
-      <property name="enabled" >
-       <bool>false</bool>
-      </property>
-      <property name="sizePolicy" >
-       <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
-        <horstretch>0</horstretch>
-        <verstretch>0</verstretch>
-       </sizepolicy>
-      </property>
-      <property name="minimumSize" >
-       <size>
-        <width>0</width>
-        <height>111</height>
-       </size>
-      </property>
-      <property name="title" >
-       <string>Sco&amp;pe</string>
-      </property>
-      <widget class="QRadioButton" name="scopeRB" >
-       <property name="geometry" >
-        <rect>
-         <x>10</x>
-         <y>40</y>
-         <width>121</width>
-         <height>23</height>
-        </rect>
-       </property>
-       <property name="toolTip" >
-        <string>Current buffer only</string>
-       </property>
-       <property name="text" >
-        <string>Buffer</string>
-       </property>
-       <property name="checked" >
-        <bool>true</bool>
-       </property>
-      </widget>
-      <widget class="QRadioButton" name="scopeRB_3" >
-       <property name="geometry" >
-        <rect>
-         <x>10</x>
-         <y>60</y>
-         <width>121</width>
-         <height>23</height>
-        </rect>
-       </property>
-       <property name="toolTip" >
-        <string>Current file and all included files</string>
-       </property>
-       <property name="text" >
-        <string>Document</string>
-       </property>
-      </widget>
-      <widget class="QRadioButton" name="scopeRB_2" >
-       <property name="geometry" >
-        <rect>
-         <x>10</x>
-         <y>20</y>
-         <width>121</width>
-         <height>23</height>
-        </rect>
-       </property>
-       <property name="toolTip" >
-        <string>Current paragraph only</string>
-       </property>
-       <property name="text" >
-        <string>Paragraph</string>
-       </property>
-       <property name="checked" >
-        <bool>false</bool>
-       </property>
-      </widget>
-      <widget class="QRadioButton" name="scopeRB_4" >
-       <property name="geometry" >
-        <rect>
-         <x>10</x>
-         <y>80</y>
-         <width>121</width>
-         <height>23</height>
-        </rect>
-       </property>
-       <property name="toolTip" >
-        <string>All open buffers</string>
-       </property>
-       <property name="text" >
-        <string>Open buffers</string>
-       </property>
-      </widget>
-     </widget>
-    </item>
-    <item row="7" column="1" colspan="2" >
-     <widget class="QGroupBox" name="groupBox_3" >
-      <property name="enabled" >
-       <bool>true</bool>
-      </property>
-      <property name="sizePolicy" >
-       <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
-        <horstretch>0</horstretch>
-        <verstretch>0</verstretch>
-       </sizepolicy>
-      </property>
-      <property name="minimumSize" >
-       <size>
-        <width>0</width>
-        <height>111</height>
-       </size>
-      </property>
-      <property name="title" >
-       <string>RegExp</string>
-      </property>
-      <widget class="QComboBox" name="regexpInsertCombo" >
-       <property name="enabled" >
-        <bool>true</bool>
-       </property>
-       <property name="geometry" >
-        <rect>
-         <x>10</x>
-         <y>52</y>
-         <width>101</width>
-         <height>20</height>
-        </rect>
-       </property>
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <item>
+      <item row="0" column="0" colspan="2" >
+       <widget class="lyx::frontend::EmbeddedWorkArea" name="find_work_area_" >
+        <property name="baseSize" >
+         <size>
+          <width>0</width>
+          <height>128</height>
+         </size>
+        </property>
+        <property name="widgetResizable" >
+         <bool>true</bool>
+        </property>
+        <widget class="QWidget" name="scrollAreaWidgetContents" >
+         <property name="geometry" >
+          <rect>
+           <x>0</x>
+           <y>0</y>
+           <width>221</width>
+           <height>85</height>
+          </rect>
+         </property>
+        </widget>
+       </widget>
+      </item>
+      <item row="2" column="0" >
+       <widget class="QCheckBox" name="wordsCB" >
+        <property name="enabled" >
+         <bool>false</bool>
+        </property>
         <property name="text" >
-         <string>Match...</string>
+         <string>Whole &amp;words</string>
         </property>
-       </item>
-       <item>
+       </widget>
+      </item>
+      <item row="3" column="0" >
+       <widget class="QPushButton" name="findNextPB" >
+        <property name="enabled" >
+         <bool>true</bool>
+        </property>
         <property name="text" >
-         <string>Anything</string>
+         <string>Find &amp;Next</string>
         </property>
-       </item>
-       <item>
+        <property name="default" >
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="0" >
+       <widget class="QPushButton" name="replaceNextPB" >
+        <property name="enabled" >
+         <bool>false</bool>
+        </property>
         <property name="text" >
-         <string>Any non-empty</string>
+         <string>Replace Ne&amp;xt</string>
         </property>
-       </item>
-       <item>
+       </widget>
+      </item>
+      <item row="6" column="0" >
+       <widget class="QPushButton" name="replaceallPB" >
+        <property name="enabled" >
+         <bool>false</bool>
+        </property>
         <property name="text" >
-         <string>Any word</string>
+         <string>Replace &amp;All</string>
         </property>
-       </item>
-       <item>
+       </widget>
+      </item>
+      <item row="6" column="1" >
+       <widget class="QPushButton" name="closePB" >
         <property name="text" >
-         <string>Any number</string>
+         <string>&amp;Close</string>
         </property>
-       </item>
-      </widget>
-     </widget>
-    </item>
-    <item row="4" column="0" colspan="3" >
-     <widget class="lyx::frontend::EmbeddedWorkArea" name="replace_work_area_" >
-      <property name="widgetResizable" >
-       <bool>true</bool>
-      </property>
-      <widget class="QWidget" name="scrollAreaWidgetContents_2" >
-       <property name="geometry" >
-        <rect>
-         <x>0</x>
-         <y>0</y>
-         <width>208</width>
-         <height>69</height>
-        </rect>
-       </property>
-      </widget>
-     </widget>
-    </item>
-   </layout>
-   <zorder>replace_work_area_</zorder>
+       </widget>
+      </item>
+      <item row="4" column="0" colspan="2" >
+       <widget class="lyx::frontend::EmbeddedWorkArea" name="replace_work_area_" >
+        <property name="baseSize" >
+         <size>
+          <width>0</width>
+          <height>128</height>
+         </size>
+        </property>
+        <property name="widgetResizable" >
+         <bool>true</bool>
+        </property>
+        <widget class="QWidget" name="scrollAreaWidgetContents_2" >
+         <property name="geometry" >
+          <rect>
+           <x>0</x>
+           <y>0</y>
+           <width>221</width>
+           <height>85</height>
+          </rect>
+         </property>
+        </widget>
+       </widget>
+      </item>
+      <item row="3" column="1" >
+       <widget class="QPushButton" name="findPrevPB" >
+        <property name="enabled" >
+         <bool>true</bool>
+        </property>
+        <property name="text" >
+         <string>Find &amp;Prev</string>
+        </property>
+        <property name="default" >
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="1" >
+       <widget class="QPushButton" name="replacePrevPB" >
+        <property name="enabled" >
+         <bool>false</bool>
+        </property>
+        <property name="text" >
+         <string>Replace P&amp;rev</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0" >
+       <widget class="QCheckBox" name="caseCB" >
+        <property name="text" >
+         <string>Case &amp;sensitive</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1" >
+       <widget class="QCheckBox" name="ignoreFormatCB" >
+        <property name="enabled" >
+         <bool>true</bool>
+        </property>
+        <property name="text" >
+         <string>Ignore For&amp;mat</string>
+        </property>
+        <property name="checked" >
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1" >
+       <widget class="QComboBox" name="regexpInsertCombo" >
+        <property name="enabled" >
+         <bool>true</bool>
+        </property>
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <item>
+         <property name="text" >
+          <string>Match...</string>
+         </property>
+        </item>
+        <item>
+         <property name="text" >
+          <string>Anything</string>
+         </property>
+        </item>
+        <item>
+         <property name="text" >
+          <string>Any non-empty</string>
+         </property>
+        </item>
+        <item>
+         <property name="text" >
+          <string>Any word</string>
+         </property>
+        </item>
+        <item>
+         <property name="text" >
+          <string>Any number</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </widget>
+   <widget class="QWidget" name="tab_4" >
+    <property name="sizePolicy" >
+     <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
+      <horstretch>0</horstretch>
+      <verstretch>0</verstretch>
+     </sizepolicy>
+    </property>
+    <attribute name="title" >
+     <string>Advanced</string>
+    </attribute>
+    <widget class="QWidget" name="gridLayoutWidget" >
+     <property name="geometry" >
+      <rect>
+       <x>0</x>
+       <y>0</y>
+       <width>221</width>
+       <height>143</height>
+      </rect>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_2" >
+      <item row="0" column="0" >
+       <widget class="QGroupBox" name="groupBox_2" >
+        <property name="enabled" >
+         <bool>false</bool>
+        </property>
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize" >
+         <size>
+          <width>0</width>
+          <height>111</height>
+         </size>
+        </property>
+        <property name="title" >
+         <string>Sco&amp;pe</string>
+        </property>
+        <widget class="QRadioButton" name="scopeRB" >
+         <property name="geometry" >
+          <rect>
+           <x>10</x>
+           <y>40</y>
+           <width>121</width>
+           <height>23</height>
+          </rect>
+         </property>
+         <property name="toolTip" >
+          <string>Current buffer only</string>
+         </property>
+         <property name="text" >
+          <string>Buffer</string>
+         </property>
+         <property name="checked" >
+          <bool>true</bool>
+         </property>
+        </widget>
+        <widget class="QRadioButton" name="scopeRB_3" >
+         <property name="geometry" >
+          <rect>
+           <x>10</x>
+           <y>60</y>
+           <width>121</width>
+           <height>23</height>
+          </rect>
+         </property>
+         <property name="toolTip" >
+          <string>Current file and all included files</string>
+         </property>
+         <property name="text" >
+          <string>Document</string>
+         </property>
+        </widget>
+        <widget class="QRadioButton" name="scopeRB_2" >
+         <property name="geometry" >
+          <rect>
+           <x>10</x>
+           <y>20</y>
+           <width>121</width>
+           <height>23</height>
+          </rect>
+         </property>
+         <property name="toolTip" >
+          <string>Current paragraph only</string>
+         </property>
+         <property name="text" >
+          <string>Paragraph</string>
+         </property>
+         <property name="checked" >
+          <bool>false</bool>
+         </property>
+        </widget>
+        <widget class="QRadioButton" name="scopeRB_4" >
+         <property name="geometry" >
+          <rect>
+           <x>10</x>
+           <y>80</y>
+           <width>121</width>
+           <height>23</height>
+          </rect>
+         </property>
+         <property name="toolTip" >
+          <string>All open buffers</string>
+         </property>
+         <property name="text" >
+          <string>Open buffers</string>
+         </property>
+        </widget>
+       </widget>
+      </item>
+      <item row="1" column="0" >
+       <widget class="QCheckBox" name="expandMacrosCB" >
+        <property name="enabled" >
+         <bool>false</bool>
+        </property>
+        <property name="text" >
+         <string>&amp;Expand macros</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </widget>
   </widget>
-  <zorder>layoutWidget</zorder>
-  <zorder>replace_work_area_</zorder>
-  <zorder>groupBox_3</zorder>
  </widget>
  <customwidgets>
   <customwidget>
Index: src/frontends/qt4/FindAndReplace.h
===================================================================
--- src/frontends/qt4/FindAndReplace.h	(revisione 27945)
+++ src/frontends/qt4/FindAndReplace.h	(copia locale)
@@ -30,12 +30,56 @@
 namespace lyx {
 namespace frontend {
 
-class FindAndReplace : public DockView, public Ui::FindAndReplaceUi
+class FindAndReplaceWidget : public QWidget, public Ui::FindAndReplaceUi
 {
 	Q_OBJECT
+
 public:
-	FindAndReplace(GuiView & parent);
+	FindAndReplaceWidget(GuiView & view);
+	bool initialiseParams(std::string const & params);
 
+private:
+	///
+	GuiView & view_;
+
+	// add a string to the combo if needed
+	void remember(std::string const & find, QComboBox & combo);
+	void findAdv(bool casesensitive,
+			bool matchword, bool backwards,
+			bool expandmacros, bool ignoreformat);
+	void find(docstring const & str, int len, bool casesens,
+		  bool words, bool backwards, bool expandmacros);
+	void find(bool backwards);
+
+	void replace(docstring const & findstr,
+		     docstring const & replacestr,
+		     bool casesens, bool words, bool backwards, bool expandmacros, bool all);
+	bool eventFilter(QObject *obj, QEvent *event);
+
+	void virtual showEvent(QShowEvent *ev);
+	void virtual hideEvent(QHideEvent *ev);
+
+protected Q_SLOTS:
+	void on_findNextPB_clicked();
+	void on_findPrevPB_clicked();
+	void on_replacePB_clicked();
+	void on_replaceallPB_clicked();
+	void on_closePB_clicked();
+	void on_regexpInsertCombo_currentIndexChanged(int index);
+};
+
+
+class FindAndReplace : public DockView
+{
+	Q_OBJECT
+public:
+	FindAndReplace(
+		GuiView & parent, ///< the main window where to dock.
+		Qt::DockWidgetArea area = Qt::RightDockWidgetArea, ///< Position of the dock (and also drawer)
+		Qt::WindowFlags flags = 0);
+
+	~FindAndReplace();
+
 	bool initialiseParams(std::string const &);
 	void clearParams() {}
 	void dispatchParams() {}
@@ -46,36 +90,12 @@
 	void updateView() {}
 	//virtual void update_contents() {}
 
-protected Q_SLOTS:
-	void on_findNextPB_clicked();
-	void on_findPrevPB_clicked();
-	void on_replacePB_clicked();
-	void on_replaceallPB_clicked();
-	void on_closePB_clicked();
-	void on_regexpInsertCombo_currentIndexChanged(int index);
-
 protected:
-	void find(bool backwards);
 	virtual bool wantInitialFocus() const { return true; }
 
 private:
-	// add a string to the combo if needed
-	void remember(std::string const & find, QComboBox & combo);
-	void findAdv(bool casesensitive,
-			bool matchword, bool backwards,
-			bool expandmacros, bool ignoreformat);
-
-private:
-	/// Apply changes
-	virtual void apply() {}
-
-	void find(docstring const & str, int len, bool casesens,
-		  bool words, bool backwards, bool expandmacros);
-
-	void replace(docstring const & findstr,
-		     docstring const & replacestr,
-		     bool casesens, bool words, bool backwards, bool expandmacros, bool all);
-	bool eventFilter(QObject *obj, QEvent *event);
+	/// The encapsulated widget.
+	FindAndReplaceWidget * widget_;
 };
 
 
Index: src/frontends/qt4/FindAndReplace.cpp
===================================================================
--- src/frontends/qt4/FindAndReplace.cpp	(revisione 27945)
+++ src/frontends/qt4/FindAndReplace.cpp	(copia locale)
@@ -43,21 +43,22 @@
 namespace lyx {
 namespace frontend {
 
-FindAndReplace::FindAndReplace(GuiView & parent)
-	: DockView(parent, "Find LyX", "Find LyX Dialog", Qt::RightDockWidgetArea)
+
+FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
+	:	view_(view)
 {
 	setupUi(this);
-	find_work_area_->setGuiView(parent);
+	find_work_area_->setGuiView(view_);
 	find_work_area_->init();
 	setFocusProxy(find_work_area_);
-	replace_work_area_->setGuiView(parent);
+	replace_work_area_->setGuiView(view_);
 	replace_work_area_->init();
 	// We don't want two cursors blinking.
 	replace_work_area_->stopBlinkingCursor();
 }
 
 
-bool FindAndReplace::eventFilter(QObject *obj, QEvent *event)
+bool FindAndReplaceWidget::eventFilter(QObject *obj, QEvent *event)
 {
 	LYXERR(Debug::DEBUG, "FindAndReplace::eventFilter()" << std::endl);
 	if (obj == find_work_area_ && event->type() == QEvent::KeyPress) {
@@ -76,11 +77,11 @@
 		}
 	}
 	// standard event processing
-	return QObject::eventFilter(obj, event);
+	return QWidget::eventFilter(obj, event);
 }
 
 
-void FindAndReplace::findAdv(bool casesensitive,
+void FindAndReplaceWidget::findAdv(bool casesensitive,
 		bool matchword, bool backwards,
 		bool expandmacros, bool ignoreformat)
 {
@@ -113,7 +114,7 @@
 		runparams.linelen = 100000; //lyxrc.plaintext_linelen;
 		runparams.dryrun = true;
 		for (; it != end; ++it) {
-			LYXERR0("Adding to search string: '" << it->asString(false) << "'");
+			LYXERR(Debug::DEBUG, "Adding to search string: '" << it->asString(false) << "'");
 			searchString += it->stringify(pos_type(0), it->size(), AS_STR_INSETS, runparams);
 		}
 	}
@@ -125,45 +126,33 @@
 	bool const regexp = to_utf8(searchString).find("\\regexp") != std::string::npos;
 	FindAdvOptions opt(searchString, casesensitive, matchword, ! backwards,
 		expandmacros, ignoreformat, regexp);
-	std::cerr << "Dispatching LFUN_WORD_FINDADV" << std::endl;
+	LYXERR(Debug::DEBUG, "Dispatching LFUN_WORD_FINDADV" << std::endl);
 	std::ostringstream oss;
 	oss << opt;
-	std::cerr << "Dispatching LFUN_WORD_FINDADV" << std::endl;
+	LYXERR(Debug::DEBUG, "Dispatching LFUN_WORD_FINDADV" << std::endl);
 	dispatch(FuncRequest(LFUN_WORD_FINDADV, from_utf8(oss.str())));
 
 	//	findAdv(&theApp()->currentView()->currentWorkArea()->bufferView(),
 	// 			searchString, len, casesensitive, matchword, ! backwards, expandmacros);
 }
 
-bool FindAndReplace::initialiseParams(std::string const &)
-{
-	find_work_area_->redraw();
-	replace_work_area_->setEnabled(true);
-	replace_work_area_->redraw();
-	find_work_area_->setFocus();
-	dispatch(FuncRequest(LFUN_BUFFER_BEGIN));
-	dispatch(FuncRequest(LFUN_BUFFER_END_SELECT));
-	return true;
-}
 
-
-void FindAndReplace::find(bool backwards)
+void FindAndReplaceWidget::find(bool backwards)
 {
 	// FIXME: create a Dialog::returnFocus() or something instead of this:
-	GuiView & gv = const_cast<GuiView &>(lyxview());
-	gv.setCurrentWorkArea(gv.currentMainWorkArea());
+	view_.setCurrentWorkArea(view_.currentMainWorkArea());
 	// FIXME: This should be an LFUN.
 	findAdv(caseCB->isChecked(),
 			wordsCB->isChecked(),
 			backwards,
 			expandMacrosCB->isChecked(),
 			ignoreFormatCB->isChecked());
-	gv.currentMainWorkArea()->redraw();
+	view_.currentMainWorkArea()->redraw();
 	find_work_area_->setFocus();
 }
 
 
-void FindAndReplace::on_regexpInsertCombo_currentIndexChanged(int index)
+void FindAndReplaceWidget::on_regexpInsertCombo_currentIndexChanged(int index)
 {
 	static char const * regexps[] = {
 		".*", ".+", "[a-z]+", "[0-9]+"
@@ -180,34 +169,89 @@
 }
 
 
-void FindAndReplace::on_closePB_clicked()
+void FindAndReplaceWidget::on_closePB_clicked()
 {
 	dispatch(FuncRequest(LFUN_DIALOG_TOGGLE, "findreplaceadv"));
 }
 
 
-void FindAndReplace::on_findNextPB_clicked() {
+void FindAndReplaceWidget::on_findNextPB_clicked() {
 	find(false);
 }
 
 
-void FindAndReplace::on_findPrevPB_clicked() {
+void FindAndReplaceWidget::on_findPrevPB_clicked() {
 	find(true);
 }
 
 
-void FindAndReplace::on_replacePB_clicked()
+void FindAndReplaceWidget::on_replacePB_clicked()
 {
 }
 
 
-void FindAndReplace::on_replaceallPB_clicked()
+void FindAndReplaceWidget::on_replaceallPB_clicked()
 {
 }
 
+
+void FindAndReplaceWidget::showEvent(QShowEvent *ev)
+{
+	replace_work_area_->setEnabled(true);
+	replace_work_area_->redraw();
+	find_work_area_->setFocus();
+	dispatch(FuncRequest(LFUN_BUFFER_BEGIN));
+	dispatch(FuncRequest(LFUN_BUFFER_END_SELECT));
+	find_work_area_->redraw();
+	find_work_area_->installEventFilter(this);
+}
+
+
+void FindAndReplaceWidget::hideEvent(QHideEvent *ev)
+{
+	find_work_area_->removeEventFilter(this);
+	this->QWidget::hideEvent(ev);
+}
+
+
+bool FindAndReplaceWidget::initialiseParams(std::string const & params)
+{
+	find_work_area_->redraw();
+	replace_work_area_->setEnabled(true);
+	replace_work_area_->redraw();
+	find_work_area_->setFocus();
+	dispatch(FuncRequest(LFUN_BUFFER_BEGIN));
+	dispatch(FuncRequest(LFUN_BUFFER_END_SELECT));
+	return true;
+}
+
+
+FindAndReplace::FindAndReplace(GuiView & parent,
+		Qt::DockWidgetArea area, Qt::WindowFlags flags)
+	: DockView(parent, "Find LyX", qt_("Find LyX Dialog"), area, flags)
+{
+	widget_ = new FindAndReplaceWidget(parent);
+	setWidget(widget_);
+	setFocusProxy(widget_);
+}
+
+
+FindAndReplace::~FindAndReplace()
+{
+	setFocusProxy(0);
+	delete widget_;
+}
+
+
+bool FindAndReplace::initialiseParams(std::string const & params)
+{
+	return widget_->initialiseParams(params);
+}
+
+
 Dialog * createGuiSearchAdv(GuiView & lv)
 {
-	return new FindAndReplace(lv);
+	return new FindAndReplace(lv, Qt::RightDockWidgetArea);
 }
 
 

Proprietà modificate su: src/support
___________________________________________________________________
Modified: svn:ignore
   - Makefile.in
Makefile
*.deps
*.lo
libsupport.la
.libs
path_defines.C
pch.h.gch
pch.h.gch.dep
package.C
   + Makefile.in
Makefile
*.deps
*.lo
libsupport.la
.libs
path_defines.C
pch.h.gch
pch.h.gch.dep
package.C
moc_*.cpp


Reply via email to