katesearch.h
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 uint matchedLength;
00067 KateTextCursor selBegin;
00068 KateTextCursor selEnd;
00069 };
00070
00071 public:
00072 enum Dialog_results {
00073 srCancel = KDialogBase::Cancel,
00074 srAll = KDialogBase::User1,
00075 srLast = KDialogBase::User2,
00076 srNo = KDialogBase::User3,
00077 srYes = KDialogBase::Ok
00078 };
00079
00080 public:
00081 KateSearch( KateView* );
00082 ~KateSearch();
00083
00084 void createActions( KActionCollection* );
00085
00086 public slots:
00087 void find();
00088 void replace();
00089 void findAgain( bool back );
00090
00091 private slots:
00092 void replaceSlot();
00093 void slotFindNext() { findAgain( false ); }
00094 void slotFindPrev() { findAgain( true ); }
00095
00096 private:
00097 static void addToList( QStringList&, const QString& );
00098 static void addToSearchList( const QString& s ) { addToList( s_searchList, s ); }
00099 static void addToReplaceList( const QString& s ) { addToList( s_replaceList, s ); }
00100 static QStringList s_searchList;
00101 static QStringList s_replaceList;
00102
00103 void search( SearchFlags flags );
00104 void wrapSearch();
00105 bool askContinue();
00106
00107 void findAgain();
00108 void promptReplace();
00109 void replaceAll();
00110 void replaceOne();
00111 void skipOne();
00112
00113 QString getSearchText();
00114 KateTextCursor getCursor();
00115 bool doSearch( const QString& text );
00116 void exposeFound( KateTextCursor &cursor, int slen );
00117
00118 inline KateView* view() { return m_view; }
00119 inline KateDocument* doc() { return m_doc; }
00120
00121 KateView* m_view;
00122 KateDocument* m_doc;
00123
00124 KateSuperRangeList* m_arbitraryHLList;
00125
00126 SConfig s;
00127
00128 QValueList<SConfig> m_searchResults;
00129 int m_resultIndex;
00130
00131 int replaces;
00132 QDialog* replacePrompt;
00133 QString m_replacement;
00134 QRegExp m_re;
00135 };
00136
00137 class ReplacePrompt : public KDialogBase
00138 {
00139 Q_OBJECT
00140
00141 public:
00142 ReplacePrompt(QWidget *parent);
00143
00144 signals:
00145 void clicked();
00146
00147 protected slots:
00148 void slotOk( void );
00149 void slotClose( void );
00150 void slotUser1( void );
00151 void slotUser2( void );
00152 void slotUser3( void );
00153 virtual void done(int);
00154 };
00155
00156 #endif
This file is part of the documentation for kate Library Version 3.2.0.