VirtualBox

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

Last change on this file since 103977 was 103923, checked in by vboxsync, 9 months ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in log viewer classes.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette