| # kutils Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kreplacedialog.cpp

    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., 59 Temple Place - Suite 330,
    00018     Boston, MA 02111-1307, USA.
    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.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:28:04 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001