VirtualBox

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

Last change on this file since 82781 was 78462, checked in by vboxsync, 5 years ago

FE/Qt: bugref:9072. Some cleaning in the log viewer.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1/* $Id: UIVMLogPage.h 78462 2019-05-10 14:56:17Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVMLogViewer class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef FEQT_INCLUDED_SRC_logviewer_UIVMLogPage_h
19#define FEQT_INCLUDED_SRC_logviewer_UIVMLogPage_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QWidget>
26/* #include <QMap> */
27#include <QPair>
28
29/* GUI includes: */
30#include "QIManagerDialog.h"
31#include "QIWithRetranslateUI.h"
32
33/* Forward declarations: */
34class QITabWidget;
35class QHBoxLayout;
36class QPlainTextEdit;
37class UIVMLogViewerTextEdit;
38
39/* Type definitions: */
40/** first is line number, second is block text */
41typedef QPair<int, QString> LogBookmark;
42
43/** UIVMLogPage defines data and functionalities of the each tab page of a UIVMLogViewerWidget.
44 * It stores the original log file content , a list of bookmarks, etc */
45class UIVMLogPage : public QIWithRetranslateUI<QWidget>
46{
47 Q_OBJECT;
48
49signals:
50
51 void sigBookmarksUpdated();
52 void sigLogPageFilteredChanged(bool isFiltered);
53
54public:
55
56 UIVMLogPage(QWidget *pParent = 0, int tabIndex = -1);
57 ~UIVMLogPage();
58
59 /** Returns the width of the current log page. return 0 if there is no current log page: */
60 int defaultLogPageWidth() const;
61
62 QPlainTextEdit *textEdit();
63 QTextDocument *document();
64
65 void setTabIndex(int index);
66 int tabIndex() const;
67
68 /* Only to be called when log file is re-read. */
69 void setLogString(const QString &strLog);
70 const QString& logString() const;
71
72 void setLogFileName(const QString &strFileName);
73 const QString& logFileName() const;
74
75 /** Set plaintextEdit's text. Note that the text we
76 * show currently might be different than
77 * m_strLog. For example during filtering. */
78 void setTextEditText(const QString &strText);
79 void setTextEditTextAsHtml(const QString &strText);
80
81 /** Marks the plain text edit When we dont have a log content. */
82 void markForError();
83
84 void setScrollBarMarkingsVector(const QVector<float> &vector);
85 void clearScrollBarMarkingsVector();
86
87 /** Undos the changes done to textDocument */
88 void documentUndo();
89
90 void deleteBookmark(int index);
91
92 const QVector<LogBookmark>& bookmarkVector() const;
93 void setBookmarkVector(const QVector<LogBookmark>& booksmarks);
94
95 void deleteAllBookmarks();
96 /** Scrolls the plain text edit to the bookmark with index @a bookmarkIndex. */
97 void scrollToBookmark(int bookmarkIndex);
98
99 bool isFiltered() const;
100 void setFiltered(bool filtered);
101
102 void setShowLineNumbers(bool bShowLineNumbers);
103 void setWrapLines(bool bWrapLines);
104
105 /** setFilterParameters is called at the end of filtering operation to store the parameter etc.
106 * these parameters are used to decide whether we have to reapply the filter, and if not to
107 * update filter panel with correct line counts etc.*/
108 void setFilterParameters(const QSet<QString> &filterTermSet, int filterOperationType,
109 int iFilteredLineCount, int iUnfilteredLineCount);
110 int filteredLineCount() const;
111 int unfilteredLineCount() const;
112 /** Compares filter parameters with previous filter operation's parameters to decide if the
113 * filter should be applied again. */
114 bool shouldFilterBeApplied(const QSet<QString> &filterTermSet, int filterOperationType) const;
115
116 QFont currentFont() const;
117 void setCurrentFont(QFont font);
118
119private slots:
120
121 void sltAddBookmark(LogBookmark bookmark);
122 void sltDeleteBookmark(LogBookmark bookmark);
123
124private:
125
126 void prepare();
127 void prepareWidgets();
128 void cleanup();
129 void retranslateUi();
130 void updateTextEditBookmarkLineSet();
131 void deleteBookmark(LogBookmark bookmark);
132
133 QHBoxLayout *m_pMainLayout;
134 UIVMLogViewerTextEdit *m_pTextEdit;
135 /** Stores the log file (unmodified) content. */
136 QString m_strLog;
137 /** Stores full path and name of the log file. */
138 QString m_strLogFileName;
139 /** This is the index of the tab containing this widget in UIVMLogViewerWidget. */
140 int m_tabIndex;
141 /** Stores the bookmarks of the logpage. All other bookmark related containers are updated wrt. this one. */
142 QVector<LogBookmark> m_bookmarkVector;
143
144 /** Keeps the index of the selected bookmark. Used especially when moving from one tab to another. */
145 int m_iSelectedBookmarkIndex;
146
147 /** @name Filtering related state variables
148 * @{ */
149 /** Designates whether currently displayed text is log text or a filtered version of it. That is
150 if m_bFiltered is false than (m_strLog == m_pTextEdit->text()). */
151 bool m_bFiltered;
152 /** The set of filter terms used in the last filtering.
153 Used when deciding whether we have to reapply the filter or not. see shouldFilterBeApplied function. */
154 QSet<QString> m_filterTermSet;
155 /** The type of the boolean last filtering operation. Used in deciding whether we have to reapply the
156 filter. see shouldFilterBeApplied function. This is int cast of enum FilterOperatorButton
157 of UIVMLogViewerFilterPanel. */
158 int m_filterOperationType;
159 /** These counts are saveds and restored during filtering operation. If filter is not reapplied these counts
160 are shown in the filter panel. */
161 int m_iFilteredLineCount;
162 int m_iUnfilteredLineCount;
163 /** @} */
164
165};
166
167#endif /* !FEQT_INCLUDED_SRC_logviewer_UIVMLogPage_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use