kate Library API Documentation

katesearch.h

00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
00003    Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
00004    Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
00005    Copyright (C) 1999 Jochen Wilhelmy <digisnap@cs.tu-berlin.de>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License version 2 as published by the Free Software Foundation.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
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 ); // All
00151     void slotUser2( void ); // Last
00152     void slotUser3( void ); // Yes
00153     virtual void done(int);
00154 };
00155 
00156 #endif
KDE Logo
This file is part of the documentation for kate Library Version 3.2.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 4 12:37:42 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003