mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
* 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:
parent
f3d50cd4a5
commit
138a4f8e9c
@ -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]))) {
|
||||
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, regexps[index - 1]));
|
||||
regexpInsertCombo->setCurrentIndex(0);
|
||||
}
|
||||
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_);
|
||||
|
@ -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 *);
|
||||
};
|
||||
|
||||
|
||||
|
@ -205,7 +205,7 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="replaceNextPB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -222,11 +222,11 @@
|
||||
<string>Find next occurrence and replace it [Enter]</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
<string>Ne&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>
|
||||
@ -243,7 +243,7 @@
|
||||
<string>Find previous occurrence and replace it [Shift+Enter]</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prev</string>
|
||||
<string>Pre&vious</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -260,6 +260,9 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Replace all occurences at once</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Replace &All</string>
|
||||
</property>
|
||||
@ -424,14 +427,11 @@
|
||||
</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>
|
||||
@ -439,39 +439,12 @@
|
||||
<property name="toolTip">
|
||||
<string>Choose one of the pre-arranged regular expressions.</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Match...</string>
|
||||
<string>Insert Re&gular Expression...</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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="findNextPB">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -488,14 +461,14 @@
|
||||
<string>Find next occurrence [Enter]</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
<string>&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>
|
||||
@ -512,7 +485,7 @@
|
||||
<string>Find previous occurrence [Shift+Enter]</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prev</string>
|
||||
<string>&Previous</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
|
Loading…
Reference in New Issue
Block a user