00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef _katesearch_h_
00023
#define _katesearch_h_
00024
00025
#include "katecursor.h"
00026
00027
#include <kdialogbase.h>
00028
00029
#include <qstring.h>
00030
#include <qregexp.h>
00031
#include <qstringlist.h>
00032
#include <qvaluelist.h>
00033
00034
class KateView;
00035
class KateDocument;
00036
class KateSuperRangeList;
00037
00038
class KActionCollection;
00039
00040
class KateSearch :
public QObject
00041 {
00042 Q_OBJECT
00043
00044
friend class KateDocument;
00045
00046
private:
00047
class SearchFlags
00048 {
00049
public:
00050
bool caseSensitive :1;
00051
bool wholeWords :1;
00052
bool fromBeginning :1;
00053
bool backward :1;
00054
bool selected :1;
00055
bool prompt :1;
00056
bool replace :1;
00057
bool finished :1;
00058
bool regExp :1;
00059 };
00060
00061
class SConfig
00062 {
00063
public:
00064 SearchFlags flags;
00065
KateTextCursor cursor;
00066
KateTextCursor wrappedEnd;
00067
bool wrapped;
00068 uint matchedLength;
00069
KateTextCursor selBegin;
00070
KateTextCursor selEnd;
00071 };
00072
00073
public:
00074
enum Dialog_results {
00075 srCancel = KDialogBase::Cancel,
00076 srAll = KDialogBase::User1,
00077 srLast = KDialogBase::User2,
00078 srNo = KDialogBase::User3,
00079 srYes = KDialogBase::Ok
00080 };
00081
00082
public:
00083 KateSearch( KateView* );
00084 ~KateSearch();
00085
00086
void createActions(
KActionCollection* );
00087
00088
public slots:
00089
void find();
00090
void replace();
00091
void findAgain(
bool back );
00092
00093
private slots:
00094
void replaceSlot();
00095
void slotFindNext() { findAgain(
false ); }
00096
void slotFindPrev() { findAgain(
true ); }
00097
00098
private:
00099
static void addToList(
QStringList&,
const QString& );
00100
static void addToSearchList(
const QString& s ) { addToList( s_searchList, s ); }
00101
static void addToReplaceList(
const QString& s ) { addToList( s_replaceList, s ); }
00102
static QStringList s_searchList;
00103
static QStringList s_replaceList;
00104
00105
void search( SearchFlags flags );
00106
void wrapSearch();
00107
bool askContinue();
00108
00109
void findAgain();
00110
void promptReplace();
00111
void replaceAll();
00112
void replaceOne();
00113
void skipOne();
00114
00115
QString getSearchText();
00116
KateTextCursor getCursor();
00117
bool doSearch(
const QString& text );
00118
void exposeFound(
KateTextCursor &cursor,
int slen );
00119
00120
inline KateView* view() {
return m_view; }
00121
inline KateDocument* doc() {
return m_doc; }
00122
00123 KateView* m_view;
00124 KateDocument* m_doc;
00125
00126 KateSuperRangeList* m_arbitraryHLList;
00127
00128 SConfig s;
00129
00130
QValueList<SConfig> m_searchResults;
00131
int m_resultIndex;
00132
00133
int replaces;
00134
QDialog* replacePrompt;
00135
QString m_replacement;
00136
QRegExp m_re;
00137 };
00138
00139
class ReplacePrompt :
public KDialogBase
00140 {
00141 Q_OBJECT
00142
00143
public:
00144 ReplacePrompt(
QWidget *parent);
00145
00146 signals:
00147
void clicked();
00148
00149
protected slots:
00150
void slotOk(
void );
00151
void slotClose(
void );
00152
void slotUser1(
void );
00153
void slotUser2(
void );
00154
void slotUser3(
void );
00155
virtual void done(
int);
00156 };
00157
00158
#endif