File indexing completed on 2024-05-12 15:45:40

0001 /*
0002     SPDX-FileCopyrightText: 2018 Sven Brauch <mail@svenbrauch.de>
0003     SPDX-FileCopyrightText: 2018 Michal Srb <michalsrb@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KTEXTEDITOR_INLINENOTE_H
0009 #define KTEXTEDITOR_INLINENOTE_H
0010 
0011 #include <ktexteditor/cursor.h>
0012 #include <ktexteditor/view.h>
0013 
0014 class QFont;
0015 class KateInlineNoteData;
0016 namespace KTextEditor
0017 {
0018 class InlineNoteProvider;
0019 }
0020 
0021 namespace KTextEditor
0022 {
0023 /**
0024  * @class InlineNote inlinenote.h <KTextEditor/InlineNote>
0025  *
0026  * Describes an inline note.
0027  *
0028  * This class contains all the information required to deal with a particular
0029  * inline note. It is instantiated and populated with information internally by
0030  * KTextEditor based on the list of notes returned by InlineNoteProvider::inlineNotes(),
0031  * and then passed back to the user of the API.
0032  *
0033  * @note Users of the InlineNoteInterface API should never create a InlineNote
0034  *       themselves. Maybe it helps to think of a InlineNote as if it were a
0035  *       QModelIndex. Only the internal KTextEditor implementation creates them.
0036  *
0037  * @since 5.50
0038  */
0039 class KTEXTEDITOR_EXPORT InlineNote
0040 {
0041 public:
0042     /**
0043      * Constructs an inline note. User code never calls this constructor,
0044      * since notes are created internally only from the columns returned by
0045      * InlineNoteProvider::inlineNotes(), and then passed around as handles
0046      * grouping useful information.
0047      */
0048     InlineNote(const KateInlineNoteData &data);
0049 
0050     /**
0051      * Returns the width of this note in pixels.
0052      */
0053     qreal width() const;
0054 
0055     /**
0056      * The provider which created this note
0057      */
0058     InlineNoteProvider *provider() const;
0059 
0060     /**
0061      * The View this note is shown in.
0062      */
0063     const KTextEditor::View *view() const;
0064 
0065     /**
0066      * The cursor position of this note.
0067      */
0068     KTextEditor::Cursor position() const;
0069 
0070     /**
0071      * The index of this note, i.e. its index in the vector returned by
0072      * the provider for a given line
0073      */
0074     int index() const;
0075 
0076     /**
0077      * Returns whether the mouse cursor is currently over this note.
0078      * @note This flag is useful when in InlineNoteProvider::paintInlineNote().
0079      */
0080     bool underMouse() const;
0081 
0082     /**
0083      * The font of the text surrounding this note.
0084      * This can be used to obtain the QFontMetrics or similar font information.
0085      */
0086     QFont font() const;
0087 
0088     /**
0089      * The height of the line containing this note
0090      */
0091     int lineHeight() const;
0092 
0093 private:
0094     // Internal implementation data structure.
0095     const KateInlineNoteData &d;
0096 };
0097 
0098 }
0099 
0100 #endif