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