KTextEditor

inlinenote.h
1 /*
2  SPDX-FileCopyrightText: 2018 Sven Brauch <[email protected]>
3  SPDX-FileCopyrightText: 2018 Michal Srb <[email protected]>
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 InlineNote inlinenote.h <KTextEditor/InlineNote>
25  *
26  * Describes an inline note.
27  *
28  * This class contains all the information required to deal with a particular
29  * inline note. It is instantiated and populated with information internally by
30  * KTextEditor based on the list of notes returned by InlineNoteProvider::inlineNotes(),
31  * and then passed back to the user of the API.
32  *
33  * @note Users of the InlineNoteInterface API should never create a InlineNote
34  * themselves. Maybe it helps to think of a InlineNote as if it were a
35  * QModelIndex. Only the internal KTextEditor implementation creates them.
36  *
37  * @since 5.50
38  */
39 class KTEXTEDITOR_EXPORT InlineNote
40 {
41 public:
42  /**
43  * Constructs an inline note. User code never calls this constructor,
44  * since notes are created internally only from the columns returned by
45  * InlineNoteProvider::inlineNotes(), and then passed around as handles
46  * grouping useful information.
47  */
48  InlineNote(const KateInlineNoteData &data);
49 
50  /**
51  * Returns the width of this note in pixels.
52  */
53  qreal width() const;
54 
55  /**
56  * The provider which created this note
57  */
58  InlineNoteProvider *provider() const;
59 
60  /**
61  * The View this note is shown in.
62  */
63  const KTextEditor::View *view() const;
64 
65  /**
66  * The cursor position of this note.
67  */
68  KTextEditor::Cursor position() const;
69 
70  /**
71  * The index of this note, i.e. its index in the vector returned by
72  * the provider for a given line
73  */
74  int index() const;
75 
76  /**
77  * Returns whether the mouse cursor is currently over this note.
78  * @note This flag is useful when in InlineNoteProvider::paintInlineNote().
79  */
80  bool underMouse() const;
81 
82  /**
83  * The font of the text surrounding this note.
84  * This can be used to obtain the QFontMetrics or similar font information.
85  */
86  QFont font() const;
87 
88  /**
89  * The height of the line containing this note
90  */
91  int lineHeight() const;
92 
93 private:
94  // Internal implementation data structure.
95  const KateInlineNoteData &d;
96 };
97 
98 }
99 
100 #endif
Internal data container for KTextEditor::InlineNote interface.
A source of inline notes for a document.
The Cursor represents a position in a Document.
Definition: cursor.h:71
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:22
Describes an inline note.
Definition: inlinenote.h:39
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:146
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Nov 26 2021 22:59:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.