VirtualBox

source: vbox/trunk/src/VBox/Debugger/VBoxDbgStatsQt.h@ 103418

Last change on this file since 103418 was 103403, checked in by vboxsync, 12 months ago

VBoxDbg: Added sorting to the statistics as well as filtering out unused rows by default.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 KB
Line 
1/* $Id: VBoxDbgStatsQt.h 103403 2024-02-17 01:51:52Z 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
41class VBoxDbgStats;
42class VBoxDbgStatsModel;
43class VBoxDbgStatsSortFileProxyModel;
44
45/** Pointer to a statistics sample. */
46typedef struct DBGGUISTATSNODE *PDBGGUISTATSNODE;
47/** Pointer to a const statistics sample. */
48typedef struct DBGGUISTATSNODE const *PCDBGGUISTATSNODE;
49
50
51/**
52 * The VM statistics tree view.
53 *
54 * A tree representation of the STAM statistics.
55 */
56class VBoxDbgStatsView : public QTreeView, public VBoxDbgBase
57{
58 Q_OBJECT;
59
60public:
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
115protected:
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
146protected 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 /** @} */
164
165
166protected:
167 /** Pointer to the data model. */
168 VBoxDbgStatsModel *m_pVBoxModel;
169 /** Pointer to the proxy data model for sorting & filtering. */
170 VBoxDbgStatsSortFileProxyModel *m_pProxyModel;
171 /** Either m_pVBoxModel or m_pProxyModel. */
172 QAbstractItemModel *m_pModel;
173 /** The current selection pattern. */
174 QString m_PatStr;
175 /** The parent widget. */
176 VBoxDbgStats *m_pParent;
177
178 /** Leaf item menu. */
179 QMenu *m_pLeafMenu;
180 /** Branch item menu. */
181 QMenu *m_pBranchMenu;
182 /** View menu. */
183 QMenu *m_pViewMenu;
184
185 /** The menu that's currently being executed. */
186 QMenu *m_pCurMenu;
187 /** The current index relating to the context menu.
188 * Considered invalid if m_pCurMenu is NULL. */
189 QModelIndex m_CurIndex;
190
191 /** Expand Tree action. */
192 QAction *m_pExpandAct;
193 /** Collapse Tree action. */
194 QAction *m_pCollapseAct;
195 /** Refresh Tree action. */
196 QAction *m_pRefreshAct;
197 /** Reset Tree action. */
198 QAction *m_pResetAct;
199 /** Copy (to clipboard) action. */
200 QAction *m_pCopyAct;
201 /** To Log action. */
202 QAction *m_pToLogAct;
203 /** To Release Log action. */
204 QAction *m_pToRelLogAct;
205 /** Adjust the columns. */
206 QAction *m_pAdjColumns;
207#if 0
208 /** Save Tree (to file) action. */
209 QAction *m_SaveFileAct;
210 /** Load Tree (from file) action. */
211 QAction *m_LoadFileAct;
212 /** Take Snapshot action. */
213 QAction *m_TakeSnapshotAct;
214 /** Load Snapshot action. */
215 QAction *m_LoadSnapshotAct;
216 /** Diff With Snapshot action. */
217 QAction *m_DiffSnapshotAct;
218#endif
219};
220
221
222
223/**
224 * The VM statistics window.
225 *
226 * This class displays the statistics of a VM. The UI contains
227 * a entry field for the selection pattern, a refresh interval
228 * spinbutton, and the tree view with the statistics.
229 */
230class VBoxDbgStats : public VBoxDbgBaseWindow
231{
232 Q_OBJECT;
233
234public:
235 /**
236 * Creates a VM statistics list view widget.
237 *
238 * @param a_pDbgGui Pointer to the debugger gui object.
239 * @param pszFilter Initial selection pattern. NULL means everything.
240 * (See STAM for details.)
241 * @param pszExpand Initial expansion pattern. NULL means nothing is
242 * expanded.
243 * @param uRefreshRate The refresh rate. 0 means not to refresh and is the default.
244 * @param pParent Parent widget.
245 */
246 VBoxDbgStats(VBoxDbgGui *a_pDbgGui, const char *pszFilter = NULL, const char *pszExpand = NULL,
247 unsigned uRefreshRate = 0, QWidget *pParent = NULL);
248
249 /** Destructor. */
250 virtual ~VBoxDbgStats();
251
252protected:
253 /**
254 * Destroy the widget on close.
255 *
256 * @param a_pCloseEvt The close event.
257 */
258 virtual void closeEvent(QCloseEvent *a_pCloseEvt);
259
260protected slots:
261 /** Apply the activated combobox pattern. */
262 void apply(const QString &Str);
263 /** The "All" button was pressed. */
264 void applyAll();
265 /** Refresh the data on timer tick and pattern changed. */
266 void refresh();
267 /**
268 * Set the refresh rate.
269 *
270 * @param iRefresh The refresh interval in seconds.
271 */
272 void setRefresh(int iRefresh);
273
274 /**
275 * Change the focus to the pattern combo box.
276 */
277 void actFocusToPat();
278
279 /** The 'show unused rows' checkbox changed. */
280 void sltShowUnusedRowsChanged(int a_iState);
281
282protected:
283
284 /** The current selection pattern. */
285 QString m_PatStr;
286 /** The pattern combo box. */
287 QComboBox *m_pPatCB;
288 /** The refresh rate in seconds.
289 * 0 means not to refresh. */
290 unsigned m_uRefreshRate;
291 /** The refresh timer .*/
292 QTimer *m_pTimer;
293 /** The tree view widget. */
294 VBoxDbgStatsView *m_pView;
295
296 /** Move to pattern field action. */
297 QAction *m_pFocusToPat;
298};
299
300
301#endif /* !DEBUGGER_INCLUDED_SRC_VBoxDbgStatsQt_h */
302
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