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 QStringList replaceStrings;
00037 };
00038
00039 KReplaceDialog::KReplaceDialog(QWidget *parent, const char *name, long options, const QStringList &findStrings, const QStringList &replaceStrings, bool hasSelection) :
00040 KFindDialog(parent, name, true)
00041 {
00042 d = new KReplaceDialogPrivate;
00043 d->replaceStrings = replaceStrings;
00044 init(true, findStrings, hasSelection);
00045 setOptions(options);
00046 }
00047
00048 KReplaceDialog::~KReplaceDialog()
00049 {
00050 delete d;
00051 }
00052
00053 void KReplaceDialog::showEvent( QShowEvent *e )
00054 {
00055 setReplacementHistory(d->replaceStrings);
00056 KFindDialog::showEvent(e);
00057 }
00058
00059 long KReplaceDialog::options() const
00060 {
00061 long options = 0;
00062
00063 options = KFindDialog::options();
00064 if (m_promptOnReplace->isChecked())
00065 options |= PromptOnReplace;
00066 if (m_backRef->isChecked())
00067 options |= BackReference;
00068 return options;
00069 }
00070
00071 QWidget *KReplaceDialog::replaceExtension()
00072 {
00073 if (!m_replaceExtension)
00074 {
00075 m_replaceExtension = new QWidget(m_replaceGrp);
00076 m_replaceLayout->addMultiCellWidget(m_replaceExtension, 3, 3, 0, 1);
00077 }
00078
00079 return m_replaceExtension;
00080 }
00081
00082 QString KReplaceDialog::replacement() const
00083 {
00084 return m_replace->currentText();
00085 }
00086
00087 QStringList KReplaceDialog::replacementHistory() const
00088 {
00089 return m_replace->historyItems();
00090 }
00091
00092 void KReplaceDialog::setOptions(long options)
00093 {
00094 KFindDialog::setOptions(options);
00095 m_promptOnReplace->setChecked(options & PromptOnReplace);
00096 m_backRef->setChecked(options & BackReference);
00097 }
00098
00099 void KReplaceDialog::setReplacementHistory(const QStringList &strings)
00100 {
00101 if (strings.count() > 0)
00102 m_replace->setHistoryItems(strings, true);
00103 else
00104 m_replace->clearHistory();
00105 }
00106
00107 void KReplaceDialog::slotOk()
00108 {
00109 KFindDialog::slotOk();
00110 m_replace->addToHistory(replacement());
00111 }
00112
00113 #include "kreplacedialog.moc"
This file is part of the documentation for kdelibs Version 3.1.0.