Changeset View
Changeset View
Standalone View
Standalone View
src/include/ktexteditor/inlinenote.h
Show All 22 Lines | |||||
23 | */ | 23 | */ | ||
24 | #ifndef KTEXTEDITOR_INLINENOTE_H | 24 | #ifndef KTEXTEDITOR_INLINENOTE_H | ||
25 | #define KTEXTEDITOR_INLINENOTE_H | 25 | #define KTEXTEDITOR_INLINENOTE_H | ||
26 | 26 | | |||
27 | #include <ktexteditor/view.h> | 27 | #include <ktexteditor/view.h> | ||
28 | #include <ktexteditor/cursor.h> | 28 | #include <ktexteditor/cursor.h> | ||
29 | 29 | | |||
30 | class QFont; | 30 | class QFont; | ||
31 | class KateInlineNoteData; | ||||
31 | namespace KTextEditor { class InlineNoteProvider; } | 32 | namespace KTextEditor { class InlineNoteProvider; } | ||
32 | 33 | | |||
33 | namespace KTextEditor { | 34 | namespace KTextEditor { | ||
34 | 35 | | |||
35 | /** | 36 | /** | ||
36 | * Describes an inline note. | 37 | * Describes an inline note. | ||
37 | * | 38 | * | ||
38 | * This structure contains all the information required to deal with | 39 | * This structure contains all the information required to deal with | ||
Show All 9 Lines | |||||
48 | class KTEXTEDITOR_EXPORT InlineNote | 49 | class KTEXTEDITOR_EXPORT InlineNote | ||
49 | { | 50 | { | ||
50 | public: | 51 | public: | ||
51 | /** | 52 | /** | ||
52 | * Constructs an inline note. User code usually does not need to call this, | 53 | * Constructs an inline note. User code usually does not need to call this, | ||
53 | * notes are created from the columns returned by InlineNoteProvider::inlineNotes(int line), | 54 | * notes are created from the columns returned by InlineNoteProvider::inlineNotes(int line), | ||
54 | * and then passed around as handles grouping useful information. | 55 | * and then passed around as handles grouping useful information. | ||
55 | */ | 56 | */ | ||
56 | InlineNote(InlineNoteProvider* provider, const KTextEditor::Cursor& position, int index, | 57 | InlineNote(const KateInlineNoteData & data); | ||
57 | const KTextEditor::View* view, QFont font, int lineHeight, bool hasFocus); | | |||
58 | | ||||
59 | /** | | |||
60 | * Constructs an invalid inline note, i.e. isValid() will return false. | | |||
61 | */ | | |||
62 | InlineNote(); | | |||
63 | | ||||
64 | /** | | |||
65 | * Returns the column this note appears in. | | |||
66 | */ | | |||
67 | int column() const; | | |||
68 | 58 | | |||
69 | /** | 59 | /** | ||
70 | * Returns the width of this note in pixels. | 60 | * Returns the width of this note in pixels. | ||
71 | */ | 61 | */ | ||
72 | qreal width() const; | 62 | qreal width() const; | ||
73 | 63 | | |||
74 | /** | 64 | /** | ||
75 | * Tells whether this note is valid, i.e. whether it has a valid provider and location set. | | |||
76 | */ | | |||
77 | bool isValid() const; | | |||
78 | | ||||
79 | /** | | |||
80 | * Equality of notes. Only checks provider, index, and position. | | |||
81 | */ | | |||
82 | bool operator==(const InlineNote& other) const; | | |||
83 | | ||||
84 | /** | | |||
85 | * Transforms the given @p pos from note coordinates to global (screen) coordinates. | 65 | * Transforms the given @p pos from note coordinates to global (screen) coordinates. | ||
86 | * | 66 | * | ||
87 | * Useful for showing a popup; to e.g. show a popup at the bottom left corner | 67 | * Useful for showing a popup; to e.g. show a popup at the bottom left corner | ||
88 | * of a note, show it at @c mapToGlobal({0, noteHeight}). | 68 | * of a note, show it at @c mapToGlobal({0, noteHeight}). | ||
89 | */ | 69 | */ | ||
90 | QPoint mapToGlobal(const QPoint& pos) const; | 70 | QPoint mapToGlobal(const QPoint& pos) const; | ||
91 | 71 | | |||
92 | /** | 72 | /** | ||
Show All 13 Lines | |||||
106 | 86 | | |||
107 | /** | 87 | /** | ||
108 | * The index of this note, i.e. its index in the vector returned by | 88 | * The index of this note, i.e. its index in the vector returned by | ||
109 | * the provider for a given line | 89 | * the provider for a given line | ||
110 | */ | 90 | */ | ||
111 | int index() const; | 91 | int index() const; | ||
112 | 92 | | |||
113 | /** | 93 | /** | ||
114 | * Whether the mouse cursor is currently over this note; only set | 94 | * Returns whether the mouse cursor is currently over this note. | ||
115 | * when paintInlineNote() is called | 95 | * @note This flag is only valid when in InlineNoteProvider::paintInlineNote(). | ||
116 | */ | 96 | */ | ||
117 | bool hasFocus() const; | 97 | bool underMouse() const; | ||
118 | 98 | | |||
119 | /** | 99 | /** | ||
120 | * The font of the text surrounding this note | 100 | * The font of the text surrounding this note | ||
121 | */ | 101 | */ | ||
122 | QFont font() const; | 102 | QFont font() const; | ||
123 | 103 | | |||
124 | /** | 104 | /** | ||
125 | * The height of the line containing this note | 105 | * The height of the line containing this note | ||
126 | */ | 106 | */ | ||
127 | int lineHeight() const; | 107 | int lineHeight() const; | ||
128 | 108 | | |||
129 | private: | 109 | private: | ||
130 | InlineNoteProvider* m_provider = nullptr; | 110 | // Internal implementation data structure. | ||
131 | const KTextEditor::View* m_view = nullptr; | 111 | const KateInlineNoteData & d; | ||
132 | KTextEditor::Cursor m_position; | | |||
133 | int m_index = -1; | | |||
134 | bool m_hasFocus = false; | | |||
135 | QFont m_font; | | |||
136 | int m_lineHeight = -1; | | |||
137 | | ||||
138 | // For future use, in case members need to be added. | | |||
139 | // TODO KF6: remove if it turns out this is unneeded. | | |||
140 | class InlineNotePrivate* d = nullptr; | | |||
141 | }; | 112 | }; | ||
142 | 113 | | |||
143 | } | 114 | } | ||
144 | 115 | | |||
145 | #endif | 116 | #endif |