kreplacedialog.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kreplacedialog.h"
00022
00023 #include <qcheckbox.h>
00024 #include <qgroupbox.h>
00025 #include <qlabel.h>
00026 #include <qlayout.h>
00027 #include <kcombobox.h>
00028
00034 class KReplaceDialog::KReplaceDialogPrivate {
00035 public:
00036 KReplaceDialogPrivate() : m_initialShowDone(false) {}
00037 QStringList replaceStrings;
00038 bool m_initialShowDone;
00039 };
00040
00041 KReplaceDialog::KReplaceDialog(QWidget *parent, const char *name, long options, const QStringList &findStrings, const QStringList &replaceStrings, bool hasSelection) :
00042 KFindDialog(parent, name, true)
00043 {
00044 d = new KReplaceDialogPrivate;
00045 d->replaceStrings = replaceStrings;
00046 init(true, findStrings, hasSelection);
00047 setOptions(options);
00048 }
00049
00050 KReplaceDialog::~KReplaceDialog()
00051 {
00052 delete d;
00053 }
00054
00055 void KReplaceDialog::showEvent( QShowEvent *e )
00056 {
00057 if ( !d->m_initialShowDone )
00058 {
00059 d->m_initialShowDone = true;
00060
00061 if (!d->replaceStrings.isEmpty())
00062 {
00063 setReplacementHistory(d->replaceStrings);
00064 m_replace->lineEdit()->setText( d->replaceStrings[0] );
00065 }
00066 }
00067
00068 KFindDialog::showEvent(e);
00069 }
00070
00071 long KReplaceDialog::options() const
00072 {
00073 long options = 0;
00074
00075 options = KFindDialog::options();
00076 if (m_promptOnReplace->isChecked())
00077 options |= PromptOnReplace;
00078 if (m_backRef->isChecked())
00079 options |= BackReference;
00080 return options;
00081 }
00082
00083 QWidget *KReplaceDialog::replaceExtension()
00084 {
00085 if (!m_replaceExtension)
00086 {
00087 m_replaceExtension = new QWidget(m_replaceGrp);
00088 m_replaceLayout->addMultiCellWidget(m_replaceExtension, 3, 3, 0, 1);
00089 }
00090
00091 return m_replaceExtension;
00092 }
00093
00094 QString KReplaceDialog::replacement() const
00095 {
00096 return m_replace->currentText();
00097 }
00098
00099 QStringList KReplaceDialog::replacementHistory() const
00100 {
00101 return m_replace->historyItems();
00102 }
00103
00104 void KReplaceDialog::setOptions(long options)
00105 {
00106 KFindDialog::setOptions(options);
00107 m_promptOnReplace->setChecked(options & PromptOnReplace);
00108 m_backRef->setChecked(options & BackReference);
00109 }
00110
00111 void KReplaceDialog::setReplacementHistory(const QStringList &strings)
00112 {
00113 if (strings.count() > 0)
00114 m_replace->setHistoryItems(strings, true);
00115 else
00116 m_replace->clearHistory();
00117 }
00118
00119 void KReplaceDialog::slotOk()
00120 {
00121 KFindDialog::slotOk();
00122 m_replace->addToHistory(replacement());
00123 }
00124
00125 #include "kreplacedialog.moc"
This file is part of the documentation for kutils Library Version 3.3.1.