File indexing completed on 2024-03-24 04:00:41
0001 /* 0002 SPDX-FileCopyrightText: 2016 Dominik Haumann <dhaumann@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KATE_TEXT_PREVIEW_H 0008 #define KATE_TEXT_PREVIEW_H 0009 0010 #include <QFrame> 0011 0012 // namespace KTextEditor { class DocumentPrivate; } 0013 namespace KTextEditor 0014 { 0015 class ViewPrivate; 0016 } 0017 0018 /** 0019 * TODO 0020 */ 0021 class KateTextPreview : public QFrame 0022 { 0023 Q_OBJECT 0024 Q_PROPERTY(qreal line READ line WRITE setLine) 0025 Q_PROPERTY(bool showFoldedLines READ showFoldedLines WRITE setShowFoldedLines) 0026 Q_PROPERTY(bool centerView READ centerView WRITE setCenterView) 0027 Q_PROPERTY(qreal scaleFactor READ scaleFactor WRITE setScaleFactor) 0028 0029 public: 0030 KateTextPreview(KTextEditor::ViewPrivate *view, QWidget *parent); 0031 0032 KTextEditor::ViewPrivate *view() const; 0033 0034 /** 0035 * Sets @p line as preview line. 0036 */ 0037 void setLine(qreal line); 0038 0039 /** 0040 * Returns the line set with setLine(). 0041 */ 0042 qreal line() const; 0043 0044 /** 0045 * Enabled/disable centering the view on the line set with setLine(). 0046 * If @p center is false, the first visible line is the once specified in 0047 * setLine(). If @p center is true, the specified line is vertically 0048 * centered. By default, centering the preview is set to true. 0049 */ 0050 void setCenterView(bool center); 0051 0052 /** 0053 * Returns whether view centering is enabled. 0054 */ 0055 bool centerView() const; 0056 0057 /** 0058 * Sets the scale factor. 0059 * The default scale factor is 1.0. 0060 * For text previews, you may want a scale factor of e.g. 0.75. 0061 * Negative scale factors are not allowed. 0062 */ 0063 void setScaleFactor(qreal factor); 0064 0065 /** 0066 * Returns the scale factor set with setScale(). 0067 * The default value is 1.0. 0068 */ 0069 qreal scaleFactor() const; 0070 0071 /** 0072 * Sets whether folded lines are hidden or not. 0073 * By default, folded liens are not visible. 0074 */ 0075 void setShowFoldedLines(bool on); 0076 0077 /** 0078 * Returns whether folded lines are hidden. 0079 */ 0080 bool showFoldedLines() const; 0081 0082 protected: 0083 void paintEvent(QPaintEvent *event) override; 0084 0085 private: 0086 KTextEditor::ViewPrivate *m_view; 0087 qreal m_line; 0088 bool m_showFoldedLines; 0089 bool m_center; 0090 qreal m_scale; 0091 }; 0092 0093 #endif