VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.h

Last change on this file was 104251, checked in by vboxsync, 2 months ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in the manager UI classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.3 KB
Line 
1/* $Id: UIToolsModel.h 104251 2024-04-09 12:36:47Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIToolsModel 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_tools_UIToolsModel_h
29#define FEQT_INCLUDED_SRC_manager_tools_UIToolsModel_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 <QTransform>
39
40/* GUI includes: */
41#include "UIToolsItem.h"
42
43/* COM includes: */
44
45/* Forward declaration: */
46class QGraphicsItem;
47class QGraphicsScene;
48class QGraphicsSceneContextMenuEvent;
49class QMenu;
50class QPaintDevice;
51class QTimer;
52class UIActionPool;
53class UITools;
54class UIToolsHandlerMouse;
55class UIToolsHandlerKeyboard;
56
57/** QObject extension used as VM Tools-pane model: */
58class UIToolsModel : public QObject
59{
60 Q_OBJECT;
61
62signals:
63
64 /** @name General stuff.
65 * @{ */
66 /** Notifies about closing request. */
67 void sigClose();
68 /** @} */
69
70 /** @name Selection stuff.
71 * @{ */
72 /** Notifies about selection changed.
73 * @param enmType Brings current tool type. */
74 void sigSelectionChanged(UIToolType enmType);
75 /** Notifies about focus changed. */
76 void sigFocusChanged();
77
78 /** Notifies about group expanding started. */
79 void sigExpandingStarted();
80 /** Notifies about group expanding finished. */
81 void sigExpandingFinished();
82 /** @} */
83
84 /** @name Layout stuff.
85 * @{ */
86 /** Notifies about item minimum width @a iHint changed. */
87 void sigItemMinimumWidthHintChanged(int iHint);
88 /** Notifies about item minimum height @a iHint changed. */
89 void sigItemMinimumHeightHintChanged(int iHint);
90 /** @} */
91
92public:
93
94 /** Constructs Tools-model passing @a pParent to the base-class.
95 * @param Brings the tools class, it will be fixed one. */
96 UIToolsModel(UIToolClass enmClass, UITools *pParent);
97 /** Destructs Tools-model. */
98 virtual ~UIToolsModel() RT_OVERRIDE;
99
100 /** @name General stuff.
101 * @{ */
102 /** Inits model. */
103 void init();
104
105 /** Returns the Tools reference. */
106 UITools *tools() const;
107 /** Returns the action-pool reference. */
108 UIActionPool *actionPool() const;
109 /** Returns the scene reference. */
110 QGraphicsScene *scene() const;
111 /** Returns the paint device reference. */
112 QPaintDevice *paintDevice() const;
113
114 /** Returns item at @a position, taking into account possible @a deviceTransform. */
115 QGraphicsItem *itemAt(const QPointF &position, const QTransform &deviceTransform = QTransform()) const;
116
117 /** Defines current tools @a enmType. */
118 void setToolsType(UIToolType enmType);
119 /** Returns current tools type. */
120 UIToolType toolsType() const;
121
122 /** Defines whether tool items @a fEnabled.*/
123 void setItemsEnabled(bool fEnabled);
124 /** Returns whether tool items enabled.*/
125 bool isItemsEnabled() const;
126
127 /** Defines restructed tool @a types. */
128 void setRestrictedToolTypes(const QList<UIToolType> &types);
129 /** Returns restricted tool types. */
130 QList<UIToolType> restrictedToolTypes() const;
131
132 /** Asks parent to close. */
133 void close();
134 /** @} */
135
136 /** @name Children stuff.
137 * @{ */
138 /** Returns the item list. */
139 QList<UIToolsItem*> items() const;
140
141 /** Returns the item of passed @a enmType. */
142 UIToolsItem *item(UIToolType enmType) const;
143 /** @} */
144
145 /** @name Selection stuff.
146 * @{ */
147 /** Defines current @a pItem. */
148 void setCurrentItem(UIToolsItem *pItem);
149 /** Returns current item. */
150 UIToolsItem *currentItem() const;
151
152 /** Defines focus @a pItem. */
153 void setFocusItem(UIToolsItem *pItem);
154 /** Returns focus item. */
155 UIToolsItem *focusItem() const;
156 /** @} */
157
158 /** @name Navigation stuff.
159 * @{ */
160 /** Returns navigation item list. */
161 const QList<UIToolsItem*> &navigationList() const;
162 /** Removes @a pItem from navigation list. */
163 void removeFromNavigationList(UIToolsItem *pItem);
164 /** Updates navigation list. */
165 void updateNavigation();
166 /** @} */
167
168 /** @name Layout stuff.
169 * @{ */
170 /** Updates layout. */
171 void updateLayout();
172 /** @} */
173
174public slots:
175
176 /** @name General stuff.
177 * @{ */
178 /** Handles Tools-view resize. */
179 void sltHandleViewResized() { updateLayout(); }
180 /** @} */
181
182 /** @name Children stuff.
183 * @{ */
184 /** Handles minimum width hint change. */
185 void sltItemMinimumWidthHintChanged();
186 /** Handles minimum height hint change. */
187 void sltItemMinimumHeightHintChanged();
188 /** @} */
189
190protected:
191
192 /** @name Event handling stuff.
193 * @{ */
194 /** Preprocesses Qt @a pEvent for passed @a pObject. */
195 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
196 /** @} */
197
198private slots:
199
200 /** @name Selection stuff.
201 * @{ */
202 /** Handles focus item destruction. */
203 void sltFocusItemDestroyed();
204 /** @} */
205
206 /** @name Event handling stuff.
207 * @{ */
208 /** Handles translation event. */
209 void sltRetranslateUI();
210 /** @} */
211
212private:
213
214 /** Data field types. */
215 enum ToolsModelData
216 {
217 /* Layout hints: */
218 ToolsModelData_Margin,
219 ToolsModelData_Spacing,
220 };
221
222 /** @name Prepare/Cleanup cascade.
223 * @{ */
224 /** Prepares all. */
225 void prepare();
226 /** Prepares scene. */
227 void prepareScene();
228 /** Prepares items. */
229 void prepareItems();
230 /** Prepares handlers. */
231 void prepareHandlers();
232 /** Loads settings. */
233 void loadSettings();
234
235 /** Loads last tool types. */
236 static void loadLastToolTypes(UIToolType &enmTypeGlobal, UIToolType &enmTypeMachine);
237
238 /** Cleanups handlers. */
239 void cleanupHandlers();
240 /** Cleanups items. */
241 void cleanupItems();
242 /** Cleanups scene. */
243 void cleanupScene();
244 /** Cleanups all. */
245 void cleanup();
246 /** @} */
247
248 /** @name General stuff.
249 * @{ */
250 /** Returns abstractly stored data value for certain @a iKey. */
251 QVariant data(int iKey) const;
252 /** @} */
253
254 /** @name General stuff.
255 * @{ */
256 /** Holds the tools class. */
257 const UIToolClass m_enmClass;
258
259 /** Holds the Tools reference. */
260 UITools *m_pTools;
261
262 /** Holds the scene reference. */
263 QGraphicsScene *m_pScene;
264
265 /** Holds the mouse handler instance. */
266 UIToolsHandlerMouse *m_pMouseHandler;
267 /** Holds the keyboard handler instance. */
268 UIToolsHandlerKeyboard *m_pKeyboardHandler;
269
270 /** Holds whether items enabled. */
271 bool m_fItemsEnabled;
272
273 /** Holds a list of restricted tool types. */
274 QList<UIToolType> m_restrictedToolTypes;
275 /** @} */
276
277 /** @name Children stuff.
278 * @{ */
279 /** Holds the root stack. */
280 QList<UIToolsItem*> m_items;
281 /** @} */
282
283 /** @name Selection stuff.
284 * @{ */
285 /** Holds the selected item reference. */
286 QPointer<UIToolsItem> m_pCurrentItem;
287 /** Holds the focus item reference. */
288 QPointer<UIToolsItem> m_pFocusItem;
289 /** @} */
290
291 /** @name Navigation stuff.
292 * @{ */
293 /** Holds the navigation list. */
294 QList<UIToolsItem*> m_navigationList;
295 /** @} */
296};
297
298#endif /* !FEQT_INCLUDED_SRC_manager_tools_UIToolsModel_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use