1 | /* |
2 | Copyright (C) 2001, S.R.Haque <srhaque@iee.org>. |
3 | Copyright (C) 2002, David Faure <david@mandrakesoft.com> |
4 | This file is part of the KDE project |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License version 2, as published by the Free Software Foundation. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef KREPLACEDIALOG_H |
22 | #define KREPLACEDIALOG_H |
23 | |
24 | #include "kfinddialog.h" |
25 | |
26 | |
27 | class KReplaceDialogPrivate; |
28 | |
29 | /** |
30 | * @short A generic "replace" dialog. |
31 | * |
32 | * @author S.R.Haque <srhaque@iee.org> |
33 | * |
34 | * \b Detail: |
35 | * |
36 | * This widget inherits from KFindDialog and implements |
37 | * the following additional functionalities: a replacement string |
38 | * object and an area for a user-defined widget to extend the dialog. |
39 | * |
40 | * \b Example: |
41 | * |
42 | * To use the basic replace dialog: |
43 | * |
44 | * \code |
45 | * \endcode |
46 | * |
47 | * To use your own extensions: |
48 | * |
49 | * \code |
50 | * \endcode |
51 | * |
52 | * \image html kreplacedialog.png "KDE Replace Dialog" |
53 | */ |
54 | class KDEUI_EXPORT KReplaceDialog: |
55 | public KFindDialog |
56 | { |
57 | Q_OBJECT |
58 | |
59 | public: |
60 | |
61 | // Options. |
62 | |
63 | enum Options |
64 | { |
65 | // Should the user be prompted before the replace operation? |
66 | PromptOnReplace = 256, |
67 | BackReference = 512 |
68 | }; |
69 | |
70 | /** |
71 | * Construct a replace dialog.read-only or rather select-only combo box with a |
72 | * parent object and a name. |
73 | * |
74 | * @param parent The parent object of this widget |
75 | * @param options A bitfield of the Options to be enabled. |
76 | * @param findStrings A QStringList to insert in the combo box of text to find |
77 | * @param replaceStrings A QStringList to insert in the combo box of text to |
78 | * replace with |
79 | * @param hasSelection Whether a selection exists |
80 | */ |
81 | explicit KReplaceDialog( QWidget *parent = 0, long options = 0, |
82 | const QStringList &findStrings = QStringList(), |
83 | const QStringList &replaceStrings = QStringList(), |
84 | bool hasSelection = true ); |
85 | |
86 | /** |
87 | * Destructor. |
88 | */ |
89 | virtual ~KReplaceDialog(); |
90 | |
91 | /** |
92 | * Provide the list of @p strings to be displayed as the history |
93 | * of replacement strings. @p strings might get truncated if it is |
94 | * too long. |
95 | * |
96 | * @param history The replacement history. |
97 | * @see replacementHistory |
98 | */ |
99 | void setReplacementHistory( const QStringList &history ); |
100 | |
101 | /** |
102 | * Returns the list of history items. |
103 | * |
104 | * @see setReplacementHistory |
105 | */ |
106 | QStringList replacementHistory() const; |
107 | |
108 | /** |
109 | * Set the options which are enabled. |
110 | * |
111 | * @param options The setting of the Options. |
112 | */ |
113 | void setOptions( long options ); |
114 | |
115 | /** |
116 | * Returns the state of the options. Disabled options may be returned in |
117 | * an indeterminate state. |
118 | * |
119 | * @see setOptions |
120 | */ |
121 | long options() const; |
122 | |
123 | /** |
124 | * Returns the replacement string. |
125 | */ |
126 | QString replacement() const; |
127 | |
128 | /** |
129 | * Returns an empty widget which the user may fill with additional UI |
130 | * elements as required. The widget occupies the width of the dialog, |
131 | * and is positioned immediately the regular expression support widgets |
132 | * for the replacement string. |
133 | */ |
134 | QWidget *replaceExtension() const; |
135 | |
136 | protected: |
137 | virtual void showEvent( QShowEvent * ); |
138 | |
139 | private: |
140 | |
141 | KReplaceDialogPrivate* const d; |
142 | |
143 | Q_PRIVATE_SLOT( d, void _k_slotOk() ) |
144 | }; |
145 | |
146 | #endif // KREPLACEDIALOG_H |
147 | |