| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2018 Sven Brauch <mail@svenbrauch.de> |
| 3 | SPDX-FileCopyrightText: 2018 Michal Srb <michalsrb@gmail.com> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef KTEXTEDITOR_INLINENOTE_H |
| 9 | #define KTEXTEDITOR_INLINENOTE_H |
| 10 | |
| 11 | #include <ktexteditor/cursor.h> |
| 12 | #include <ktexteditor/view.h> |
| 13 | |
| 14 | class QFont; |
| 15 | class KateInlineNoteData; |
| 16 | namespace KTextEditor |
| 17 | { |
| 18 | class InlineNoteProvider; |
| 19 | } |
| 20 | |
| 21 | namespace KTextEditor |
| 22 | { |
| 23 | /*! |
| 24 | * \class KTextEditor::InlineNote |
| 25 | * \inmodule KTextEditor |
| 26 | * \inheaderfile KTextEditor/InlineNote |
| 27 | * |
| 28 | * \brief Describes an inline note. |
| 29 | * |
| 30 | * This class contains all the information required to deal with a particular |
| 31 | * inline note. It is instantiated and populated with information internally by |
| 32 | * KTextEditor based on the list of notes returned by InlineNoteProvider::inlineNotes(), |
| 33 | * and then passed back to the user of the API. |
| 34 | * |
| 35 | * \note Users of the InlineNoteInterface API should never create a InlineNote |
| 36 | * themselves. Maybe it helps to think of a InlineNote as if it were a |
| 37 | * QModelIndex. Only the internal KTextEditor implementation creates them. |
| 38 | * |
| 39 | * \since 5.50 |
| 40 | */ |
| 41 | class KTEXTEDITOR_EXPORT InlineNote |
| 42 | { |
| 43 | public: |
| 44 | /*! |
| 45 | * Constructs an inline note. User code never calls this constructor, |
| 46 | * since notes are created internally only from the columns returned by |
| 47 | * InlineNoteProvider::inlineNotes(), and then passed around as handles |
| 48 | * grouping useful information. |
| 49 | */ |
| 50 | InlineNote(const KateInlineNoteData &data); |
| 51 | |
| 52 | /*! |
| 53 | * Returns the width of this note in pixels. |
| 54 | */ |
| 55 | qreal width() const; |
| 56 | |
| 57 | /*! |
| 58 | * The provider which created this note |
| 59 | */ |
| 60 | InlineNoteProvider *provider() const; |
| 61 | |
| 62 | /*! |
| 63 | * The View this note is shown in. |
| 64 | */ |
| 65 | const KTextEditor::View *view() const; |
| 66 | |
| 67 | /*! |
| 68 | * The cursor position of this note. |
| 69 | */ |
| 70 | KTextEditor::Cursor position() const; |
| 71 | |
| 72 | /*! |
| 73 | * The index of this note, i.e. its index in the vector returned by |
| 74 | * the provider for a given line |
| 75 | */ |
| 76 | int index() const; |
| 77 | |
| 78 | /*! |
| 79 | * Returns whether the mouse cursor is currently over this note. |
| 80 | * \note This flag is useful when in InlineNoteProvider::paintInlineNote(). |
| 81 | */ |
| 82 | bool underMouse() const; |
| 83 | |
| 84 | /*! |
| 85 | * The font of the text surrounding this note. |
| 86 | * This can be used to obtain the QFontMetrics or similar font information. |
| 87 | */ |
| 88 | QFont font() const; |
| 89 | |
| 90 | /*! |
| 91 | * The height of the line containing this note |
| 92 | */ |
| 93 | int lineHeight() const; |
| 94 | |
| 95 | private: |
| 96 | // Internal implementation data structure. |
| 97 | const KateInlineNoteData &d; |
| 98 | }; |
| 99 | |
| 100 | } |
| 101 | |
| 102 | #endif |
| 103 | |