VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsModel.h

Last change on this file was 103803, checked in by vboxsync, 3 months ago

FE/Qt. bugref:10618. Splitting COMEnums.h file into individual enum header files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h79562-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h79645-79692
    /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h79225,​79271
File size: 12.3 KB
Line 
1/* $Id: UIDetailsModel.h 103803 2024-03-12 11:15:18Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIDetailsModel class declaration.
4 */
5
6/*
7 * Copyright (C) 2012-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 FEQT_INCLUDED_SRC_manager_details_UIDetailsModel_h
29#define FEQT_INCLUDED_SRC_manager_details_UIDetailsModel_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMap>
36#include <QObject>
37#include <QPointer>
38#include <QSet>
39
40/* GUI includes: */
41#include "UIExtraDataDefs.h"
42
43/* COM includes: */
44
45/* Forward declaration: */
46class QGraphicsItem;
47class QGraphicsScene;
48class QGraphicsSceneContextMenuEvent;
49class QGraphicsView;
50class UIVirtualMachineItem;
51class UIDetails;
52class UIDetailsContextMenu;
53class UIDetailsElement;
54class UIDetailsElementAnimationCallback;
55class UIDetailsGroup;
56class UIDetailsItem;
57class UIDetailsView;
58
59
60/** QObject sub-class used as graphics details model. */
61class UIDetailsModel : public QObject
62{
63 Q_OBJECT;
64
65signals:
66
67 /** Notifies listeners about model root item @a iMinimumWidthHint changed. */
68 void sigRootItemMinimumWidthHintChanged(int iMinimumWidthHint);
69
70 /** Notifies listeners about element link clicked.
71 * @param strCategory Brings details element category.
72 * @param strControl Brings settings control to select.
73 * @param uId Brings ID of the machine details referring. */
74 void sigLinkClicked(const QString &strCategory, const QString &strControl, const QUuid &uId);
75
76public:
77
78 /** Constructs a details model passing @a pParent to the base-class.
79 * @param pParent Brings the details container to embed into. */
80 UIDetailsModel(UIDetails *pParent);
81 /** Destructs a details model. */
82 virtual ~UIDetailsModel() RT_OVERRIDE;
83
84 /** Inits model. */
85 void init();
86
87 /** Returns graphics scene this model belongs to. */
88 QGraphicsScene *scene() const;
89 /** Returns the reference of the first view of the scene(). */
90 UIDetailsView *view() const;
91 /** Returns paint device this model belongs to. */
92 QGraphicsView *paintDevice() const;
93
94 /** Returns graphics item as certain @a position. */
95 QGraphicsItem *itemAt(const QPointF &position) const;
96
97 /** Returns the details pane reference. */
98 UIDetails *details() const { return m_pDetails; }
99
100 /** Returns the root item instance. */
101 UIDetailsItem *root() const;
102
103 /** Updates layout by positioning items manually. */
104 void updateLayout();
105
106 /** Defines virtual machine @a items for this model to reflect. */
107 void setItems(const QList<UIVirtualMachineItem*> &items);
108
109 /** Returns the details categories. */
110 const QMap<DetailsElementType, bool> &categories() const { return m_categories; }
111 /** Defines the details @a categories. */
112 void setCategories(const QMap<DetailsElementType, bool> &categories);
113
114 /** Returns options for General element. */
115 UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral optionsGeneral() const { return m_fOptionsGeneral; }
116 /** Defines @a fOptions for General element. */
117 void setOptionsGeneral(UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral fOptions);
118
119 /** Returns options for System element. */
120 UIExtraDataMetaDefs::DetailsElementOptionTypeSystem optionsSystem() const { return m_fOptionsSystem; }
121 /** Defines @a fOptions for System element. */
122 void setOptionsSystem(UIExtraDataMetaDefs::DetailsElementOptionTypeSystem fOptions);
123
124 /** Returns options for Display element. */
125 UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay optionsDisplay() const { return m_fOptionsDisplay; }
126 /** Defines @a fOptions for Display element. */
127 void setOptionsDisplay(UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay fOptions);
128
129 /** Returns options for Storage element. */
130 UIExtraDataMetaDefs::DetailsElementOptionTypeStorage optionsStorage() const { return m_fOptionsStorage; }
131 /** Defines @a fOptions for Storage element. */
132 void setOptionsStorage(UIExtraDataMetaDefs::DetailsElementOptionTypeStorage fOptions);
133
134 /** Returns options for Audio element. */
135 UIExtraDataMetaDefs::DetailsElementOptionTypeAudio optionsAudio() const { return m_fOptionsAudio; }
136 /** Defines @a fOptions for Audio element. */
137 void setOptionsAudio(UIExtraDataMetaDefs::DetailsElementOptionTypeAudio fOptions);
138
139 /** Returns options for Network element. */
140 UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork optionsNetwork() const { return m_fOptionsNetwork; }
141 /** Defines @a fOptions for Network element. */
142 void setOptionsNetwork(UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork fOptions);
143
144 /** Returns options for Serial element. */
145 UIExtraDataMetaDefs::DetailsElementOptionTypeSerial optionsSerial() const { return m_fOptionsSerial; }
146 /** Defines @a fOptions for Serial element. */
147 void setOptionsSerial(UIExtraDataMetaDefs::DetailsElementOptionTypeSerial fOptions);
148
149 /** Returns options for Usb element. */
150 UIExtraDataMetaDefs::DetailsElementOptionTypeUsb optionsUsb() const { return m_fOptionsUsb; }
151 /** Defines @a fOptions for Usb element. */
152 void setOptionsUsb(UIExtraDataMetaDefs::DetailsElementOptionTypeUsb fOptions);
153
154 /** Returns options for Shared Folders element. */
155 UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders optionsSharedFolders() const { return m_fOptionsSharedFolders; }
156 /** Defines @a fOptions for Shared Folders element. */
157 void setOptionsSharedFolders(UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders fOptions);
158
159 /** Returns options for User Interface element. */
160 UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface optionsUserInterface() const { return m_fOptionsUserInterface; }
161 /** Defines @a fOptions for User Interface element. */
162 void setOptionsUserInterface(UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface fOptions);
163
164 /** Returns options for Description element. */
165 UIExtraDataMetaDefs::DetailsElementOptionTypeDescription optionsDescription() const { return m_fOptionsDescription; }
166 /** Defines @a fOptions for Description element. */
167 void setOptionsDescription(UIExtraDataMetaDefs::DetailsElementOptionTypeDescription fOptions);
168
169public slots:
170
171 /** Handle details view resize. */
172 void sltHandleViewResize();
173
174 /** Handles chooser pane signal about group toggle started. */
175 void sltHandleToggleStarted();
176 /** Handles chooser pane signal about group toggle finished. */
177 void sltHandleToggleFinished();
178
179 /** Handle extra-data categories change. */
180 void sltHandleExtraDataCategoriesChange();
181 /** Handle extra-data options change for category of certain @a enmType. */
182 void sltHandleExtraDataOptionsChange(DetailsElementType enmType);
183
184 /** Handles request to start toggle details element of certain @a enmType, making element @a fToggled. */
185 void sltToggleElements(DetailsElementType type, bool fToggled);
186
187protected:
188
189 /** Preprocesses any Qt @a pEvent for passed @a pObject. */
190 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
191
192private slots:
193
194 /** Handles sigal about details element of certain @a enmType toggling finished, making element @a fToggled. */
195 void sltToggleAnimationFinished(DetailsElementType type, bool fToggled);
196
197private:
198
199 /** @name Prepare/Cleanup cascade.
200 * @{ */
201 /** Prepares all. */
202 void prepare();
203 /** Prepares scene. */
204 void prepareScene();
205 /** Prepares root. */
206 void prepareRoot();
207 /** Prepares context-menu. */
208 void prepareContextMenu();
209 /** Loads settings. */
210 void loadSettings();
211 /** Loads details categories. */
212 void loadDetailsCategories();
213 /** Loads details options for certain category @a enmType.
214 * @note enmType equal to DetailsElementType_Invalid means load everything. */
215 void loadDetailsOptions(DetailsElementType enmType = DetailsElementType_Invalid);
216
217 /** Cleanups context-menu. */
218 void cleanupContextMenu();
219 /** Cleanups root. */
220 void cleanupRoot();
221 /** Cleanups scene. */
222 void cleanupScene();
223 /** Cleanups all. */
224 void cleanup();
225 /** @} */
226
227 /** Performs handling for allowed context menu @a pEvent. */
228 bool processContextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent);
229
230 /** Holds the details reference. */
231 UIDetails *m_pDetails;
232
233 /** Holds the graphics scene reference. */
234 QGraphicsScene *m_pScene;
235 /** Holds the root element instance. */
236 UIDetailsGroup *m_pRoot;
237 /** Holds the element animation callback instance. */
238 UIDetailsElementAnimationCallback *m_pAnimationCallback;
239
240 /** Holds the details categories. */
241 QMap<DetailsElementType, bool> m_categories;
242
243 /** Holds the options for General element. */
244 UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral m_fOptionsGeneral;
245 /** Holds the options for System element. */
246 UIExtraDataMetaDefs::DetailsElementOptionTypeSystem m_fOptionsSystem;
247 /** Holds the options for Display element. */
248 UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay m_fOptionsDisplay;
249 /** Holds the options for Storage element. */
250 UIExtraDataMetaDefs::DetailsElementOptionTypeStorage m_fOptionsStorage;
251 /** Holds the options for Audio element. */
252 UIExtraDataMetaDefs::DetailsElementOptionTypeAudio m_fOptionsAudio;
253 /** Holds the options for Network element. */
254 UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork m_fOptionsNetwork;
255 /** Holds the options for Serial element. */
256 UIExtraDataMetaDefs::DetailsElementOptionTypeSerial m_fOptionsSerial;
257 /** Holds the options for Usb element. */
258 UIExtraDataMetaDefs::DetailsElementOptionTypeUsb m_fOptionsUsb;
259 /** Holds the options for Shared Folders element. */
260 UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders m_fOptionsSharedFolders;
261 /** Holds the options for User Interface element. */
262 UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface m_fOptionsUserInterface;
263 /** Holds the options for Description element. */
264 UIExtraDataMetaDefs::DetailsElementOptionTypeDescription m_fOptionsDescription;
265
266 /** Holds the context-menu instance. */
267 UIDetailsContextMenu *m_pContextMenu;
268};
269
270
271/** QObject sub-class used as details element animation callback. */
272class UIDetailsElementAnimationCallback : public QObject
273{
274 Q_OBJECT;
275
276signals:
277
278 /** Notifies listeners about all animations finished.
279 * @param enmType Brings the type of element item which was animated.
280 * @param fToggled Brings whether elements being toggled to be closed or opened. */
281 void sigAllAnimationFinished(DetailsElementType enmType, bool fToggled);
282
283public:
284
285 /** Constructors details element animation callback passing @a pParent to the base-class.
286 * @param enmType Brings the type of element item which was animated.
287 * @param fToggled Brings whether elements being toggled to be closed or opened. */
288 UIDetailsElementAnimationCallback(QObject *pParent, DetailsElementType enmType, bool fToggled);
289
290 /** Adds notifier for a certain details @a pItem. */
291 void addNotifier(UIDetailsElement *pItem);
292
293private slots:
294
295 /** Handles a signal about animation finnished. */
296 void sltAnimationFinished();
297
298private:
299
300 /** Holds the list of elements which notifies this callback about completion. */
301 QList<UIDetailsElement*> m_notifiers;
302 /** Holds the type of element item which was animated. */
303 DetailsElementType m_enmType;
304 /** Holds whether elements being toggled to be closed or opened. */
305 bool m_fToggled;
306};
307
308
309#endif /* !FEQT_INCLUDED_SRC_manager_details_UIDetailsModel_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use