adv search/replace: move insert regexp to context menu

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33871 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Edwin Leuven 2010-03-26 14:46:51 +00:00
parent 1e4ccc2d22
commit b768107db9
4 changed files with 28 additions and 59 deletions

View File

@ -308,6 +308,7 @@ Menuset
OptItem "Move Section Down|D" "outline-down"
OptItem "Move Section Up|U" "outline-up"
OptItem "Insert Short Title|T" "optional-insert"
OptSubMenu "Insert Regular Expression..." "context-edit-regexp"
Separator
OptItem "Accept Change|c" "change-accept"
OptItem "Reject Change|j" "change-reject"
@ -320,6 +321,19 @@ Menuset
Item "Fullscreen Mode" "ui-toggle fullscreen"
End
#
# Regular Expression context menu
#
Menu "context-edit-regexp"
Item "Anything|A" "command-sequence regexp-mode; self-insert .*"
Item "Anything Non-Empty|o" "command-sequence regexp-mode; self-insert .+"
Item "Any Word|W" "command-sequence regexp-mode; self-insert [a-z]+"
Item "Any Number|N" "command-sequence regexp-mode; self-insert [0-9]+"
Item "User Defined|U" "regexp-mode"
End
#
# Math Macro context menu
#

View File

@ -62,21 +62,6 @@ FindAndReplaceWidget::FindAndReplaceWidget(GuiView & view)
replace_work_area_->setFrameStyle(QFrame::StyledPanel);
// We don't want two cursors blinking.
replace_work_area_->stopBlinkingCursor();
QMenu * menu = new QMenu();
QAction * regAny = menu->addAction(qt_("&Anything"));
regAny->setData(".*");
QAction * regAnyNonEmpty = menu->addAction(qt_("Any non-&empty"));
regAnyNonEmpty->setData(".+");
QAction * regAnyWord = menu->addAction(qt_("Any &word"));
regAnyWord->setData("[a-z]+");
QAction * regAnyNumber = menu->addAction(qt_("Any &number"));
regAnyNumber->setData("[0-9]+");
QAction * regCustom = menu->addAction(qt_("&User-defined"));
regCustom->setData("");
regexpInsertPB->setMenu(menu);
connect(menu, SIGNAL(triggered(QAction *)),
this, SLOT(insertRegexp(QAction *)));
}
@ -513,18 +498,6 @@ void FindAndReplaceWidget::findAndReplace(bool backwards, bool replace)
}
void FindAndReplaceWidget::insertRegexp(QAction * action)
{
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));
}
void FindAndReplaceWidget::hideDialog()
{
dispatch(FuncRequest(LFUN_DIALOG_TOGGLE, "findreplaceadv"));

View File

@ -69,7 +69,6 @@ protected Q_SLOTS:
void on_findNextPB_clicked();
void on_replacePB_clicked();
void on_replaceallPB_clicked();
void insertRegexp(QAction *);
};

View File

@ -63,7 +63,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<item row="1" column="0" colspan="2">
<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>
@ -81,29 +81,6 @@
</widget>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>52</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<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>
<property name="text">
<string>Insert Re&amp;gular Expression...</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Replace with:</string>
@ -113,7 +90,7 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<item row="3" column="0" colspan="2">
<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>
@ -130,8 +107,14 @@
</widget>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="4" column="0">
<widget class="QCheckBox" name="caseCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Perform a case-sensitive search</string>
</property>
@ -140,7 +123,7 @@
</property>
</widget>
</item>
<item row="5" column="2">
<item row="4" column="1">
<widget class="QPushButton" name="findNextPB">
<property name="enabled">
<bool>true</bool>
@ -156,7 +139,7 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="5" column="0">
<widget class="QCheckBox" name="wordsCB">
<property name="enabled">
<bool>true</bool>
@ -169,7 +152,7 @@
</property>
</widget>
</item>
<item row="6" column="2">
<item row="5" column="1">
<widget class="QPushButton" name="replacePB">
<property name="enabled">
<bool>true</bool>
@ -182,14 +165,14 @@
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="6" column="0">
<widget class="QCheckBox" name="searchbackCB">
<property name="text">
<string>Search backwards</string>
</property>
</widget>
</item>
<item row="7" column="2">
<item row="6" column="1">
<widget class="QPushButton" name="replaceallPB">
<property name="enabled">
<bool>false</bool>