]> git.lyx.org Git - features.git/commitdiff
simplify adv search/replace layout
authorEdwin Leuven <e.leuven@gmail.com>
Thu, 25 Mar 2010 16:57:39 +0000 (16:57 +0000)
committerEdwin Leuven <e.leuven@gmail.com>
Thu, 25 Mar 2010 16:57:39 +0000 (16:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33867 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/FindAndReplace.cpp
src/frontends/qt4/FindAndReplace.h
src/frontends/qt4/ui/FindAndReplaceUi.ui

index 85c2ddea867101fdd9597a1e270ae5fa8910e36d..bd4bb303c08420e4c4014b6a1430a3f43727a4ad 100644 (file)
@@ -96,22 +96,21 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
                break;
 
        case Qt::Key_Enter:
-       case Qt::Key_Return:
-               if (e->modifiers() == Qt::ShiftModifier) {
-                       if (obj == find_work_area_)
-                               on_findPrevPB_clicked();
-                       else
-                               on_replacePrevPB_clicked();
-                       return true;
-               } else if (e->modifiers() == Qt::NoModifier) {
-                       if (obj == find_work_area_)
-                               on_findNextPB_clicked();
-                       else
-                               on_replaceNextPB_clicked();
-                       return true;
-               }
+       case Qt::Key_Return: {
+               // with shift we (temporarily) change search/replace direction
+               bool const searchback = searchbackCB->isChecked();
+               if (e->modifiers() == Qt::ShiftModifier && !searchback)
+                       searchbackCB->setChecked(!searchback);
+
+               if (obj == find_work_area_)
+                       on_findNextPB_clicked();
+               else
+                       on_replacePB_clicked();
+               // back to how it was
+               searchbackCB->setChecked(searchback);
+               return true;
                break;
-
+               }
        case Qt::Key_Tab:
                if (e->modifiers() == Qt::NoModifier) {
                        if (obj == find_work_area_){
@@ -532,28 +531,16 @@ void FindAndReplaceWidget::hideDialog()
 }
 
 
-void FindAndReplaceWidget::on_findNextPB_clicked() {
-       findAndReplace(false, false);
-       find_work_area_->setFocus();
-}
-
-
-void FindAndReplaceWidget::on_findPrevPB_clicked() {
-       findAndReplace(true, false);
-       find_work_area_->setFocus();
-}
-
-
-void FindAndReplaceWidget::on_replaceNextPB_clicked()
+void FindAndReplaceWidget::on_findNextPB_clicked() 
 {
-       findAndReplace(false, true);
-       replace_work_area_->setFocus();
+       findAndReplace(searchbackCB->isChecked(), false);
+       find_work_area_->setFocus();
 }
 
 
-void FindAndReplaceWidget::on_replacePrevPB_clicked()
+void FindAndReplaceWidget::on_replacePB_clicked()
 {
-       findAndReplace(true, true);
+       findAndReplace(searchbackCB->isChecked(), true);
        replace_work_area_->setFocus();
 }
 
index ffdf79b00ea6f50731cdf9fff2057e685e10fb34..3bb2b44394a7c95ce43ebc20f74bc1cf64259e84 100644 (file)
@@ -67,9 +67,7 @@ private:
 
 protected Q_SLOTS:
        void on_findNextPB_clicked();
-       void on_findPrevPB_clicked();
-       void on_replaceNextPB_clicked();
-       void on_replacePrevPB_clicked();
+       void on_replacePB_clicked();
        void on_replaceallPB_clicked();
        void insertRegexp(QAction *);
 };
index b19382a607aa7d50012e025c10d659ddf52590ec..457b04f34913c0665f0b71b6394fe1d0be5f467a 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>288</width>
-    <height>366</height>
+    <width>247</width>
+    <height>341</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -63,7 +63,7 @@
          </property>
         </widget>
        </item>
-       <item row="1" column="0" colspan="2">
+       <item row="1" column="0" colspan="3">
         <widget class="lyx::frontend::EmbeddedWorkArea" name="find_work_area_">
          <property name="toolTip">
           <string>Enter the text to search for in this full-featured LyX editing area</string>
             <height>57</height>
            </rect>
           </property>
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
          </widget>
         </widget>
        </item>
        <item row="2" column="0">
-        <widget class="QCheckBox" name="caseCB">
-         <property name="toolTip">
-          <string>Perform a case-sensitive search</string>
-         </property>
-         <property name="text">
-          <string>Case &amp;sensitive</string>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="1">
-        <widget class="QCheckBox" name="wordsCB">
-         <property name="enabled">
-          <bool>true</bool>
-         </property>
-         <property name="toolTip">
-          <string>Restrict search to whole words only</string>
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
          </property>
-         <property name="text">
-          <string>Whole &amp;words</string>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>52</width>
+           <height>20</height>
+          </size>
          </property>
-        </widget>
+        </spacer>
        </item>
-       <item row="3" column="0" colspan="2">
+       <item row="2" column="1" colspan="2">
         <widget class="QPushButton" name="regexpInsertPB">
          <property name="toolTip">
           <string>Choose one of the pre-arranged regular expressions.</string>
          </property>
         </widget>
        </item>
-       <item row="4" column="0">
+       <item row="3" column="0" colspan="2">
         <widget class="QLabel" name="label_2">
          <property name="text">
           <string>&amp;Replace with:</string>
          </property>
         </widget>
        </item>
-       <item row="5" column="0" colspan="2">
+       <item row="4" column="0" colspan="3">
         <widget class="lyx::frontend::EmbeddedWorkArea" name="replace_work_area_">
          <property name="toolTip">
           <string>Enter the text to replace in this full-featured LyX editing area</string>
             <height>57</height>
            </rect>
           </property>
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
          </widget>
         </widget>
        </item>
+       <item row="5" column="0" colspan="2">
+        <widget class="QCheckBox" name="caseCB">
+         <property name="toolTip">
+          <string>Perform a case-sensitive search</string>
+         </property>
+         <property name="text">
+          <string>Case &amp;sensitive</string>
+         </property>
+        </widget>
+       </item>
+       <item row="5" column="2">
+        <widget class="QPushButton" name="findNextPB">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="toolTip">
+          <string>Find next occurrence [Enter]</string>
+         </property>
+         <property name="text">
+          <string>Find &amp;Next</string>
+         </property>
+         <property name="default">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
        <item row="6" column="0" colspan="2">
-        <layout class="QGridLayout" name="gridLayout_2">
-         <item row="0" column="0">
-          <widget class="QPushButton" name="findPrevPB">
-           <property name="enabled">
-            <bool>true</bool>
-           </property>
-           <property name="toolTip">
-            <string>Find previous occurrence [Shift+Enter]</string>
-           </property>
-           <property name="text">
-            <string>Find &amp;Previous</string>
-           </property>
-           <property name="default">
-            <bool>true</bool>
-           </property>
-          </widget>
-         </item>
-         <item row="0" column="1">
-          <widget class="QPushButton" name="findNextPB">
-           <property name="enabled">
-            <bool>true</bool>
-           </property>
-           <property name="toolTip">
-            <string>Find next occurrence [Enter]</string>
-           </property>
-           <property name="text">
-            <string>Find &amp;Next</string>
-           </property>
-           <property name="default">
-            <bool>true</bool>
-           </property>
-          </widget>
-         </item>
-         <item row="1" column="0">
-          <widget class="QPushButton" name="replacePrevPB">
-           <property name="enabled">
-            <bool>true</bool>
-           </property>
-           <property name="toolTip">
-            <string>Replace and find previous occurrence [Shift+Enter]</string>
-           </property>
-           <property name="text">
-            <string>Replace Pre&amp;vious</string>
-           </property>
-          </widget>
-         </item>
-         <item row="1" column="1">
-          <widget class="QPushButton" name="replaceNextPB">
-           <property name="enabled">
-            <bool>true</bool>
-           </property>
-           <property name="toolTip">
-            <string>Replace and find next occurrence [Enter]</string>
-           </property>
-           <property name="text">
-            <string>Replace Ne&amp;xt</string>
-           </property>
-          </widget>
-         </item>
-         <item row="2" column="1">
-          <widget class="QPushButton" name="replaceallPB">
-           <property name="enabled">
-            <bool>false</bool>
-           </property>
-           <property name="toolTip">
-            <string>Replace all occurences at once</string>
-           </property>
-           <property name="text">
-            <string>Replace &amp;All</string>
-           </property>
-          </widget>
-         </item>
-        </layout>
+        <widget class="QCheckBox" name="wordsCB">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="toolTip">
+          <string>Restrict search to whole words only</string>
+         </property>
+         <property name="text">
+          <string>Whole &amp;words</string>
+         </property>
+        </widget>
+       </item>
+       <item row="6" column="2">
+        <widget class="QPushButton" name="replacePB">
+         <property name="enabled">
+          <bool>true</bool>
+         </property>
+         <property name="toolTip">
+          <string>Replace and find next occurrence [Enter]</string>
+         </property>
+         <property name="text">
+          <string>&amp;Replace</string>
+         </property>
+        </widget>
+       </item>
+       <item row="7" column="0" colspan="2">
+        <widget class="QCheckBox" name="searchbackCB">
+         <property name="text">
+          <string>Search backwards</string>
+         </property>
+        </widget>
+       </item>
+       <item row="7" column="2">
+        <widget class="QPushButton" name="replaceallPB">
+         <property name="enabled">
+          <bool>false</bool>
+         </property>
+         <property name="toolTip">
+          <string>Replace all occurences at once</string>
+         </property>
+         <property name="text">
+          <string>Replace &amp;All</string>
+         </property>
+        </widget>
        </item>
       </layout>
      </widget>