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-2004 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 __KATE_SEARCH_H__
00023 #define __KATE_SEARCH_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; // after wraping around, search/replace until here
00067         bool wrapped; // have we allready wrapped around ?
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 
00142 class KateReplacePrompt : public KDialogBase
00143 {
00144   Q_OBJECT
00145     
00146   public:
00151     KateReplacePrompt(QWidget *parent);
00152 
00153   signals:
00157     void clicked();
00158 
00159   protected slots:
00163     void slotOk ();
00164     
00168     void slotClose ();
00169     
00173     void slotUser1 ();
00174     
00178     void slotUser2 ();
00179     
00183     void slotUser3 ();
00184     
00189     void done (int result);
00190 };
00191 
00192 #endif
00193 
00194 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE Logo
This file is part of the documentation for kate Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jan 22 16:53:00 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003