* FindAndReplace{cpp,h,Ui.ui}: some UI plishment.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33217 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-01-25 06:58:54 +00:00
parent f3d50cd4a5
commit 138a4f8e9c
3 changed files with 43 additions and 59 deletions

View File

@ -38,6 +38,7 @@
#include <QCloseEvent> #include <QCloseEvent>
#include <QLineEdit> #include <QLineEdit>
#include <QMenu>
#include <iostream> #include <iostream>
@ -62,6 +63,21 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
replace_work_area_->init(); replace_work_area_->init();
// We don't want two cursors blinking. // We don't want two cursors blinking.
replace_work_area_->stopBlinkingCursor(); 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[] = { string const regexp = fromqstr(action->data().toString());
".*", ".+", "[a-z]+", "[0-9]+", "" LYXERR(Debug::FIND, "Regexp: " << regexp);
};
LYXERR(Debug::FIND, "Index: " << index);
if (index >= 1 && index < 1 + int(sizeof(regexps)/sizeof(regexps[0]))) {
find_work_area_->setFocus(); find_work_area_->setFocus();
Cursor & cur = find_work_area_->bufferView().cursor(); Cursor & cur = find_work_area_->bufferView().cursor();
if (!cur.inRegexped()) if (!cur.inRegexped())
dispatch(FuncRequest(LFUN_REGEXP_MODE)); dispatch(FuncRequest(LFUN_REGEXP_MODE));
dispatch(FuncRequest(LFUN_SELF_INSERT, regexps[index - 1])); dispatch(FuncRequest(LFUN_SELF_INSERT, regexp));
regexpInsertCombo->setCurrentIndex(0);
}
} }
@ -539,7 +550,7 @@ bool FindAndReplaceWidget::initialiseParams(std::string const & /* params */)
FindAndReplace::FindAndReplace(GuiView & parent, FindAndReplace::FindAndReplace(GuiView & parent,
Qt::DockWidgetArea area, Qt::WindowFlags flags) 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); widget_ = new FindAndReplaceWidget(parent);
setWidget(widget_); setWidget(widget_);

View File

@ -71,7 +71,7 @@ protected Q_SLOTS:
void on_replacePrevPB_clicked(); void on_replacePrevPB_clicked();
void on_replaceallPB_clicked(); void on_replaceallPB_clicked();
void on_closePB_clicked(); void on_closePB_clicked();
void on_regexpInsertCombo_currentIndexChanged(int index); void insertRegexp(QAction *);
}; };

View File

@ -205,7 +205,7 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="1">
<widget class="QPushButton" name="replaceNextPB"> <widget class="QPushButton" name="replaceNextPB">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -222,11 +222,11 @@
<string>Find next occurrence and replace it [Enter]</string> <string>Find next occurrence and replace it [Enter]</string>
</property> </property>
<property name="text"> <property name="text">
<string>Next</string> <string>Ne&amp;xt</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="0">
<widget class="QPushButton" name="replacePrevPB"> <widget class="QPushButton" name="replacePrevPB">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -243,7 +243,7 @@
<string>Find previous occurrence and replace it [Shift+Enter]</string> <string>Find previous occurrence and replace it [Shift+Enter]</string>
</property> </property>
<property name="text"> <property name="text">
<string>Prev</string> <string>Pre&amp;vious</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -260,6 +260,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip">
<string>Replace all occurences at once</string>
</property>
<property name="text"> <property name="text">
<string>Replace &amp;All</string> <string>Replace &amp;All</string>
</property> </property>
@ -424,14 +427,11 @@
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="3" column="0" colspan="2">
<widget class="QComboBox" name="regexpInsertCombo"> <widget class="QPushButton" name="regexpInsertPB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy> <sizepolicy>
<hsizetype>7</hsizetype> <hsizetype>3</hsizetype>
<vsizetype>1</vsizetype> <vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -439,39 +439,12 @@
<property name="toolTip"> <property name="toolTip">
<string>Choose one of the pre-arranged regular expressions.</string> <string>Choose one of the pre-arranged regular expressions.</string>
</property> </property>
<item>
<property name="text"> <property name="text">
<string>Match...</string> <string>Insert Re&amp;gular Expression...</string>
</property> </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>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="1">
<widget class="QPushButton" name="findNextPB"> <widget class="QPushButton" name="findNextPB">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -488,14 +461,14 @@
<string>Find next occurrence [Enter]</string> <string>Find next occurrence [Enter]</string>
</property> </property>
<property name="text"> <property name="text">
<string>Next</string> <string>&amp;Next</string>
</property> </property>
<property name="default"> <property name="default">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="0">
<widget class="QPushButton" name="findPrevPB"> <widget class="QPushButton" name="findPrevPB">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -512,7 +485,7 @@
<string>Find previous occurrence [Shift+Enter]</string> <string>Find previous occurrence [Shift+Enter]</string>
</property> </property>
<property name="text"> <property name="text">
<string>Prev</string> <string>&amp;Previous</string>
</property> </property>
<property name="default"> <property name="default">
<bool>true</bool> <bool>true</bool>