VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/logviewer/UIVMLogViewerTextEdit.h

Last change on this file was 103982, checked in by vboxsync, 2 months ago

FE/Qt: bugref:10624. Replacing override and final keywords with RT_OVERRIDE and RT_FINAL defines.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: UIVMLogViewerTextEdit.h 103982 2024-03-21 11:43:53Z 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
34class UILogScrollLabel;
35
36/* GUI includes: */
37#include "UILibraryDefs.h"
38#include "UIVMLogBookmark.h"
39
40/* Qt includes: */
41#include <QPlainTextEdit>
42
43/* QPlainTextEdit extension with some addtional context menu items,
44 a special scrollbar, line number area, bookmarking support,
45 background watermarking etc.: */
46class UIVMLogViewerTextEdit : public QPlainTextEdit
47{
48 Q_OBJECT;
49
50signals:
51
52 void sigAddBookmark(const UIVMLogBookmark& bookmark);
53 void sigDeleteBookmark(const UIVMLogBookmark& bookmark);
54
55public:
56
57 UIVMLogViewerTextEdit(QWidget* parent = 0);
58
59 int lineNumberAreaWidth();
60 void lineNumberAreaPaintEvent(QPaintEvent *event);
61 /** Forwards the call to scroll bar class */
62 void setScrollBarMarkingsVector(const QVector<float> &vector);
63 /** Forwards the call to scroll bar class */
64 void clearScrollBarMarkingsVector();
65
66 void scrollToLine(int lineNumber);
67 void scrollToBottom();
68 void scrollToTop();
69 void setBookmarkLineSet(const QSet<int>& lineSet);
70 void setShownTextIsFiltered(bool warning);
71
72 void setShowLineNumbers(bool bShowLineNumbers);
73 bool showLineNumbers() const;
74
75 void setWrapLines(bool bWrapLines);
76 bool wrapLines() const;
77
78 /** currentVerticalScrollBarValue is used by UIVMLogPage to store and restore scrolled
79 plain text position as we switch from a tab to another */
80 int currentVerticalScrollBarValue() const;
81 void setCurrentVerticalScrollBarValue(int value);
82 void setCurrentFont(QFont font);
83 void saveScrollBarPosition();
84 void restoreScrollBarPosition();
85
86 void setCursorPosition(int iPosition);
87
88protected:
89
90 virtual void contextMenuEvent(QContextMenuEvent *pEvent) RT_OVERRIDE;
91 virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
92 virtual void mouseMoveEvent(QMouseEvent *pEvent) RT_OVERRIDE;
93 virtual void leaveEvent(QEvent * pEvent) RT_OVERRIDE;
94 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
95
96private slots:
97
98 void sltBookmark();
99 void sltUpdateLineNumberAreaWidth(int newBlockCount);
100 void sltHandleUpdateRequest(const QRect &, int);
101 int visibleLineCount();
102 void sltRetranslateUI();
103
104private:
105
106 /** Configures this (such as palette etc.) */
107 void configure();
108 void prepare();
109 void prepareWidgets();
110 UIVMLogBookmark bookmarkForPos(const QPoint &position);
111 int lineNumberForPos(const QPoint &position);
112 void setMouseCursorLine(int lineNumber);
113 /** If bookmark exists this function removes it, if not it adds the bookmark. */
114 void toggleBookmark(const UIVMLogBookmark& bookmark);
115
116 UIVMLogBookmark m_iContextMenuBookmark;
117 QWidget *m_pLineNumberArea;
118 /** Set of bookmarked lines. This set is updated from UIVMLogPage. This set is
119 used only for lookup in this class. */
120 QSet<int> m_bookmarkLineSet;
121 /** Number of the line under the mouse cursor. */
122 int m_mouseCursorLine;
123 /** If true the we draw a text near the top right corner of the text edit to warn
124 the user the text edit's content is filtered (as oppesed to whole log file content.
125 And we dont display bookmarks and adding/deleting bookmarks are disabled. */
126 bool m_bShownTextIsFiltered;
127 bool m_bShowLineNumbers;
128 bool m_bWrapLines;
129 QString m_strBackgroungText;
130 friend class UILineNumberArea;
131 bool m_bHasContextMenu;
132 int m_iVerticalScrollBarValue;
133 UILogScrollLabel *m_pScrollToBottomLabel;
134 UILogScrollLabel *m_pScrollToTopLabel;
135 QCursor m_originalCursor;
136 };
137
138
139
140
141#endif /* !FEQT_INCLUDED_SRC_logviewer_UIVMLogViewerTextEdit_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use