KDEUI
Go to the documentation of this file.
22 #include "kfinddialog_p.h"
24 #include <QtGui/QCheckBox>
25 #include <QtGui/QGroupBox>
26 #include <QtGui/QLabel>
27 #include <QtGui/QLayout>
28 #include <QtGui/QLineEdit>
29 #include <QtCore/QRegExp>
40 class KReplaceDialogPrivate
45 , initialShowDone(false)
46 , replaceExtension (0)
53 QStringList replaceStrings;
59 const QStringList &replaceStrings,
bool hasSelection)
60 :
KFindDialog(parent, options, findStrings, hasSelection, true ),
61 d(new KReplaceDialogPrivate(this))
63 d->replaceStrings = replaceStrings;
73 if ( !d->initialShowDone )
75 d->initialShowDone =
true;
77 if (!d->replaceStrings.isEmpty())
80 KFindDialog::d->replace->lineEdit()->setText( d->replaceStrings[0] );
92 if (KFindDialog::d->promptOnReplace->isChecked())
94 if (KFindDialog::d->backRef->isChecked())
101 if (!d->replaceExtension)
103 d->replaceExtension =
new QWidget(KFindDialog::d->replaceGrp);
104 KFindDialog::d->replaceLayout->addWidget(d->replaceExtension, 3, 0, 1, 2);
107 return d->replaceExtension;
112 return KFindDialog::d->replace->currentText();
117 QStringList lst = KFindDialog::d->replace->historyItems();
119 if ( KFindDialog::d->
replace->lineEdit()->text().isEmpty() )
120 lst.prepend( QString() );
133 if (strings.count() > 0)
134 KFindDialog::d->replace->setHistoryItems(strings,
true);
136 KFindDialog::d->replace->clearHistory();
139 void KReplaceDialogPrivate::_k_slotOk()
142 if ( q->KFindDialog::d->regExp->isChecked() && q->KFindDialog::d->backRef->isChecked() )
144 QRegExp r ( q->pattern() );
145 int caps = r.numCaptures();
146 QRegExp check(QString(
"((?:\\\\)+)(\\d+)"));
148 QString rep = q->replacement();
149 while ( (p = check.indexIn( rep, p ) ) > -1 )
151 if ( check.cap(1).length()%2 && check.cap(2).toInt() > caps )
154 "Your replacement string is referencing a capture greater than '\\%1', ", caps ) +
156 i18np(
"but your pattern only defines 1 capture.",
157 "but your pattern only defines %1 captures.", caps ) :
158 i18n(
"but your pattern defines no captures.") ) +
159 i18n(
"\nPlease correct.") );
162 p += check.matchedLength();
167 q->KFindDialog::d->_k_slotOk();
168 q->KFindDialog::d->replace->addToHistory(q->replacement());
172 #include "kreplacedialog.moc"
long options() const
Returns the state of the options.
static void information(QWidget *parent, const QString &text, const QString &caption=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
Display an "Information" dialog.
QStringList replacementHistory() const
Returns the list of history items.
virtual void showEvent(QShowEvent *)
void setReplacementHistory(const QStringList &history)
Provide the list of strings to be displayed as the history of replacement strings.
long options() const
Returns the state of the options.
friend class KReplaceDialog
KAction * replace(const QObject *recvr, const char *slot, QObject *parent)
Find and replace matches.
QString i18np(const char *sing, const char *plur, const A1 &a1)
virtual void showEvent(QShowEvent *)
virtual ~KReplaceDialog()
Destructor.
QString i18n(const char *text)
QWidget * replaceExtension() const
Returns an empty widget which the user may fill with additional UI elements as required.
A generic "replace" dialog.
void setOptions(long options)
Set the options which are checked.
QString replacement() const
Returns the replacement string.
void setOptions(long options)
Set the options which are enabled.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 27 2020 00:00:00 by
doxygen 1.8.20 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.