]> git.lyx.org Git - features.git/commitdiff
* FindAndReplace{cpp,h,Ui.ui}: some UI plishment.
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 25 Jan 2010 06:58:54 +0000 (06:58 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 25 Jan 2010 06:58:54 +0000 (06:58 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33217 a592a061-630c-0410-9148-cb99ea01b6c8

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

index 4f4649a2e431dae12955af67d4289edcd5822e1a..b01e46d9970d900a071581416f4c314adb637595 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <QCloseEvent>
 #include <QLineEdit>
+#include <QMenu>
 
 #include <iostream>
 
@@ -62,6 +63,21 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
        replace_work_area_->init();
        // We don't want two cursors blinking.
        replace_work_area_->stopBlinkingCursor();
+
+       QMenu * menu = new QMenu();
+       QAction * regAny = menu->addAction("&Anything");
+       regAny->setData(".*");
+       QAction * regAnyNonEmpty = menu->addAction("Any non-&empty");
+       regAnyNonEmpty->setData(".+");
+       QAction * regAnyWord = menu->addAction("Any &word");
+       regAnyWord->setData("[a-z]+");
+       QAction * regAnyNumber = menu->addAction("Any &number");
+       regAnyNumber->setData("[0-9]+");
+       QAction * regCustom = menu->addAction("&User-defined");
+       regCustom->setData("");
+       regexpInsertPB->setMenu(menu);
+
+       connect(menu, SIGNAL(triggered(QAction *)), this, SLOT(insertRegexp(QAction *)));
 }
 
 
@@ -457,20 +473,15 @@ void FindAndReplaceWidget::findAndReplace(bool backwards, bool replace)
 }
 
 
-void FindAndReplaceWidget::on_regexpInsertCombo_currentIndexChanged(int index)
+void FindAndReplaceWidget::insertRegexp(QAction * action)
 {
-       static char const * regexps[] = {
-               ".*", ".+", "[a-z]+", "[0-9]+", ""
-       };
-       LYXERR(Debug::FIND, "Index: " << index);
-       if (index >= 1 && index < 1 + int(sizeof(regexps)/sizeof(regexps[0]))) {
-               find_work_area_->setFocus();
-               Cursor & cur = find_work_area_->bufferView().cursor();
-               if (! cur.inRegexped())
-                       dispatch(FuncRequest(LFUN_REGEXP_MODE));
-               dispatch(FuncRequest(LFUN_SELF_INSERT, regexps[index - 1]));
-               regexpInsertCombo->setCurrentIndex(0);
-       }
+       string const regexp = fromqstr(action->data().toString());
+       LYXERR(Debug::FIND, "Regexp: " << regexp);
+       find_work_area_->setFocus();
+       Cursor & cur = find_work_area_->bufferView().cursor();
+       if (!cur.inRegexped())
+               dispatch(FuncRequest(LFUN_REGEXP_MODE));
+       dispatch(FuncRequest(LFUN_SELF_INSERT, regexp));
 }
 
 
@@ -539,7 +550,7 @@ bool FindAndReplaceWidget::initialiseParams(std::string const & /* params */)
 
 FindAndReplace::FindAndReplace(GuiView & parent,
                Qt::DockWidgetArea area, Qt::WindowFlags flags)
-       : DockView(parent, "Find LyX", qt_("Find LyX Dialog"), area, flags)
+       : DockView(parent, "Find LyX", qt_("Advanced Find and Replace"), area, flags)
 {
        widget_ = new FindAndReplaceWidget(parent);
        setWidget(widget_);
index e940606f351ebba7dc485d117c7ad82e6859c445..b4bc3e1a8472947eec0099782215bffbbcb7edc7 100644 (file)
@@ -71,7 +71,7 @@ protected Q_SLOTS:
        void on_replacePrevPB_clicked();
        void on_replaceallPB_clicked();
        void on_closePB_clicked();
-       void on_regexpInsertCombo_currentIndexChanged(int index);
+       void insertRegexp(QAction *);
 };
 
 
index fb9470b019627affae6970d0972bfa67aeeef10f..999f2079d38d94fcede845253ea37b15223012f2 100644 (file)
                    </widget>
                   </widget>
                  </item>
-                 <item row="2" column="0">
+                 <item row="2" column="1">
                   <widget class="QPushButton" name="replaceNextPB">
                    <property name="enabled">
                     <bool>true</bool>
                     <string>Find next occurrence and replace it [Enter]</string>
                    </property>
                    <property name="text">
-                    <string>Next</string>
+                    <string>Ne&amp;xt</string>
                    </property>
                   </widget>
                  </item>
-                 <item row="2" column="1">
+                 <item row="2" column="0">
                   <widget class="QPushButton" name="replacePrevPB">
                    <property name="enabled">
                     <bool>true</bool>
                     <string>Find previous occurrence and replace it [Shift+Enter]</string>
                    </property>
                    <property name="text">
-                    <string>Prev</string>
+                    <string>Pre&amp;vious</string>
                    </property>
                   </widget>
                  </item>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    </property>
+                   <property name="toolTip">
+                    <string>Replace all occurences at once</string>
+                   </property>
                    <property name="text">
                     <string>Replace &amp;All</string>
                    </property>
                   </widget>
                  </item>
                  <item row="3" column="0" colspan="2">
-                  <widget class="QComboBox" name="regexpInsertCombo">
-                   <property name="enabled">
-                    <bool>true</bool>
-                   </property>
+                  <widget class="QPushButton" name="regexpInsertPB">
                    <property name="sizePolicy">
                     <sizepolicy>
-                     <hsizetype>7</hsizetype>
-                     <vsizetype>1</vsizetype>
+                     <hsizetype>3</hsizetype>
+                     <vsizetype>0</vsizetype>
                      <horstretch>0</horstretch>
                      <verstretch>0</verstretch>
                     </sizepolicy>
                    <property name="toolTip">
                     <string>Choose one of the pre-arranged regular expressions.</string>
                    </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>
-                   <item>
-                    <property name="text">
-                     <string>User-defined</string>
-                    </property>
-                   </item>
+                   <property name="text">
+                    <string>Insert Re&amp;gular Expression...</string>
+                   </property>
                   </widget>
                  </item>
-                 <item row="4" column="0">
+                 <item row="4" column="1">
                   <widget class="QPushButton" name="findNextPB">
                    <property name="enabled">
                     <bool>true</bool>
                     <string>Find next occurrence [Enter]</string>
                    </property>
                    <property name="text">
-                    <string>Next</string>
+                    <string>&amp;Next</string>
                    </property>
                    <property name="default">
                     <bool>true</bool>
                    </property>
                   </widget>
                  </item>
-                 <item row="4" column="1">
+                 <item row="4" column="0">
                   <widget class="QPushButton" name="findPrevPB">
                    <property name="enabled">
                     <bool>true</bool>
                     <string>Find previous occurrence [Shift+Enter]</string>
                    </property>
                    <property name="text">
-                    <string>Prev</string>
+                    <string>&amp;Previous</string>
                    </property>
                    <property name="default">
                     <bool>true</bool>