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 | 58 | | |||
59 | /** | 59 | /** | ||
60 | * Constructs an invalid inline note, i.e. isValid() will return false. | 60 | * Constructs an invalid inline note, i.e. isValid() will return false. | ||
61 | */ | 61 | */ | ||
62 | InlineNote(); | 62 | InlineNote(); | ||
63 | 63 | | |||
64 | /** | 64 | /** | ||
65 | * Returns the column this note appears in. | | |||
66 | */ | | |||
67 | int column() const; | | |||
68 | | ||||
69 | /** | | |||
70 | * Returns the width of this note in pixels. | 65 | * Returns the width of this note in pixels. | ||
71 | */ | 66 | */ | ||
72 | qreal width() const; | 67 | qreal width() const; | ||
73 | 68 | | |||
74 | /** | 69 | /** | ||
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. | 70 | * Transforms the given @p pos from note coordinates to global (screen) coordinates. | ||
86 | * | 71 | * | ||
87 | * Useful for showing a popup; to e.g. show a popup at the bottom left corner | 72 | * 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}). | 73 | * of a note, show it at @c mapToGlobal({0, noteHeight}). | ||
89 | */ | 74 | */ | ||
90 | QPoint mapToGlobal(const QPoint& pos) const; | 75 | QPoint mapToGlobal(const QPoint& pos) const; | ||
91 | 76 | | |||
92 | /** | 77 | /** | ||
Show All 29 Lines | |||||
122 | QFont font() const; | 107 | QFont font() const; | ||
123 | 108 | | |||
124 | /** | 109 | /** | ||
125 | * The height of the line containing this note | 110 | * The height of the line containing this note | ||
126 | */ | 111 | */ | ||
127 | int lineHeight() const; | 112 | int lineHeight() const; | ||
128 | 113 | | |||
129 | private: | 114 | private: | ||
130 | InlineNoteProvider* m_provider = nullptr; | 115 | // Internal implementation data structure. | ||
131 | const KTextEditor::View* m_view = nullptr; | 116 | 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 | }; | 117 | }; | ||
142 | 118 | | |||
143 | } | 119 | } | ||
144 | 120 | | |||
145 | #endif | 121 | #endif |