1 | /* $Id: UIVMLogViewerTextEdit.h 98844 2023-03-06 17:21:13Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIVMLogViewer class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_logviewer_UIVMLogViewerTextEdit_h
|
---|
29 | #define FEQT_INCLUDED_SRC_logviewer_UIVMLogViewerTextEdit_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* GUI includes: */
|
---|
35 | #include "QIWithRetranslateUI.h"
|
---|
36 | #include "UIVMLogBookmark.h"
|
---|
37 |
|
---|
38 | /* Qt includes: */
|
---|
39 | #include <QPlainTextEdit>
|
---|
40 |
|
---|
41 | /* QPlainTextEdit extension with some addtional context menu items,
|
---|
42 | a special scrollbar, line number area, bookmarking support,
|
---|
43 | background watermarking etc.: */
|
---|
44 | class UIVMLogViewerTextEdit : public QIWithRetranslateUI<QPlainTextEdit>
|
---|
45 | {
|
---|
46 | Q_OBJECT;
|
---|
47 |
|
---|
48 | signals:
|
---|
49 |
|
---|
50 | void sigAddBookmark(const UIVMLogBookmark& bookmark);
|
---|
51 | void sigDeleteBookmark(const UIVMLogBookmark& bookmark);
|
---|
52 |
|
---|
53 | public:
|
---|
54 |
|
---|
55 | UIVMLogViewerTextEdit(QWidget* parent = 0);
|
---|
56 |
|
---|
57 | int lineNumberAreaWidth();
|
---|
58 | void lineNumberAreaPaintEvent(QPaintEvent *event);
|
---|
59 | /** Forwards the call to scroll bar class */
|
---|
60 | void setScrollBarMarkingsVector(const QVector<float> &vector);
|
---|
61 | /** Forwards the call to scroll bar class */
|
---|
62 | void clearScrollBarMarkingsVector();
|
---|
63 |
|
---|
64 | void scrollToLine(int lineNumber);
|
---|
65 | void scrollToEnd();
|
---|
66 | void setBookmarkLineSet(const QSet<int>& lineSet);
|
---|
67 | void setShownTextIsFiltered(bool warning);
|
---|
68 |
|
---|
69 | void setShowLineNumbers(bool bShowLineNumbers);
|
---|
70 | bool showLineNumbers() const;
|
---|
71 |
|
---|
72 | void setWrapLines(bool bWrapLines);
|
---|
73 | bool wrapLines() const;
|
---|
74 |
|
---|
75 | /** currentVerticalScrollBarValue is used by UIVMLogPage to store and restore scrolled
|
---|
76 | plain text position as we switch from a tab to another */
|
---|
77 | int currentVerticalScrollBarValue() const;
|
---|
78 | void setCurrentVerticalScrollBarValue(int value);
|
---|
79 | void setCurrentFont(QFont font);
|
---|
80 | void saveScrollBarPosition();
|
---|
81 | void restoreScrollBarPosition();
|
---|
82 |
|
---|
83 | void setCursorPosition(int iPosition);
|
---|
84 |
|
---|
85 | protected:
|
---|
86 |
|
---|
87 | virtual void contextMenuEvent(QContextMenuEvent *pEvent) RT_OVERRIDE;
|
---|
88 | virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
|
---|
89 | virtual void mouseMoveEvent(QMouseEvent *pEvent) RT_OVERRIDE;
|
---|
90 | virtual void leaveEvent(QEvent * pEvent) RT_OVERRIDE;
|
---|
91 | virtual void retranslateUi() RT_OVERRIDE;
|
---|
92 |
|
---|
93 | private slots:
|
---|
94 |
|
---|
95 | void sltBookmark();
|
---|
96 | void sltUpdateLineNumberAreaWidth(int newBlockCount);
|
---|
97 | void sltHandleUpdateRequest(const QRect &, int);
|
---|
98 | int visibleLineCount();
|
---|
99 |
|
---|
100 | private:
|
---|
101 |
|
---|
102 | /** Configures this (such as palette etc.) */
|
---|
103 | void configure();
|
---|
104 | void prepare();
|
---|
105 | void prepareWidgets();
|
---|
106 | UIVMLogBookmark bookmarkForPos(const QPoint &position);
|
---|
107 | int lineNumberForPos(const QPoint &position);
|
---|
108 | void setMouseCursorLine(int lineNumber);
|
---|
109 | /** If bookmark exists this function removes it, if not it adds the bookmark. */
|
---|
110 | void toggleBookmark(const UIVMLogBookmark& bookmark);
|
---|
111 |
|
---|
112 | UIVMLogBookmark m_iContextMenuBookmark;
|
---|
113 | QWidget *m_pLineNumberArea;
|
---|
114 | /** Set of bookmarked lines. This set is updated from UIVMLogPage. This set is
|
---|
115 | used only for lookup in this class. */
|
---|
116 | QSet<int> m_bookmarkLineSet;
|
---|
117 | /** Number of the line under the mouse cursor. */
|
---|
118 | int m_mouseCursorLine;
|
---|
119 | /** If true the we draw a text near the top right corner of the text edit to warn
|
---|
120 | the user the text edit's content is filtered (as oppesed to whole log file content.
|
---|
121 | And we dont display bookmarks and adding/deleting bookmarks are disabled. */
|
---|
122 | bool m_bShownTextIsFiltered;
|
---|
123 | bool m_bShowLineNumbers;
|
---|
124 | bool m_bWrapLines;
|
---|
125 | QString m_strBackgroungText;
|
---|
126 | friend class UILineNumberArea;
|
---|
127 | bool m_bHasContextMenu;
|
---|
128 | int m_iVerticalScrollBarValue;
|
---|
129 | };
|
---|
130 |
|
---|
131 |
|
---|
132 |
|
---|
133 |
|
---|
134 | #endif /* !FEQT_INCLUDED_SRC_logviewer_UIVMLogViewerTextEdit_h */
|
---|