KTextEditor

inlinenoteinterface.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_INLINENOTEINTERFACE_H
9 #define KTEXTEDITOR_INLINENOTEINTERFACE_H
10 
11 #include <QString>
12 
13 #include <ktexteditor_export.h>
14 
15 #include <ktexteditor/cursor.h>
16 #include <ktexteditor/view.h>
17 
18 class QPainter;
19 
20 namespace KTextEditor
21 {
22 class InlineNoteProvider;
23 
24 /**
25  * @class InlineNoteInterface inlinenoteinterface.h <KTextEditor/InlineNoteInterface>
26  *
27  * @brief Inline notes interface for rendering notes in the text.
28  *
29  * @ingroup kte_group_view_extensions
30  *
31  * @section inlinenote_introduction Introduction
32  *
33  * The inline notes interface provides a way to render arbitrary things in
34  * the text. The text layout of the line is adapted to create space for the
35  * note. Possible applications include showing a name of a function parameter
36  * in a function call or rendering a square with a color preview next to CSS
37  * color property.
38  *
39  * \image html inlinenote.png "Inline note showing a CSS color preview"
40  *
41  * To register as inline note provider, call registerInlineNoteProvider() with
42  * an instance that inherits InlineNoteProvider. Finally, make sure you remove
43  * your inline note provider by calling unregisterInlineNoteProvider().
44  *
45  * @section inlinenote_access Accessing the InlineNoteInterface
46  *
47  * The InlineNoteInterface is an extension interface for a
48  * View, i.e. the View inherits the interface. Use qobject_cast to access the
49  * interface:
50  * @code
51  * // view is of type KTextEditor::View*
52  * auto iface = qobject_cast<KTextEditor::InlineNoteInterface*>(view);
53  *
54  * if (iface) {
55  * // the implementation supports the interface
56  * // myProvider inherits KTextEditor::InlineNoteProvider
57  * iface->registerInlineNoteProvider(myProvider);
58  * } else {
59  * // the implementation does not support the interface
60  * }
61  * @endcode
62  *
63  * @see InlineNoteProvider
64  * @see InlineNote
65  *
66  * @author Sven Brauch, Michal Srb
67  * @since 5.50
68  */
69 class KTEXTEDITOR_EXPORT InlineNoteInterface
70 {
71 public:
73  virtual ~InlineNoteInterface();
74 
75  /**
76  * Register the inline note provider @p provider.
77  *
78  * Whenever a line is painted, the @p provider will be queried for notes
79  * that should be painted in it. When the provider is about to be
80  * destroyed, make sure to call unregisterInlineNoteProvider() to avoid a
81  * dangling pointer.
82  *
83  * @param provider inline note provider
84  * @see unregisterInlineNoteProvider(), InlineNoteProvider
85  */
86  virtual void registerInlineNoteProvider(KTextEditor::InlineNoteProvider *provider) = 0;
87 
88  /**
89  * Unregister the inline note provider @p provider.
90  *
91  * @param provider inline note provider to unregister
92  * @see registerInlineNoteProvider(), InlineNoteProvider
93  */
94  virtual void unregisterInlineNoteProvider(KTextEditor::InlineNoteProvider *provider) = 0;
95 };
96 
97 }
98 
99 Q_DECLARE_INTERFACE(KTextEditor::InlineNoteInterface, "org.kde.KTextEditor.InlineNoteInterface")
100 
101 #endif
A source of inline notes for a document.
Inline notes interface for rendering notes in the text.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:21
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 01:49:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.