git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20801 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-10-06 20:54:31 +00:00
parent e117f67786
commit f5eb303b4b
5 changed files with 52 additions and 47 deletions

View File

@ -27,7 +27,6 @@
#include "GuiParagraph.h"
#include "GuiPrefs.h"
#include "GuiPrint.h"
#include "GuiSearch.h"
#include "GuiShowFile.h"
#include "GuiView.h"
#include "TocWidget.h"
@ -165,7 +164,7 @@ Dialog * Dialogs::build(string const & name)
if (name == "file")
return createGuiShowFile(lyxview_);
if (name == "findreplace")
return new GuiSearchDialog(lyxview_);
return createGuiSearch(lyxview_);
if (name == "float")
return createGuiFloat(lyxview_);
if (name == "graphics")

View File

@ -5,6 +5,7 @@
*
* \author John Levon
* \author Edwin Leuven
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
@ -13,7 +14,9 @@
#include "GuiSearch.h"
#include "ControlSearch.h"
#include "FuncRequest.h"
#include "lyxfind.h"
#include "qt_helpers.h"
#include <QLineEdit>
@ -36,11 +39,11 @@ static void uniqueInsert(QComboBox * box, QString const & text)
}
GuiSearchDialog::GuiSearchDialog(LyXView & lv)
: GuiDialog(lv, "findreplace")
GuiSearch::GuiSearch(LyXView & lv)
: GuiDialog(lv, "findreplace"), Controller(this)
{
setupUi(this);
setController(new ControlSearch(*this));
setController(this, false);
setViewTitle(_("Find and Replace"));
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
@ -63,27 +66,21 @@ GuiSearchDialog::GuiSearchDialog(LyXView & lv)
}
ControlSearch & GuiSearchDialog::controller()
{
return static_cast<ControlSearch &>(GuiDialog::controller());
}
void GuiSearchDialog::showView()
void GuiSearch::showView()
{
findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
GuiDialog::showView();
}
void GuiSearchDialog::closeEvent(QCloseEvent * e)
void GuiSearch::closeEvent(QCloseEvent * e)
{
slotClose();
GuiDialog::closeEvent(e);
}
void GuiSearchDialog::findChanged()
void GuiSearch::findChanged()
{
if (findCO->currentText().isEmpty()) {
findPB->setEnabled(false);
@ -97,52 +94,59 @@ void GuiSearchDialog::findChanged()
}
void GuiSearchDialog::findClicked()
void GuiSearch::findClicked()
{
docstring const needle = qstring_to_ucs4(findCO->currentText());
find(needle, caseCB->isChecked(), wordsCB->isChecked(),
backwardsCB->isChecked());
!backwardsCB->isChecked());
uniqueInsert(findCO, findCO->currentText());
findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
}
void GuiSearchDialog::replaceClicked()
void GuiSearch::replaceClicked()
{
docstring const needle = qstring_to_ucs4(findCO->currentText());
docstring const repl = qstring_to_ucs4(replaceCO->currentText());
replace(needle, repl, caseCB->isChecked(), wordsCB->isChecked(),
backwardsCB->isChecked(), false);
!backwardsCB->isChecked(), false);
uniqueInsert(findCO, findCO->currentText());
uniqueInsert(replaceCO, replaceCO->currentText());
}
void GuiSearchDialog::replaceallClicked()
void GuiSearch::replaceallClicked()
{
replace(qstring_to_ucs4(findCO->currentText()),
qstring_to_ucs4(replaceCO->currentText()),
caseCB->isChecked(), wordsCB->isChecked(), false, true);
caseCB->isChecked(), wordsCB->isChecked(), true, true);
uniqueInsert(findCO, findCO->currentText());
uniqueInsert(replaceCO, replaceCO->currentText());
}
void GuiSearchDialog::find(docstring const & str, bool casesens,
bool words, bool backwards)
void GuiSearch::find(docstring const & search, bool casesensitive,
bool matchword, bool forward)
{
controller().find(str, casesens, words, !backwards);
docstring const data = find2string(search, casesensitive,
matchword, forward);
dispatch(FuncRequest(LFUN_WORD_FIND, data));
}
void GuiSearchDialog::replace(docstring const & findstr,
docstring const & replacestr,
bool casesens, bool words, bool backwards, bool all)
void GuiSearch::replace(docstring const & search, docstring const & replace,
bool casesensitive, bool matchword,
bool forward, bool all)
{
controller().replace(findstr, replacestr, casesens, words,
!backwards, all);
docstring const data =
replace2string(search, replace, casesensitive,
matchword, all, forward);
dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
}
Dialog * createGuiSearch(LyXView & lv) { return new GuiSearch(lv); }
} // namespace frontend
} // namespace lyx

View File

@ -5,6 +5,7 @@
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
@ -13,20 +14,17 @@
#define GUISEARCH_H
#include "GuiDialog.h"
#include "ControlSearch.h"
#include "ui_SearchUi.h"
namespace lyx {
namespace frontend {
class ControlSearch;
class GuiSearchDialog : public GuiDialog, public Ui::SearchUi
class GuiSearch : public GuiDialog, public Ui::SearchUi, public Controller
{
Q_OBJECT
public:
GuiSearchDialog(LyXView & lv);
GuiSearch(LyXView & lv);
private Q_SLOTS:
void findChanged();
@ -38,14 +36,21 @@ private:
void showView();
void closeEvent(QCloseEvent * e);
/// parent controller
ControlSearch & controller();
Controller & controller() { return *this; }
///
void find(docstring const & str, bool casesens,
bool words, bool backwards);
///
void replace(docstring const & findstr,
docstring const & replacestr,
bool casesens, bool words, bool backwards, bool all);
bool initialiseParams(std::string const &) { return true; }
void clearParams() {}
void dispatchParams() {}
bool isBufferDependent() const { return true; }
/// Searches occurence of string
void find(docstring const & search,
bool casesensitive, bool matchword, bool forward);
/// Replaces occurence of string
void replace(docstring const & search, docstring const & replace,
bool casesensitive, bool matchword,
bool forward, bool all);
};
} // namespace frontend

View File

@ -315,11 +315,8 @@ void TocWidget::reconnectSelectionModel()
void TocWidget::disconnectSelectionModel()
{
disconnect(tocTV->selectionModel(),
SIGNAL(currentChanged(const QModelIndex &,
const QModelIndex &)),
this,
SLOT(selectionChanged(const QModelIndex &,
const QModelIndex &)));
SIGNAL(currentChanged(QModelIndex, QModelIndex)),
this, SLOT(selectionChanged(QModelIndex, QModelIndex)));
}
} // namespace frontend

View File

@ -14,7 +14,7 @@
#define TOC_WIDGET_H
#include "GuiDialog.h"
#include "ControlToc.h"
#include "GuiToc.h"
#include "ui_TocUi.h"