Changeset View
Changeset View
Standalone View
Standalone View
src/search/katesearchbar.h
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 95 | public Q_SLOTS: | |||
---|---|---|---|---|---|
104 | * @param replacementPattern the replacement pattern | 104 | * @param replacementPattern the replacement pattern | ||
105 | */ | 105 | */ | ||
106 | void setReplacementPattern(const QString &replacementPattern); | 106 | void setReplacementPattern(const QString &replacementPattern); | ||
107 | 107 | | |||
108 | void setSearchMode(SearchMode mode); | 108 | void setSearchMode(SearchMode mode); | ||
109 | void setSelectionOnly(bool selectionOnly); | 109 | void setSelectionOnly(bool selectionOnly); | ||
110 | void setMatchCase(bool matchCase); | 110 | void setMatchCase(bool matchCase); | ||
111 | 111 | | |||
112 | // Called for <F3> and <Shift>+<F3> | 112 | // Called by buttons and typically <F3>/<Shift>+<F3> shortcuts | ||
113 | void findNext(); | 113 | void findNext(); | ||
114 | void findPrevious(); | 114 | void findPrevious(); | ||
115 | void findAll(); | | |||
116 | 115 | | |||
116 | // PowerMode stuff | ||||
117 | void findAll(); | ||||
117 | void replaceNext(); | 118 | void replaceNext(); | ||
118 | void replaceAll(); | 119 | void replaceAll(); | ||
119 | 120 | | |||
120 | // Also used by KTextEditor::ViewPrivate | 121 | // Also used by KTextEditor::ViewPrivate | ||
121 | void enterPowerMode(); | 122 | void enterPowerMode(); | ||
122 | void enterIncrementalMode(); | 123 | void enterIncrementalMode(); | ||
123 | 124 | | |||
124 | bool clearHighlights(); | 125 | bool clearHighlights(); | ||
Show All 10 Lines | 135 | private Q_SLOTS: | |||
135 | void onIncPatternChanged(const QString &pattern); | 136 | void onIncPatternChanged(const QString &pattern); | ||
136 | void onMatchCaseToggled(bool matchCase); | 137 | void onMatchCaseToggled(bool matchCase); | ||
137 | 138 | | |||
138 | void onReturnPressed(); | 139 | void onReturnPressed(); | ||
139 | void updateSelectionOnly(); | 140 | void updateSelectionOnly(); | ||
140 | void updateIncInitCursor(); | 141 | void updateIncInitCursor(); | ||
141 | 142 | | |||
142 | void onPowerPatternChanged(const QString &pattern); | 143 | void onPowerPatternChanged(const QString &pattern); | ||
143 | | ||||
144 | void onPowerModeChanged(int index); | 144 | void onPowerModeChanged(int index); | ||
145 | void onPowerPatternContextMenuRequest(); | 145 | void onPowerPatternContextMenuRequest(); | ||
146 | void onPowerPatternContextMenuRequest(const QPoint &); | 146 | void onPowerPatternContextMenuRequest(const QPoint &); | ||
147 | void onPowerReplacmentContextMenuRequest(); | 147 | void onPowerReplacmentContextMenuRequest(); | ||
148 | void onPowerReplacmentContextMenuRequest(const QPoint &); | 148 | void onPowerReplacmentContextMenuRequest(const QPoint &); | ||
149 | void onPowerCancelFindOrReplace(); | ||||
150 | | ||||
151 | /** | ||||
152 | * This function do the hard search & replace work in time slice steps. | ||||
153 | * When all is done @ref m_matchCounter is set and the signal | ||||
154 | * @ref findOrReplaceAllFinished() is emitted. | ||||
155 | */ | ||||
156 | void findOrReplaceAll(); | ||||
157 | | ||||
158 | | ||||
159 | /** | ||||
160 | * Restore needed settings when signal @ref findOrReplaceAllFinished() | ||||
161 | * was received. | ||||
162 | */ | ||||
163 | void endFindOrReplaceAll(); | ||||
164 | | ||||
165 | Q_SIGNALS: | ||||
166 | /** | ||||
167 | * Will emitted by @ref findOrReplaceAll() when all is done. | ||||
168 | */ | ||||
169 | void findOrReplaceAllFinished(); | ||||
149 | 170 | | |||
150 | private: | 171 | private: | ||
151 | // Helpers | 172 | // Helpers | ||
anthonyfieroni: Do not change. | |||||
152 | bool find(SearchDirection searchDirection = SearchForward, const QString *replacement = nullptr); | 173 | bool find(SearchDirection searchDirection = SearchForward) { return findOrReplace(searchDirection, nullptr); }; | ||
153 | int findAll(KTextEditor::Range inputRange, const QString *replacement); | 174 | bool findOrReplace(SearchDirection searchDirection, const QString *replacement); | ||
It's exported class you cannot remove a function, it breaks the ABI anthonyfieroni: It's exported class you cannot remove a function, it breaks the ABI | |||||
175 | | ||||
176 | /** | ||||
177 | * The entry point to start a search & replace task. | ||||
178 | * Set needed member variables and call @ref findOrReplaceAll() to do the work. | ||||
179 | */ | ||||
180 | void beginFindOrReplaceAll(KTextEditor::Range inputRange, const QString &replacement, bool replaceMode = true); | ||||
181 | void beginFindAll(KTextEditor::Range inputRange) { beginFindOrReplaceAll(inputRange, QString(), false); }; | ||||
154 | 182 | | |||
155 | bool isPatternValid() const; | 183 | bool isPatternValid() const; | ||
156 | 184 | | |||
157 | KTextEditor::SearchOptions searchOptions(SearchDirection searchDirection = SearchForward) const; | 185 | KTextEditor::SearchOptions searchOptions(SearchDirection searchDirection = SearchForward) const; | ||
158 | 186 | | |||
159 | void highlightMatch(const KTextEditor::Range &range); | 187 | void highlightMatch(const KTextEditor::Range &range); | ||
160 | void highlightReplacement(const KTextEditor::Range &range); | 188 | void highlightReplacement(const KTextEditor::Range &range); | ||
161 | void indicateMatch(MatchResult matchResult); | 189 | void indicateMatch(MatchResult matchResult); | ||
162 | static void selectRange(KTextEditor::ViewPrivate *view, const KTextEditor::Range &range); | 190 | static void selectRange(KTextEditor::ViewPrivate *view, const KTextEditor::Range &range); | ||
163 | void selectRange2(const KTextEditor::Range &range); | 191 | void selectRange2(const KTextEditor::Range &range); | ||
164 | 192 | | |||
165 | QVector<QString> getCapturePatterns(const QString &pattern) const; | 193 | QVector<QString> getCapturePatterns(const QString &pattern) const; | ||
166 | void showExtendedContextMenu(bool forPattern, const QPoint &pos); | 194 | void showExtendedContextMenu(bool forPattern, const QPoint &pos); | ||
167 | 195 | | |||
168 | void givePatternFeedback(); | 196 | void givePatternFeedback(); | ||
169 | void addCurrentTextToHistory(QComboBox *combo); | 197 | void addCurrentTextToHistory(QComboBox *combo); | ||
170 | void backupConfig(bool ofPower); | 198 | void backupConfig(bool ofPower); | ||
171 | void sendConfig(); | 199 | void sendConfig(); | ||
172 | void fixForSingleLine(KTextEditor::Range &range, SearchDirection searchDirection); | 200 | void fixForSingleLine(KTextEditor::Range &range, SearchDirection searchDirection); | ||
173 | 201 | | |||
174 | void showInfoMessage(const QString &text); | 202 | void showResultMessage(); | ||
anthonyfieroni: Same here. | |||||
175 | 203 | | |||
176 | private: | 204 | private: | ||
177 | KTextEditor::ViewPrivate *const m_view; | 205 | KTextEditor::ViewPrivate *const m_view; | ||
178 | KateViewConfig *const m_config; | 206 | KateViewConfig *const m_config; | ||
179 | QList<KTextEditor::MovingRange *> m_hlRanges; | 207 | QList<KTextEditor::MovingRange *> m_hlRanges; | ||
180 | QPointer<KTextEditor::Message> m_infoMessage; | 208 | QPointer<KTextEditor::Message> m_infoMessage; | ||
181 | QPointer<KTextEditor::Message> m_wrappedMessage; | 209 | QPointer<KTextEditor::Message> m_wrappedMessage; | ||
182 | SearchDirection m_lastSearchDirection = SearchForward; | 210 | SearchDirection m_lastSearchDirection = SearchForward; | ||
183 | 211 | | |||
184 | // Shared by both dialogs | 212 | // Shared by both dialogs | ||
185 | QVBoxLayout *const m_layout; | 213 | QVBoxLayout *const m_layout; | ||
186 | QWidget *m_widget; | 214 | QWidget *m_widget; | ||
187 | 215 | | |||
188 | // Incremental search related | 216 | // Incremental search related | ||
189 | Ui::IncrementalSearchBar *m_incUi; | 217 | Ui::IncrementalSearchBar *m_incUi; | ||
190 | KTextEditor::Cursor m_incInitCursor; | 218 | KTextEditor::Cursor m_incInitCursor; | ||
191 | 219 | | |||
192 | // Power search related | 220 | // Power search related | ||
193 | Ui::PowerSearchBar *m_powerUi; | 221 | Ui::PowerSearchBar *m_powerUi = nullptr; | ||
222 | KTextEditor::MovingRange *m_workingRange = nullptr; | ||||
223 | KTextEditor::Range m_inputRange; | ||||
224 | QString m_replacement; | ||||
225 | uint m_matchCounter = 0; | ||||
226 | bool m_replaceMode = false; | ||||
227 | bool m_cancelFindOrReplace = true; | ||||
You cannot add new members as well, they change object size. Since this class not use pimpl idiom it will be harder to change anything in header except to add new non-virtual functions. anthonyfieroni: You cannot add new members as well, they change object size. Since this class not use pimpl… | |||||
This is a purely internal class. cullmann: This is a purely internal class.
It is only exported for the unit tests, no header files are… | |||||
Yes: as rule of thumb: only classes in the KTextEditor namespace are public API. Everything else can be freely changed. In this case, as Christoph points out, this is purely internal API. PS: maybe we should have a KTEXTEDITOR_TEST_EXPORT macro to make this explicit. :-) dhaumann: Yes: as rule of thumb: only classes in the KTextEditor namespace are public API. Everything… | |||||
228 | std::vector<KTextEditor::Range> m_highlightRanges; | ||||
194 | 229 | | |||
195 | // attribute to highlight matches with | 230 | // attribute to highlight matches with | ||
196 | KTextEditor::Attribute::Ptr highlightMatchAttribute; | 231 | KTextEditor::Attribute::Ptr highlightMatchAttribute; | ||
197 | KTextEditor::Attribute::Ptr highlightReplacementAttribute; | 232 | KTextEditor::Attribute::Ptr highlightReplacementAttribute; | ||
198 | 233 | | |||
199 | // Status backup | 234 | // Status backup | ||
200 | bool m_incHighlightAll : 1; | 235 | bool m_incHighlightAll : 1; | ||
201 | bool m_incFromCursor : 1; | 236 | bool m_incFromCursor : 1; | ||
Show All 9 Lines |
Do not change.