KTextEditor

annotationinterface.h
1/*
2 SPDX-FileCopyrightText: 2008 Andreas Pakulat <apaku@gmx.de>
3 SPDX-FileCopyrightText: 2008-2018 Dominik Haumann <dhaumann@kde.org>
4 SPDX-FileCopyrightText: 2017-2018 Friedrich W. H. Kossebau <kossebau@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KTEXTEDITOR_ANNOTATIONINTERFACE_H
10#define KTEXTEDITOR_ANNOTATIONINTERFACE_H
11
12#include <ktexteditor_export.h>
13
14#include <QObject>
15
16class QMenu;
17
18namespace KTextEditor
19{
20class View;
21class AbstractAnnotationItemDelegate;
22
23/**
24 * \brief An model for providing line annotation information
25 *
26 * \section annomodel_intro Introduction
27 *
28 * AnnotationModel is a model-like interface that can be implemented
29 * to provide annotation information for each line in a document. It provides
30 * means to retrieve several kinds of data for a given line in the document.
31 *
32 * \section annomodel_impl Implementing a AnnotationModel
33 *
34 * The public interface of this class is loosely based on the QAbstractItemModel
35 * interfaces. It only has a single method to override which is the \ref data()
36 * method to provide the actual data for a line and role combination.
37 *
38 * \since 4.1
39 * \see KTextEditor::AnnotationInterface, KTextEditor::AnnotationViewInterface
40 */
41class KTEXTEDITOR_EXPORT AnnotationModel : public QObject
42{
43 Q_OBJECT
44public:
45 ~AnnotationModel() override;
46
47 enum {
48 GroupIdentifierRole = Qt::UserRole
49 };
50 // KF6: add AnnotationModelUserRole = Qt::UserRole + 0x100
51
52 /**
53 * data() is used to retrieve the information needed to present the
54 * annotation information from the annotation model. The provider
55 * should return useful information for the line and the data role.
56 *
57 * The following roles are supported:
58 * - Qt::DisplayRole - a short display text to be placed in the border
59 * - Qt::TooltipRole - a tooltip information, longer text possible
60 * - Qt::BackgroundRole - a brush to be used to paint the background on the border
61 * - Qt::ForegroundRole - a brush to be used to paint the text on the border
62 * - AnnotationModel::GroupIdentifierRole - a string which identifies a
63 * group of items which will be highlighted on mouseover; return the same
64 * string for all items in a group (KDevelop uses a VCS revision number, for example)
65 *
66 *
67 * \param line the line for which the data is to be retrieved
68 * \param role the role to identify which kind of annotation is to be retrieved
69 *
70 * \returns a QVariant that contains the data for the given role.
71 */
72 virtual QVariant data(int line, Qt::ItemDataRole role) const = 0; // KF6: use int for role
73
74Q_SIGNALS:
75 /**
76 * The model should emit the signal reset() when the text of almost all
77 * lines changes. In most cases it is enough to call lineChanged().
78 *
79 * \note Kate Part implementation details: Whenever reset() is emitted Kate
80 * Part iterates over all lines of the document. Kate Part searches
81 * for the longest text to determine the annotation border's width.
82 *
83 * \see lineChanged()
84 */
85 void reset();
86
87 /**
88 * The model should emit the signal lineChanged() when a line has to be
89 * updated.
90 *
91 * \note Kate Part implementation details: lineChanged() repaints the whole
92 * annotation border automatically.
93 */
94 void lineChanged(int line);
95};
96
97} // namespace KTextEditor
98
99#endif
An model for providing line annotation information.
virtual QVariant data(int line, Qt::ItemDataRole role) const =0
data() is used to retrieve the information needed to present the annotation information from the anno...
void reset()
The model should emit the signal reset() when the text of almost all lines changes.
void lineChanged(int line)
The model should emit the signal lineChanged() when a line has to be updated.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.