1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2001 S.R. Haque <srhaque@iee.org>.
4 SPDX-FileCopyrightText: 2002 David Faure <david@mandrakesoft.com>
5 SPDX-FileCopyrightText: 2004 Arend van Beelen jr. <arend@auton.nl>
6
7 SPDX-License-Identifier: LGPL-2.0-only
8*/
9
10#ifndef KREPLACEDIALOG_H
11#define KREPLACEDIALOG_H
12
13#include "ktextwidgets_export.h"
14
15#include "kfinddialog.h"
16
17class KReplaceDialogPrivate;
18
19/*!
20 * \class KReplaceDialog
21 * \inmodule KTextWidgets
22 *
23 * \brief A generic "replace" dialog.
24 *
25 * \b Detail:
26 *
27 * This widget inherits from KFindDialog and implements
28 * the following additional functionalities: a replacement string
29 * object and an area for a user-defined widget to extend the dialog.
30 *
31 * \b Example:
32 *
33 * To use the basic replace dialog:
34 *
35 * \code
36 * \endcode
37 *
38 * To use your own extensions:
39 *
40 * \code
41 * \endcode
42 *
43 * \image kreplacedialog.png "KReplaceDialog Widget"
44 */
45class KTEXTWIDGETS_EXPORT KReplaceDialog : public KFindDialog
46{
47 Q_OBJECT
48
49public:
50 /*!
51 * \enum KReplaceDialog::Options
52 *
53 * \value PromptOnReplace
54 * Should the user be prompted before the replace operation?
55 *
56 * \value BackReference
57 * Use a back reference in the regular expression.
58 */
59
60 enum Options {
61 PromptOnReplace = 256,
62 BackReference = 512,
63 };
64
65 /*!
66 * Construct a replace dialog.read-only or rather select-only combo box with a
67 * parent object and a name.
68 *
69 * \a parent The parent object of this widget
70 *
71 * \a options A bitfield of the Options to be enabled.
72 *
73 * \a findStrings A QStringList to insert in the combo box of text to find
74 *
75 * \a replaceStrings A QStringList to insert in the combo box of text to
76 * replace with
77 *
78 * \a hasSelection Whether a selection exists
79 */
80 explicit KReplaceDialog(QWidget *parent = nullptr,
81 long options = 0,
82 const QStringList &findStrings = QStringList(),
83 const QStringList &replaceStrings = QStringList(),
84 bool hasSelection = true);
85
86 ~KReplaceDialog() override;
87
88 /*!
89 * Provide the list of strings to be displayed as the \a history
90 * of replacement strings. The history might get truncated if it is
91 * too long.
92 *
93 * \sa replacementHistory
94 */
95 void setReplacementHistory(const QStringList &history);
96
97 /*!
98 * Returns the list of history items.
99 *
100 * \sa setReplacementHistory
101 */
102 QStringList replacementHistory() const;
103
104 /*!
105 * Set the options which are enabled.
106 *
107 * \a options The setting of the Options.
108 */
109 void setOptions(long options);
110
111 /*!
112 * Returns the state of the options. Disabled options may be returned in
113 * an indeterminate state.
114 *
115 * \sa setOptions
116 */
117 long options() const;
118
119 /*!
120 * Returns the replacement string.
121 */
122 QString replacement() const;
123
124 /*!
125 * Returns an empty widget which the user may fill with additional UI
126 * elements as required. The widget occupies the width of the dialog,
127 * and is positioned immediately the regular expression support widgets
128 * for the replacement string.
129 */
130 QWidget *replaceExtension() const;
131
132protected:
133 void showEvent(QShowEvent *) override;
134
135private:
136 Q_DECLARE_PRIVATE(KReplaceDialog)
137};
138
139#endif // KREPLACEDIALOG_H
140

source code of ktextwidgets/src/findreplace/kreplacedialog.h