1 | /* $Id: VBoxDbgStatsQt.h 103462 2024-02-19 23:26:11Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Debugger GUI - Statistics.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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 DEBUGGER_INCLUDED_SRC_VBoxDbgStatsQt_h
|
---|
29 | #define DEBUGGER_INCLUDED_SRC_VBoxDbgStatsQt_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include "VBoxDbgBase.h"
|
---|
35 |
|
---|
36 | #include <QTreeView>
|
---|
37 | #include <QTimer>
|
---|
38 | #include <QComboBox>
|
---|
39 | #include <QMenu>
|
---|
40 |
|
---|
41 | class VBoxDbgStats;
|
---|
42 | class VBoxDbgStatsModel;
|
---|
43 | class VBoxDbgStatsSortFileProxyModel;
|
---|
44 |
|
---|
45 | /** Pointer to a statistics sample. */
|
---|
46 | typedef struct DBGGUISTATSNODE *PDBGGUISTATSNODE;
|
---|
47 | /** Pointer to a const statistics sample. */
|
---|
48 | typedef struct DBGGUISTATSNODE const *PCDBGGUISTATSNODE;
|
---|
49 |
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * The VM statistics tree view.
|
---|
53 | *
|
---|
54 | * A tree representation of the STAM statistics.
|
---|
55 | */
|
---|
56 | class VBoxDbgStatsView : public QTreeView, public VBoxDbgBase
|
---|
57 | {
|
---|
58 | Q_OBJECT;
|
---|
59 |
|
---|
60 | public:
|
---|
61 | /**
|
---|
62 | * Creates a VM statistics list view widget.
|
---|
63 | *
|
---|
64 | * @param a_pDbgGui Pointer to the debugger gui object.
|
---|
65 | * @param a_pModel The model. Will take ownership of this and delete it
|
---|
66 | * together with the view later
|
---|
67 | * @param a_pProxyModel The proxy model object to use for sorting and
|
---|
68 | * filtering.
|
---|
69 | * @param a_pParent Parent widget.
|
---|
70 | */
|
---|
71 | VBoxDbgStatsView(VBoxDbgGui *a_pDbgGui, VBoxDbgStatsModel *a_pModel, VBoxDbgStatsSortFileProxyModel *a_pProxyModel,
|
---|
72 | VBoxDbgStats *a_pParent = NULL);
|
---|
73 |
|
---|
74 | /** Destructor. */
|
---|
75 | virtual ~VBoxDbgStatsView();
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Updates the view with current information from STAM.
|
---|
79 | *
|
---|
80 | * This will indirectly update the m_PatStr.
|
---|
81 | *
|
---|
82 | * @param rPatStr Selection pattern. NULL means everything, see STAM for further details.
|
---|
83 | */
|
---|
84 | void updateStats(const QString &rPatStr);
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Shows or hides the unused rows.
|
---|
88 | *
|
---|
89 | * @param a_fShow Whether to show (@c true) or hide (@c false) unused
|
---|
90 | * rows.
|
---|
91 | */
|
---|
92 | void setShowUnusedRows(bool a_fShow);
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * Resets the stats items matching the specified pattern.
|
---|
96 | *
|
---|
97 | * This pattern doesn't have to be the one used for update, thus m_PatStr isn't updated.
|
---|
98 | *
|
---|
99 | * @param rPatStr Selection pattern. NULL means everything, see STAM for further details.
|
---|
100 | */
|
---|
101 | void resetStats(const QString &rPatStr);
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * Resizes the columns to fit the content.
|
---|
105 | */
|
---|
106 | void resizeColumnsToContent();
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Expands the trees matching the given expression.
|
---|
110 | *
|
---|
111 | * @param rPatStr Selection pattern.
|
---|
112 | */
|
---|
113 | void expandMatching(const QString &rPatStr);
|
---|
114 |
|
---|
115 | protected:
|
---|
116 | /**
|
---|
117 | * @callback_method_impl{VBoxDbgStatsModel::FNITERATOR,
|
---|
118 | * Worker for expandMatching}.
|
---|
119 | */
|
---|
120 | static bool expandMatchingCallback(PDBGGUISTATSNODE pNode, QModelIndex const &a_rIndex, const char *pszFullName, void *pvUser);
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * Expands or collapses a sub-tree.
|
---|
124 | *
|
---|
125 | * @param a_rIndex The root of the sub-tree.
|
---|
126 | * @param a_fExpanded Expand/collapse.
|
---|
127 | */
|
---|
128 | void setSubTreeExpanded(QModelIndex const &a_rIndex, bool a_fExpanded);
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * Popup context menu.
|
---|
132 | *
|
---|
133 | * @param a_pEvt The event.
|
---|
134 | */
|
---|
135 | virtual void contextMenuEvent(QContextMenuEvent *a_pEvt);
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * Gets the model index of the root node.
|
---|
139 | *
|
---|
140 | * This takes proxy / no-proxy into account.
|
---|
141 | *
|
---|
142 | * @returns root index for.
|
---|
143 | */
|
---|
144 | QModelIndex myGetRootIndex(void) const;
|
---|
145 |
|
---|
146 | protected slots:
|
---|
147 | /**
|
---|
148 | * Slot for handling the view/header context menu.
|
---|
149 | * @param a_rPos The mouse location.
|
---|
150 | */
|
---|
151 | void headerContextMenuRequested(const QPoint &a_rPos);
|
---|
152 |
|
---|
153 | /** @name Action signal slots.
|
---|
154 | * @{ */
|
---|
155 | void actExpand();
|
---|
156 | void actCollapse();
|
---|
157 | void actRefresh();
|
---|
158 | void actReset();
|
---|
159 | void actCopy();
|
---|
160 | void actToLog();
|
---|
161 | void actToRelLog();
|
---|
162 | void actAdjColumns();
|
---|
163 | void actFilter();
|
---|
164 | /** @} */
|
---|
165 |
|
---|
166 |
|
---|
167 | protected:
|
---|
168 | /** Pointer to the data model. */
|
---|
169 | VBoxDbgStatsModel *m_pVBoxModel;
|
---|
170 | /** Pointer to the proxy data model for sorting & filtering. */
|
---|
171 | VBoxDbgStatsSortFileProxyModel *m_pProxyModel;
|
---|
172 | /** Either m_pVBoxModel or m_pProxyModel. */
|
---|
173 | QAbstractItemModel *m_pModel;
|
---|
174 | /** The current selection pattern. */
|
---|
175 | QString m_PatStr;
|
---|
176 | /** The parent widget. */
|
---|
177 | VBoxDbgStats *m_pParent;
|
---|
178 |
|
---|
179 | /** Leaf item menu. */
|
---|
180 | QMenu *m_pLeafMenu;
|
---|
181 | /** Branch item menu. */
|
---|
182 | QMenu *m_pBranchMenu;
|
---|
183 | /** View menu. */
|
---|
184 | QMenu *m_pViewMenu;
|
---|
185 |
|
---|
186 | /** The menu that's currently being executed. */
|
---|
187 | QMenu *m_pCurMenu;
|
---|
188 | /** The current index relating to the context menu.
|
---|
189 | * Considered invalid if m_pCurMenu is NULL. */
|
---|
190 | QModelIndex m_CurIndex;
|
---|
191 |
|
---|
192 | /** Expand Tree action. */
|
---|
193 | QAction *m_pExpandAct;
|
---|
194 | /** Collapse Tree action. */
|
---|
195 | QAction *m_pCollapseAct;
|
---|
196 | /** Refresh Tree action. */
|
---|
197 | QAction *m_pRefreshAct;
|
---|
198 | /** Reset Tree action. */
|
---|
199 | QAction *m_pResetAct;
|
---|
200 | /** Copy (to clipboard) action. */
|
---|
201 | QAction *m_pCopyAct;
|
---|
202 | /** To Log action. */
|
---|
203 | QAction *m_pToLogAct;
|
---|
204 | /** To Release Log action. */
|
---|
205 | QAction *m_pToRelLogAct;
|
---|
206 | /** Adjust the columns. */
|
---|
207 | QAction *m_pAdjColumnsAct;
|
---|
208 | /** Filter sub-tree action. */
|
---|
209 | QAction *m_pFilterAct;
|
---|
210 | #if 0
|
---|
211 | /** Save Tree (to file) action. */
|
---|
212 | QAction *m_SaveFileAct;
|
---|
213 | /** Load Tree (from file) action. */
|
---|
214 | QAction *m_LoadFileAct;
|
---|
215 | /** Take Snapshot action. */
|
---|
216 | QAction *m_TakeSnapshotAct;
|
---|
217 | /** Load Snapshot action. */
|
---|
218 | QAction *m_LoadSnapshotAct;
|
---|
219 | /** Diff With Snapshot action. */
|
---|
220 | QAction *m_DiffSnapshotAct;
|
---|
221 | #endif
|
---|
222 | };
|
---|
223 |
|
---|
224 |
|
---|
225 |
|
---|
226 | /**
|
---|
227 | * The VM statistics window.
|
---|
228 | *
|
---|
229 | * This class displays the statistics of a VM. The UI contains
|
---|
230 | * a entry field for the selection pattern, a refresh interval
|
---|
231 | * spinbutton, and the tree view with the statistics.
|
---|
232 | */
|
---|
233 | class VBoxDbgStats : public VBoxDbgBaseWindow
|
---|
234 | {
|
---|
235 | Q_OBJECT;
|
---|
236 |
|
---|
237 | public:
|
---|
238 | /**
|
---|
239 | * Creates a VM statistics list view widget.
|
---|
240 | *
|
---|
241 | * @param a_pDbgGui Pointer to the debugger gui object.
|
---|
242 | * @param pszFilter Initial selection pattern. NULL means everything.
|
---|
243 | * (See STAM for details.)
|
---|
244 | * @param pszExpand Initial expansion pattern. NULL means nothing is
|
---|
245 | * expanded.
|
---|
246 | * @param uRefreshRate The refresh rate. 0 means not to refresh and is the default.
|
---|
247 | * @param pParent Parent widget.
|
---|
248 | */
|
---|
249 | VBoxDbgStats(VBoxDbgGui *a_pDbgGui, const char *pszFilter = NULL, const char *pszExpand = NULL,
|
---|
250 | unsigned uRefreshRate = 0, QWidget *pParent = NULL);
|
---|
251 |
|
---|
252 | /** Destructor. */
|
---|
253 | virtual ~VBoxDbgStats();
|
---|
254 |
|
---|
255 | protected:
|
---|
256 | /**
|
---|
257 | * Destroy the widget on close.
|
---|
258 | *
|
---|
259 | * @param a_pCloseEvt The close event.
|
---|
260 | */
|
---|
261 | virtual void closeEvent(QCloseEvent *a_pCloseEvt);
|
---|
262 |
|
---|
263 | protected slots:
|
---|
264 | /** Apply the activated combobox pattern. */
|
---|
265 | void apply(const QString &Str);
|
---|
266 | /** The "All" button was pressed. */
|
---|
267 | void applyAll();
|
---|
268 | /** Refresh the data on timer tick and pattern changed. */
|
---|
269 | void refresh();
|
---|
270 | /**
|
---|
271 | * Set the refresh rate.
|
---|
272 | *
|
---|
273 | * @param iRefresh The refresh interval in seconds.
|
---|
274 | */
|
---|
275 | void setRefresh(int iRefresh);
|
---|
276 |
|
---|
277 | /**
|
---|
278 | * Change the focus to the pattern combo box.
|
---|
279 | */
|
---|
280 | void actFocusToPat();
|
---|
281 |
|
---|
282 | /** The 'show unused rows' checkbox changed. */
|
---|
283 | void sltShowUnusedRowsChanged(int a_iState);
|
---|
284 |
|
---|
285 | protected:
|
---|
286 |
|
---|
287 | /** The current selection pattern. */
|
---|
288 | QString m_PatStr;
|
---|
289 | /** The pattern combo box. */
|
---|
290 | QComboBox *m_pPatCB;
|
---|
291 | /** The refresh rate in seconds.
|
---|
292 | * 0 means not to refresh. */
|
---|
293 | unsigned m_uRefreshRate;
|
---|
294 | /** The refresh timer .*/
|
---|
295 | QTimer *m_pTimer;
|
---|
296 | /** The tree view widget. */
|
---|
297 | VBoxDbgStatsView *m_pView;
|
---|
298 |
|
---|
299 | /** Move to pattern field action. */
|
---|
300 | QAction *m_pFocusToPat;
|
---|
301 | };
|
---|
302 |
|
---|
303 |
|
---|
304 | #endif /* !DEBUGGER_INCLUDED_SRC_VBoxDbgStatsQt_h */
|
---|
305 |
|
---|