From 138a4f8e9c811bc7db5a7e3dc02000aca7b9e4fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Mon, 25 Jan 2010 06:58:54 +0000 Subject: [PATCH] * 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 --- src/frontends/qt4/FindAndReplace.cpp | 39 +++++++++------ src/frontends/qt4/FindAndReplace.h | 2 +- src/frontends/qt4/ui/FindAndReplaceUi.ui | 61 +++++++----------------- 3 files changed, 43 insertions(+), 59 deletions(-) diff --git a/src/frontends/qt4/FindAndReplace.cpp b/src/frontends/qt4/FindAndReplace.cpp index 4f4649a2e4..b01e46d997 100644 --- a/src/frontends/qt4/FindAndReplace.cpp +++ b/src/frontends/qt4/FindAndReplace.cpp @@ -38,6 +38,7 @@ #include #include +#include #include @@ -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_); diff --git a/src/frontends/qt4/FindAndReplace.h b/src/frontends/qt4/FindAndReplace.h index e940606f35..b4bc3e1a84 100644 --- a/src/frontends/qt4/FindAndReplace.h +++ b/src/frontends/qt4/FindAndReplace.h @@ -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 *); }; diff --git a/src/frontends/qt4/ui/FindAndReplaceUi.ui b/src/frontends/qt4/ui/FindAndReplaceUi.ui index fb9470b019..999f2079d3 100644 --- a/src/frontends/qt4/ui/FindAndReplaceUi.ui +++ b/src/frontends/qt4/ui/FindAndReplaceUi.ui @@ -205,7 +205,7 @@ - + true @@ -222,11 +222,11 @@ Find next occurrence and replace it [Enter] - Next + Ne&xt - + true @@ -243,7 +243,7 @@ Find previous occurrence and replace it [Shift+Enter] - Prev + Pre&vious @@ -260,6 +260,9 @@ 0 + + Replace all occurences at once + Replace &All @@ -424,14 +427,11 @@ - - - true - + - 7 - 1 + 3 + 0 0 0 @@ -439,39 +439,12 @@ Choose one of the pre-arranged regular expressions. - - - Match... - - - - - Anything - - - - - Any non-empty - - - - - Any word - - - - - Any number - - - - - User-defined - - + + Insert Re&gular Expression... + - + true @@ -488,14 +461,14 @@ Find next occurrence [Enter] - Next + &Next true - + true @@ -512,7 +485,7 @@ Find previous occurrence [Shift+Enter] - Prev + &Previous true