VirtualBox

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

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

FE/Qt. bugref:6699. Some refactoring.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: UIVMLogPage.h 103940 2024-03-20 09:14: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_UIVMLogPage_h
29#define FEQT_INCLUDED_SRC_logviewer_UIVMLogPage_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QSet>
36#include <QWidget>
37#include <QUuid>
38
39/* GUI includes: */
40#include "UIVMLogBookmark.h"
41
42/* Forward declarations: */
43class QHBoxLayout;
44class QPlainTextEdit;
45class QTextDocument;
46class UIVMLogViewerTextEdit;
47class UIVMLogBookmarkManager;
48
49class UIVMLogTab : public QWidget
50{
51
52 Q_OBJECT;
53
54public:
55
56 UIVMLogTab(QWidget *pParent, const QUuid &uMachineId, const QString &strMachineName);
57 const QUuid &machineId() const;
58 const QString machineName() const;
59
60private:
61
62 QUuid m_uMachineId;
63 QString m_strMachineName;
64};
65
66/** UIVMLogPage defines data and functionalities of the each tab page of a UIVMLogViewerWidget.
67 * It stores the original log file content , a list of bookmarks, etc */
68class UIVMLogPage : public UIVMLogTab
69{
70 Q_OBJECT;
71
72signals:
73
74 void sigBookmarksUpdated();
75 void sigLogPageFilteredChanged(bool isFiltered);
76
77public:
78
79 UIVMLogPage(QWidget *pParent, const QUuid &uMachineId, const QString &strMachineName);
80 ~UIVMLogPage();
81
82 /** Returns the width of the current log page. return 0 if there is no current log page: */
83 int defaultLogPageWidth() const;
84
85 QPlainTextEdit *textEdit();
86 QTextDocument *document();
87
88 void setLogContent(const QString &strLogContent, bool fError);
89 const QString& logString() const;
90
91 void setLogFileName(const QString &strFileName);
92 const QString& logFileName() const;
93
94 /** Marks the plain text edit When we dont have a log content. */
95 void markForError();
96
97 void setScrollBarMarkingsVector(const QVector<float> &vector);
98 void clearScrollBarMarkingsVector();
99
100 /** Undos the changes done to textDocument */
101 void documentUndo();
102
103 QVector<UIVMLogBookmark> bookmarkList() const;
104
105 void deleteAllBookmarks();
106 /** Scrolls the plain text edit to the bookmark with index @a bookmarkIndex. */
107 void scrollToBookmark(int bookmarkIndex);
108
109 bool isFiltered() const;
110 void setFiltered(bool filtered);
111
112 void setShowLineNumbers(bool bShowLineNumbers);
113 void setWrapLines(bool bWrapLines);
114
115 QFont currentFont() const;
116 void setCurrentFont(QFont font);
117
118 void setLogFileId(int iLogFileId);
119 int logFileId() const;
120
121 void scrollToEnd();
122
123 void saveScrollBarPosition();
124 void restoreScrollBarPosition();
125
126 void deleteBookmarkByIndex(int iIndex);
127
128private slots:
129
130 void sltAddBookmark(const UIVMLogBookmark& bookmark);
131 void sltDeleteBookmark(const UIVMLogBookmark& bookmark);
132
133private:
134
135 void prepare();
136 void prepareWidgets();
137 void cleanup();
138 void updateTextEditBookmarkLineSet();
139
140 /** Set plaintextEdit's text. Note that the text we
141 * show currently might be different than
142 * m_strLog. For example during filtering. */
143 void setTextEditText(const QString &strText);
144 void setTextEditTextAsHtml(const QString &strText);
145
146 QHBoxLayout *m_pMainLayout;
147 UIVMLogViewerTextEdit *m_pTextEdit;
148 /** Stores the log file (unmodified by filtering etc) content. */
149 QString m_strLog;
150 /** Stores full path and name of the log file. */
151 QString m_strLogFileName;
152 /** Stores the bookmarks of the logpage. All other bookmark related containers are updated wrt. this one. */
153 UIVMLogBookmarkManager *m_pBookmarkManager;
154
155 /** Keeps the index of the selected bookmark. Used especially when moving from one tab to another. */
156 int m_iSelectedBookmarkIndex;
157
158 /** @name Filtering related state variables
159 * @{ */
160 /** Designates whether currently displayed text is log text or a filtered version of it. That is
161 if m_bFiltered is false than (m_strLog == m_pTextEdit->text()). */
162 bool m_bFiltered;
163 /** @} */
164 /** The id we pass to CMachine::ReadLog. Used while refreshing and saving page content. */
165 int m_iLogFileId;
166};
167
168#endif /* !FEQT_INCLUDED_SRC_logviewer_UIVMLogPage_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use