#ifndef QSEARCHADV_H
#define QSEARCHADV_H
-#include "GuiWorkArea.h"
-
#include "DockView.h"
+// This is needed so that ui_FindAndReplaceUi.h can find qt_()
+#include "qt_helpers.h"
#include "ui_FindAndReplaceUi.h"
-#include "BufferView.h"
-#include "Buffer.h"
-#include "LyX.h"
-#include "LyXFunc.h"
-#include "Text.h"
-
-#include <QDialog>
+#include "lyxfind.h"
#include <string>
namespace lyx {
namespace frontend {
-class FindAndReplace : public DockView, public Ui::FindAndReplaceUi
+class FindAndReplaceWidget : public QTabWidget, public Ui::FindAndReplaceUi
{
Q_OBJECT
+
public:
- FindAndReplace(GuiView & parent);
+ FindAndReplaceWidget(GuiView & view);
+ bool initialiseParams(std::string const & params);
+ void updateGUI();
- bool initialiseParams(std::string const &) { return true; }
- void clearParams() {}
- void dispatchParams() {}
- bool isBufferDependent() const { return true; }
- void selectAll();
+public Q_SLOTS:
+ ///
+ void dockLocationChanged(Qt::DockWidgetArea area);
- void showEvent(QShowEvent * ev);
- void hideEvent(QHideEvent * ev);
+private:
+ ///
+ GuiView & view_;
- /// update
- void updateView() {}
- //virtual void update_contents() {}
+ /// add a string to the combo if needed
+ void remember(std::string const & find, QComboBox & combo);
+
+ /// Perform the scope-related buffer switch while searching
+ bool findAndReplaceScope(FindAndReplaceOptions & opt, bool replace_all = false);
+
+ /// Collect options from the GUI elements, then perform the search
+ bool findAndReplace(bool backwards, bool replace, bool replace_all = false);
+
+ /// FIXME Probably to be merged with findAndReplace(bool, bool, bool)
+ bool findAndReplace(bool casesensitive, bool matchword, bool backwards,
+ bool expandmacros, bool ignoreformat, bool replace,
+ bool keep_case, bool replace_all = false);
+
+ bool eventFilter(QObject *obj, QEvent *event);
+
+ void virtual showEvent(QShowEvent *ev);
+ void virtual hideEvent(QHideEvent *ev);
+
+ void hideDialog();
protected Q_SLOTS:
void on_findNextPB_clicked();
- void on_findPrevPB_clicked();
void on_replacePB_clicked();
void on_replaceallPB_clicked();
- void on_closePB_clicked();
- void on_regexpInsertCombo_currentIndexChanged(int index);
+};
-protected:
- void find(bool backwards);
- virtual bool wantInitialFocus() const { return true; }
-private:
- // add a string to the combo if needed
- void remember(std::string const & find, QComboBox & combo);
- void findAdv(bool casesensitive,
- bool matchword, bool backwards,
- bool expandmacros, bool ignoreformat);
+class FindAndReplace : public DockView
+{
+ Q_OBJECT
+public:
+ FindAndReplace(
+ GuiView & parent, ///< the main window where to dock.
+ Qt::DockWidgetArea area = Qt::RightDockWidgetArea, ///< Position of the dock (and also drawer)
+ Qt::WindowFlags flags = 0);
- GuiView & parent_view_;
+ ~FindAndReplace();
- GuiWorkArea * searchWorkArea_; // The work area defining what to search
+ bool initialiseParams(std::string const &);
+ void clearParams() {}
+ void dispatchParams() {}
+ bool isBufferDependent() const { return false; }
+ bool canApplyToReadOnly() const { return true; }
+ void selectAll();
-private:
- /// Apply changes
- virtual void apply() {}
+ /// update
+ void updateView();
+ //virtual void update_contents() {}
- void find(docstring const & str, int len, bool casesens,
- bool words, bool backwards, bool expandmacros);
+protected:
+ virtual bool wantInitialFocus() const { return true; }
- void replace(docstring const & findstr,
- docstring const & replacestr,
- bool casesens, bool words, bool backwards, bool expandmacros, bool all);
- bool eventFilter(QObject *obj, QEvent *event);
+private:
+ /// The encapsulated widget.
+ FindAndReplaceWidget * widget_;
};