00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#ifndef _ISearchPlugin_H_
00020
#define _ISearchPlugin_H_
00021
00022
#include <ktexteditor/plugin.h>
00023
#include <ktexteditor/view.h>
00024
#include <ktexteditor/document.h>
00025
#include <ktexteditor/searchinterface.h>
00026
#include <ktexteditor/viewcursorinterface.h>
00027
#include <ktexteditor/selectioninterface.h>
00028
00029
#include <kxmlguiclient.h>
00030
#include <qobject.h>
00031
#include <qguardedptr.h>
00032
00033
class QLabel;
00034
00035
class ISearchPlugin :
public KTextEditor::Plugin,
public KTextEditor::PluginViewInterface
00036 {
00037 Q_OBJECT
00038
00039
public:
00040 ISearchPlugin(
QObject *parent = 0,
const char* name = 0,
const QStringList &args =
QStringList() );
00041
virtual ~ISearchPlugin();
00042
00043
void addView (KTextEditor::View *view);
00044
void removeView (KTextEditor::View *view);
00045
00046
private:
00047
QPtrList<class ISearchPluginView> m_views;
00048 };
00049
00050
class ISearchPluginView :
public QObject,
public KXMLGUIClient
00051 {
00052 Q_OBJECT
00053
00054
public:
00055 ISearchPluginView( KTextEditor::View *view );
00056
virtual ~ISearchPluginView();
00057
00058
virtual bool eventFilter(
QObject*,
QEvent* );
00059
00060
void setView( KTextEditor::View* view );
00061
00062
public slots:
00063
void setCaseSensitive(
bool );
00064
void setFromBeginning(
bool );
00065
void setRegExp(
bool );
00066
void setAutoWrap(
bool );
00067
00068
private slots:
00069
void slotSearchForwardAction();
00070
void slotSearchBackwardAction();
00071
void slotSearchAction(
bool reverse );
00072
void slotTextChanged(
const QString& text );
00073
void slotReturnPressed(
const QString& text );
00074
void slotAddContextMenuItems(
QPopupMenu *menu);
00075
00076
private:
00077
void readConfig();
00078
void writeConfig();
00079
00080
void updateLabelText(
bool failing =
false,
bool reverse =
false,
00081
bool wrapped =
false,
bool overwrapped =
false );
00082
void startSearch();
00083
void endSearch();
00084
void quitToView(
const QString &text );
00085
00086
void nextMatch(
bool reverse );
00087
bool iSearch( uint startLine, uint startCol,
00088
const QString& text,
bool reverse,
bool autoWrap );
00089
00090 KTextEditor::View* m_view;
00091 KTextEditor::Document* m_doc;
00092 KTextEditor::SearchInterface* m_searchIF;
00093 KTextEditor::ViewCursorInterface* m_cursorIF;
00094 KTextEditor::SelectionInterface* m_selectIF;
00095
KAction* m_searchForwardAction;
00096
KAction* m_searchBackwardAction;
00097
KWidgetAction* m_comboAction;
00098
QGuardedPtr<QLabel> m_label;
00099
QGuardedPtr<KHistoryCombo> m_combo;
00100
QString m_lastString;
00101
bool m_searchBackward;
00102
bool m_caseSensitive;
00103
bool m_fromBeginning;
00104
bool m_regExp;
00105
bool m_autoWrap;
00106
bool m_wrapped;
00107 uint m_startLine, m_startCol;
00108 uint m_searchLine, m_searchCol;
00109 uint m_foundLine, m_foundCol, m_matchLen;
00110
bool m_toolBarWasHidden;
00111
enum { NoSearch, TextSearch, MatchSearch } state;
00112 };
00113
00114
#endif // _ISearchPlugin_H_