1/*
2 SPDX-FileCopyrightText: 2016 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATE_TEXT_PREVIEW_H
8#define KATE_TEXT_PREVIEW_H
9
10#include <QFrame>
11
12// namespace KTextEditor { class DocumentPrivate; }
13namespace KTextEditor
14{
15class ViewPrivate;
16}
17
18/**
19 * TODO
20 */
21class KateTextPreview : public QFrame
22{
23 Q_OBJECT
24 Q_PROPERTY(qreal line READ line WRITE setLine)
25 Q_PROPERTY(bool showFoldedLines READ showFoldedLines WRITE setShowFoldedLines)
26 Q_PROPERTY(bool centerView READ centerView WRITE setCenterView)
27 Q_PROPERTY(qreal scaleFactor READ scaleFactor WRITE setScaleFactor)
28
29public:
30 KateTextPreview(KTextEditor::ViewPrivate *view, QWidget *parent);
31
32 KTextEditor::ViewPrivate *view() const;
33
34 /**
35 * Sets @p line as preview line.
36 */
37 void setLine(qreal line);
38
39 /**
40 * Returns the line set with setLine().
41 */
42 qreal line() const;
43
44 /**
45 * Enabled/disable centering the view on the line set with setLine().
46 * If @p center is false, the first visible line is the once specified in
47 * setLine(). If @p center is true, the specified line is vertically
48 * centered. By default, centering the preview is set to true.
49 */
50 void setCenterView(bool center);
51
52 /**
53 * Returns whether view centering is enabled.
54 */
55 bool centerView() const;
56
57 /**
58 * Sets the scale factor.
59 * The default scale factor is 1.0.
60 * For text previews, you may want a scale factor of e.g. 0.75.
61 * Negative scale factors are not allowed.
62 */
63 void setScaleFactor(qreal factor);
64
65 /**
66 * Returns the scale factor set with setScale().
67 * The default value is 1.0.
68 */
69 qreal scaleFactor() const;
70
71 /**
72 * Sets whether folded lines are hidden or not.
73 * By default, folded liens are not visible.
74 */
75 void setShowFoldedLines(bool on);
76
77 /**
78 * Returns whether folded lines are hidden.
79 */
80 bool showFoldedLines() const;
81
82protected:
83 void paintEvent(QPaintEvent *event) override;
84
85private:
86 KTextEditor::ViewPrivate *m_view;
87 qreal m_line;
88 bool m_showFoldedLines;
89 bool m_center;
90 qreal m_scale;
91};
92
93#endif
94

source code of ktexteditor/src/view/katetextpreview.h