3 * VBox Debugger GUI - Statistics.
7 * Copyright (C) 2006-2010 Oracle Corporation
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.
18 #ifndef ___Debugger_VBoxDbgStats_h
19 #define ___Debugger_VBoxDbgStats_h
21 #include "VBoxDbgBase.h"
29 class VBoxDbgStatsModel
;
31 /** Pointer to a statistics sample. */
32 typedef struct DBGGUISTATSNODE
*PDBGGUISTATSNODE
;
33 /** Pointer to a const statistics sample. */
34 typedef struct DBGGUISTATSNODE
const *PCDBGGUISTATSNODE
;
38 * The VM statistics tree view.
40 * A tree representation of the STAM statistics.
42 class VBoxDbgStatsView
: public QTreeView
, public VBoxDbgBase
48 * Creates a VM statistics list view widget.
50 * @param a_pDbgGui Pointer to the debugger gui object.
51 * @param a_pModel The model. Will take ownership of this and delete it together
53 * @param a_pParent Parent widget.
55 VBoxDbgStatsView(VBoxDbgGui
*a_pDbgGui
, VBoxDbgStatsModel
*a_pModel
, VBoxDbgStats
*a_pParent
= NULL
);
58 virtual ~VBoxDbgStatsView();
61 * Updates the view with current information from STAM.
62 * This will indirectly update the m_PatStr.
64 * @param rPatStr Selection pattern. NULL means everything, see STAM for further details.
66 void updateStats(const QString
&rPatStr
);
69 * Resets the stats items matching the specified pattern.
70 * This pattern doesn't have to be the one used for update, thus m_PatStr isn't updated.
72 * @param rPatStr Selection pattern. NULL means everything, see STAM for further details.
74 void resetStats(const QString
&rPatStr
);
77 * Resizes the columns to fit the content.
79 void resizeColumnsToContent();
83 * Expands or collapses a sub-tree.
85 * @param a_rIndex The root of the sub-tree.
86 * @param a_fExpanded Expand/collapse.
88 void setSubTreeExpanded(QModelIndex
const &a_rIndex
, bool a_fExpanded
);
93 * @param a_pEvt The event.
95 virtual void contextMenuEvent(QContextMenuEvent
*a_pEvt
);
99 * Slot for handling the view/header context menu.
100 * @param a_rPos The mouse location.
102 void headerContextMenuRequested(const QPoint
&a_rPos
);
104 /** @name Action signal slots.
113 void actAdjColumns();
118 /** Pointer to the data model. */
119 VBoxDbgStatsModel
*m_pModel
;
120 /** The current selection pattern. */
122 /** The parent widget. */
123 VBoxDbgStats
*m_pParent
;
125 /** Leaf item menu. */
127 /** Branch item menu. */
128 QMenu
*m_pBranchMenu
;
132 /** The menu that's currently being executed. */
134 /** The current index relating to the context menu.
135 * Considered invalid if m_pCurMenu is NULL. */
136 QModelIndex m_CurIndex
;
138 /** Expand Tree action. */
139 QAction
*m_pExpandAct
;
140 /** Collapse Tree action. */
141 QAction
*m_pCollapseAct
;
142 /** Refresh Tree action. */
143 QAction
*m_pRefreshAct
;
144 /** Reset Tree action. */
145 QAction
*m_pResetAct
;
146 /** Copy (to clipboard) action. */
148 /** To Log action. */
149 QAction
*m_pToLogAct
;
150 /** To Release Log action. */
151 QAction
*m_pToRelLogAct
;
152 /** Adjust the columns. */
153 QAction
*m_pAdjColumns
;
155 /** Save Tree (to file) action. */
156 QAction
*m_SaveFileAct
;
157 /** Load Tree (from file) action. */
158 QAction
*m_LoadFileAct
;
159 /** Take Snapshot action. */
160 QAction
*m_TakeSnapshotAct
;
161 /** Load Snapshot action. */
162 QAction
*m_LoadSnapshotAct
;
163 /** Diff With Snapshot action. */
164 QAction
*m_DiffSnapshotAct
;
171 * The VM statistics window.
173 * This class displays the statistics of a VM. The UI contains
174 * a entry field for the selection pattern, a refresh interval
175 * spinbutton, and the tree view with the statistics.
177 class VBoxDbgStats
: public VBoxDbgBaseWindow
183 * Creates a VM statistics list view widget.
185 * @param a_pDbgGui Pointer to the debugger gui object.
186 * @param pszPat Initial selection pattern. NULL means everything. (See STAM for details.)
187 * @param uRefreshRate The refresh rate. 0 means not to refresh and is the default.
188 * @param pParent Parent widget.
190 VBoxDbgStats(VBoxDbgGui
*a_pDbgGui
, const char *pszPat
= NULL
, unsigned uRefreshRate
= 0, QWidget
*pParent
= NULL
);
193 virtual ~VBoxDbgStats();
197 * Destroy the widget on close.
199 * @param a_pCloseEvt The close event.
201 virtual void closeEvent(QCloseEvent
*a_pCloseEvt
);
204 /** Apply the activated combobox pattern. */
205 void apply(const QString
&Str
);
206 /** The "All" button was pressed. */
208 /** Refresh the data on timer tick and pattern changed. */
211 * Set the refresh rate.
213 * @param iRefresh The refresh interval in seconds.
215 void setRefresh(int iRefresh
);
218 * Change the focus to the pattern combo box.
220 void actFocusToPat();
224 /** The current selection pattern. */
226 /** The pattern combo box. */
228 /** The refresh rate in seconds.
229 * 0 means not to refresh. */
230 unsigned m_uRefreshRate
;
231 /** The refresh timer .*/
233 /** The tree view widget. */
234 VBoxDbgStatsView
*m_pView
;
236 /** Move to pattern field action. */
237 QAction
*m_pFocusToPat
;