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
6 SPDX-License-Identifier: LGPL-2.0-only
7*/
8
9#ifndef KREPLACEDIALOG_H
10#define KREPLACEDIALOG_H
11
12#include "ktextwidgets_export.h"
13
14#include "kfinddialog.h"
15
16class KReplaceDialogPrivate;
17
18/**
19 * @class KReplaceDialog kreplace.h <KReplaceDialog>
20 *
21 * @short A generic "replace" dialog.
22 *
23 * @author S.R.Haque <srhaque@iee.org>
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 html kreplacedialog.png "KReplaceDialog Widget"
44 */
45class KTEXTWIDGETS_EXPORT KReplaceDialog : public KFindDialog
46{
47 Q_OBJECT
48
49public:
50 /// Options.
51
52 enum Options {
53 /// Should the user be prompted before the replace operation?
54 PromptOnReplace = 256,
55 BackReference = 512,
56 };
57
58 /**
59 * Construct a replace dialog.read-only or rather select-only combo box with a
60 * parent object and a name.
61 *
62 * @param parent The parent object of this widget
63 * @param options A bitfield of the Options to be enabled.
64 * @param findStrings A QStringList to insert in the combo box of text to find
65 * @param replaceStrings A QStringList to insert in the combo box of text to
66 * replace with
67 * @param hasSelection Whether a selection exists
68 */
69 explicit KReplaceDialog(QWidget *parent = nullptr,
70 long options = 0,
71 const QStringList &findStrings = QStringList(),
72 const QStringList &replaceStrings = QStringList(),
73 bool hasSelection = true);
74
75 /**
76 * Destructor.
77 */
78 ~KReplaceDialog() override;
79
80 /**
81 * Provide the list of @p strings to be displayed as the history
82 * of replacement strings. @p strings might get truncated if it is
83 * too long.
84 *
85 * @param history The replacement history.
86 * @see replacementHistory
87 */
88 void setReplacementHistory(const QStringList &history);
89
90 /**
91 * Returns the list of history items.
92 *
93 * @see setReplacementHistory
94 */
95 QStringList replacementHistory() const;
96
97 /**
98 * Set the options which are enabled.
99 *
100 * @param options The setting of the Options.
101 */
102 void setOptions(long options);
103
104 /**
105 * Returns the state of the options. Disabled options may be returned in
106 * an indeterminate state.
107 *
108 * @see setOptions
109 */
110 long options() const;
111
112 /**
113 * Returns the replacement string.
114 */
115 QString replacement() const;
116
117 /**
118 * Returns an empty widget which the user may fill with additional UI
119 * elements as required. The widget occupies the width of the dialog,
120 * and is positioned immediately the regular expression support widgets
121 * for the replacement string.
122 */
123 QWidget *replaceExtension() const;
124
125protected:
126 void showEvent(QShowEvent *) override;
127
128private:
129 Q_DECLARE_PRIVATE(KReplaceDialog)
130};
131
132#endif // KREPLACEDIALOG_H
133

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