Changeset View
Changeset View
Standalone View
Standalone View
src/utils/ktexteditor.cpp
Show All 26 Lines | |||||
27 | 27 | | |||
28 | #include "document.h" | 28 | #include "document.h" | ||
29 | 29 | | |||
30 | #include "view.h" | 30 | #include "view.h" | ||
31 | 31 | | |||
32 | #include "plugin.h" | 32 | #include "plugin.h" | ||
33 | 33 | | |||
34 | #include "command.h" | 34 | #include "command.h" | ||
35 | #include "inlinenoteinterface.h" | ||||
35 | #include "markinterface.h" | 36 | #include "markinterface.h" | ||
36 | #include "modificationinterface.h" | 37 | #include "modificationinterface.h" | ||
37 | #include "sessionconfiginterface.h" | 38 | #include "sessionconfiginterface.h" | ||
38 | #include "texthintinterface.h" | 39 | #include "texthintinterface.h" | ||
39 | 40 | | |||
40 | #include "annotationinterface.h" | 41 | #include "annotationinterface.h" | ||
41 | 42 | | |||
42 | #include "kateglobal.h" | 43 | #include "kateglobal.h" | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | |||||
205 | {} | 206 | {} | ||
206 | 207 | | |||
207 | TextHintProvider::TextHintProvider() | 208 | TextHintProvider::TextHintProvider() | ||
208 | {} | 209 | {} | ||
209 | 210 | | |||
210 | TextHintProvider::~TextHintProvider() | 211 | TextHintProvider::~TextHintProvider() | ||
211 | {} | 212 | {} | ||
212 | 213 | | |||
214 | InlineNoteInterface::InlineNoteInterface() | ||||
215 | {} | ||||
216 | | ||||
217 | InlineNoteInterface::~InlineNoteInterface() | ||||
218 | {} | ||||
219 | | ||||
220 | InlineNoteProvider::InlineNoteProvider() | ||||
221 | {} | ||||
222 | | ||||
223 | InlineNoteProvider::~InlineNoteProvider() | ||||
224 | {} | ||||
225 | | ||||
226 | InlineNote::InlineNote(InlineNoteProvider* provider, const KTextEditor::Cursor& location, int index, | ||||
227 | const KTextEditor::View* view, QFont font, int lineHeight, bool hasFocus) | ||||
228 | : m_provider(provider) | ||||
229 | , m_view(view) | ||||
230 | , m_location(location) | ||||
231 | , m_index(index) | ||||
232 | , m_hasFocus(hasFocus) | ||||
233 | , m_font(font) | ||||
234 | , m_lineHeight(lineHeight) | ||||
235 | { | ||||
236 | } | ||||
237 | | ||||
238 | InlineNote::InlineNote() | ||||
dhaumann: When members are initialized in the header file, you can write here:
InlineNote… | |||||
239 | : m_provider(nullptr) | ||||
240 | , m_view(nullptr) | ||||
241 | , m_location({}) | ||||
242 | , m_index(-1) | ||||
243 | , m_hasFocus(false) | ||||
244 | { | ||||
245 | } | ||||
246 | | ||||
247 | int InlineNote::column() const | ||||
248 | { | ||||
249 | return m_location.column(); | ||||
250 | } | ||||
251 | | ||||
252 | qreal InlineNote::width() const | ||||
253 | { | ||||
254 | return m_provider->inlineNoteSize(*this).width(); | ||||
255 | } | ||||
256 | | ||||
257 | void InlineNote::paint(QPainter &painter) const | ||||
258 | { | ||||
259 | m_provider->paintInlineNote(*this, painter); | ||||
260 | } | ||||
261 | | ||||
262 | void KTextEditor::InlineNote::activate(Qt::MouseButtons buttons, const QPoint& pos) | ||||
263 | { | ||||
264 | m_provider->inlineNoteActivated(*this, buttons, pos); | ||||
265 | } | ||||
266 | | ||||
267 | void KTextEditor::InlineNote::setFocus(bool focus, const QPoint& pos) | ||||
268 | { | ||||
269 | m_provider->inlineNoteFocusChanged(*this, focus, pos); | ||||
270 | } | ||||
271 | | ||||
272 | bool KTextEditor::InlineNote::hasFocus() const | ||||
273 | { | ||||
274 | return m_hasFocus; | ||||
275 | } | ||||
276 | | ||||
277 | void KTextEditor::InlineNoteProvider::inlineNoteFocusChanged(const KTextEditor::InlineNote& note, bool hasFocus, const QPoint& pos) | ||||
278 | { | ||||
279 | Q_UNUSED(note); | ||||
280 | Q_UNUSED(hasFocus); | ||||
281 | Q_UNUSED(pos); | ||||
282 | } | ||||
283 | | ||||
284 | void KTextEditor::InlineNoteProvider::inlineNoteActivated(const KTextEditor::InlineNote& note, Qt::MouseButtons buttons, const QPoint& pos) | ||||
285 | { | ||||
286 | Q_UNUSED(note); | ||||
287 | Q_UNUSED(buttons); | ||||
288 | Q_UNUSED(pos); | ||||
289 | } | ||||
290 | | ||||
291 | bool InlineNote::isValid() const | ||||
292 | { | ||||
293 | return m_provider != nullptr && m_location.isValid(); | ||||
294 | } | ||||
295 | | ||||
296 | InlineNote::operator bool() const { | ||||
297 | return isValid(); | ||||
298 | } | ||||
299 | | ||||
300 | bool InlineNote::operator==(const InlineNote& other) const { | ||||
301 | return m_provider == other.m_provider && m_location == other.m_location && m_index == other.m_index; | ||||
302 | } | ||||
303 | | ||||
304 | QPoint InlineNote::mapToGlobal(const QPoint& pos) const | ||||
305 | { | ||||
306 | auto localPos = static_cast<const ViewPrivate*>(m_view)->inlineNoteRect(*this).topLeft() + pos; | ||||
307 | return m_view->mapToGlobal(localPos); | ||||
308 | } | ||||
309 | | ||||
310 | KTextEditor::InlineNoteProvider* InlineNote::provider() const | ||||
311 | { | ||||
312 | return m_provider; | ||||
313 | } | ||||
314 | | ||||
315 | const KTextEditor::View* InlineNote::view() const | ||||
316 | { | ||||
317 | return m_view; | ||||
318 | } | ||||
319 | | ||||
320 | QFont InlineNote::font() const | ||||
321 | { | ||||
322 | return m_font; | ||||
323 | } | ||||
324 | | ||||
325 | int InlineNote::index() const | ||||
326 | { | ||||
327 | return m_index; | ||||
328 | } | ||||
329 | | ||||
330 | int InlineNote::lineHeight() const | ||||
331 | { | ||||
332 | return m_lineHeight; | ||||
333 | } | ||||
334 | | ||||
335 | KTextEditor::Cursor InlineNote::location() const | ||||
336 | { | ||||
337 | return m_location; | ||||
338 | } | ||||
339 | | ||||
213 | Command::Command(const QStringList &cmds, QObject *parent) | 340 | Command::Command(const QStringList &cmds, QObject *parent) | ||
214 | : QObject(parent) | 341 | : QObject(parent) | ||
215 | , m_cmds (cmds) | 342 | , m_cmds (cmds) | ||
216 | , d(nullptr) | 343 | , d(nullptr) | ||
217 | { | 344 | { | ||
218 | // register this command | 345 | // register this command | ||
219 | static_cast<KTextEditor::EditorPrivate *> (KTextEditor::Editor::instance())->cmdManager()->registerCommand (this); | 346 | static_cast<KTextEditor::EditorPrivate *> (KTextEditor::Editor::instance())->cmdManager()->registerCommand (this); | ||
220 | } | 347 | } | ||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |
When members are initialized in the header file, you can write here: