kreplace.h
00001 /* 00002 Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. 00003 Copyright (C) 2002, David Faure <david@mandrakesoft.com> 00004 This file is part of the KDE project 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2, as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KREPLACE_H 00022 #define KREPLACE_H 00023 00024 #include "kfind.h" 00025 00026 class KReplaceNextDialog; 00027 00097 class KUTILS_EXPORT KReplace : 00098 public KFind 00099 { 00100 Q_OBJECT 00101 00102 public: 00103 00112 KReplace(const QString &pattern, const QString &replacement, long options, QWidget *parent = 0); 00124 KReplace(const QString &pattern, const QString &replacement, long options, QWidget *parent, QWidget* replaceDialog); 00125 00129 virtual ~KReplace(); 00130 00138 int numReplacements() const { return m_replacements; } 00139 00145 virtual void resetCounts(); 00146 00153 Result replace(); 00154 00163 KDialogBase* replaceNextDialog( bool create = false ); 00164 00170 void closeReplaceNextDialog(); 00171 00189 static int replace( QString &text, const QString &pattern, const QString &replacement, int index, long options, int *replacedLength ); 00190 00207 static int replace( QString &text, const QRegExp &pattern, const QString &replacement, int index, long options, int *replacedLength ); 00208 00225 virtual bool shouldRestart( bool forceAsking = false, bool showNumMatches = true ) const; 00226 00231 virtual void displayFinalDialog() const; 00232 00233 signals: 00234 00249 void replace(const QString &text, int replacementIndex, int replacedLength, int matchedLength); 00250 00251 protected slots: 00252 00253 void slotSkip(); 00254 void slotReplace(); 00255 void slotReplaceAll(); 00256 00257 private: 00258 KReplaceNextDialog* dialog(); 00259 void doReplace(); 00260 static int replace( QString &text, const QString &replacement, int index, long options, int length ); 00261 00262 QString m_replacement; 00263 unsigned m_replacements; 00264 00265 // Binary compatible extensibility. 00266 class KReplacePrivate; 00267 KReplacePrivate *d; 00268 }; 00269 #endif