VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h

Last change on this file was 106061, checked in by vboxsync, 3 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.6 KB
Line 
1/* $Id: UIChooserItemMachine.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIChooserItemMachine class declaration.
4 */
5
6/*
7 * Copyright (C) 2012-2024 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_chooser_UIChooserItemMachine_h
29#define FEQT_INCLUDED_SRC_manager_chooser_UIChooserItemMachine_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* GUI includes: */
35#include "UIChooserItem.h"
36#include "UIManagerDefs.h"
37
38/* Forward declarations: */
39class UIChooserNodeMachine;
40class UIVirtualMachineItem;
41
42
43/** UIChooserItem extension implementing machine item. */
44class UIChooserItemMachine : public UIChooserItem
45{
46 Q_OBJECT;
47
48public:
49
50 /** RTTI required for qgraphicsitem_cast. */
51 enum { Type = UIChooserNodeType_Machine };
52
53 /** Build item for certain @a pNode, passing @a pParent to the base-class. */
54 UIChooserItemMachine(UIChooserItem *pParent, UIChooserNodeMachine *pNode);
55 /** Destructs machine item. */
56 virtual ~UIChooserItemMachine() RT_OVERRIDE;
57
58 /** @name Item stuff.
59 * @{ */
60 /** Returns machine node reference. */
61 UIChooserNodeMachine *nodeToMachineType() const;
62 /** Returns item machine id. */
63 QUuid id() const;
64 /** Returns whether item accessible. */
65 bool accessible() const;
66
67 /** Returns virtual machine cache instance. */
68 UIVirtualMachineItem *cache() const;
69 /** Returns virtual machine cache type. */
70 UIVirtualMachineItemType cacheType() const;
71
72 /** Recaches item contents. */
73 void recache();
74
75 /** Returns whether VM is locked. */
76 bool isLockedMachine() const;
77
78 /** Returns whether passed @a position belongs to tool button area. */
79 bool isToolButtonArea(const QPoint &position, int iMarginMultiplier = 1) const;
80 /** @} */
81
82 /** @name Navigation stuff.
83 * @{ */
84 /** Class-name used for drag&drop mime-data format. */
85 static QString className();
86
87 /** Enumerates machine items from @a il to @a ol using @a iEnumerationFlags. */
88 static void enumerateMachineItems(const QList<UIChooserItem*> &il,
89 QList<UIChooserItemMachine*> &ol,
90 int iEnumerationFlags = 0);
91 /** @} */
92
93protected:
94
95 /** @name Event-handling stuff.
96 * @{ */
97 /** Handles show @a pEvent. */
98 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
99
100 /** Handles resize @a pEvent. */
101 virtual void resizeEvent(QGraphicsSceneResizeEvent *pEvent) RT_OVERRIDE;
102
103 /** Handles mouse press @a pEvent. */
104 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) RT_OVERRIDE;
105
106 /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */
107 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *pWidget = 0) RT_OVERRIDE;
108 /** @} */
109
110 /** @name Item stuff.
111 * @{ */
112 /** Returns RTTI item type. */
113 virtual int type() const RT_OVERRIDE { return Type; }
114
115 /** Defines item as @a fSelected. */
116 virtual void setSelected(bool fSelected) RT_OVERRIDE;
117
118 /** Starts item editing. */
119 virtual void startEditing() RT_OVERRIDE;
120
121 /** Updates item. */
122 virtual void updateItem() RT_OVERRIDE;
123 /** Updates item tool-tip. */
124 virtual void updateToolTip() RT_OVERRIDE;
125 /** @} */
126
127 /** @name Children stuff.
128 * @{ */
129 /** Returns children items of certain @a enmType. */
130 virtual QList<UIChooserItem*> items(UIChooserNodeType enmType = UIChooserNodeType_Any) const RT_OVERRIDE;
131
132 /** Adds possible @a fFavorite child @a pItem to certain @a iPosition. */
133 virtual void addItem(UIChooserItem *pItem, bool fFavorite, int iPosition) RT_OVERRIDE;
134 /** Removes child @a pItem. */
135 virtual void removeItem(UIChooserItem *pItem) RT_OVERRIDE;
136
137 /** Searches for a first child item answering to specified @a strSearchTag and @a iSearchFlags. */
138 virtual UIChooserItem *searchForItem(const QString &strSearchTag, int iSearchFlags) RT_OVERRIDE;
139
140 /** Searches for a first machine child item. */
141 virtual UIChooserItem *firstMachineItem() RT_OVERRIDE;
142 /** @} */
143
144 /** @name Layout stuff.
145 * @{ */
146 /** Updates layout. */
147 virtual void updateLayout() RT_OVERRIDE;
148
149 /** Returns minimum width-hint. */
150 virtual int minimumWidthHint() const RT_OVERRIDE;
151 /** Returns minimum height-hint. */
152 virtual int minimumHeightHint() const RT_OVERRIDE;
153
154 /** Returns size-hint.
155 * @param enmWhich Brings size-hint type.
156 * @param constraint Brings size constraint. */
157 virtual QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const RT_OVERRIDE;
158 /** @} */
159
160 /** @name Navigation stuff.
161 * @{ */
162 /** Returns pixmap item representation. */
163 virtual QPixmap toPixmap() RT_OVERRIDE;
164
165 /** Returns whether item drop is allowed.
166 * @param pEvent Brings information about drop event.
167 * @param enmPlace Brings the place of drag token to the drop moment. */
168 virtual bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, UIChooserItemDragToken where) const RT_OVERRIDE;
169 /** Processes item drop.
170 * @param pEvent Brings information about drop event.
171 * @param pFromWho Brings the item according to which we choose drop position.
172 * @param enmPlace Brings the place of drag token to the drop moment (according to item mentioned above). */
173 virtual void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho, UIChooserItemDragToken where) RT_OVERRIDE;
174 /** Reset drag token. */
175 virtual void resetDragToken() RT_OVERRIDE;
176
177 /** Returns D&D mime data. */
178 virtual QMimeData *createMimeData() RT_OVERRIDE;
179 /** @} */
180
181private slots:
182
183 /** @name Item stuff.
184 * @{ */
185 /** Handles top-level window remaps. */
186 void sltHandleWindowRemapped();
187
188 /** Updates first row maximum width. */
189 void sltUpdateFirstRowMaximumWidth() { updateFirstRowMaximumWidth(); }
190 /** @} */
191
192 /** @name Event handling stuff.
193 * @{ */
194 /** Handles translation event. */
195 void sltRetranslateUI();
196 /** @} */
197
198private:
199
200 /** Data field types. */
201 enum MachineItemData
202 {
203 /* Layout hints: */
204 MachineItemData_MarginHL,
205 MachineItemData_MarginHR,
206 MachineItemData_MarginV,
207 MachineItemData_MajorSpacing,
208 MachineItemData_MinorSpacing,
209 MachineItemData_TextSpacing,
210 MachineItemData_ButtonMargin,
211 };
212
213 /** @name Prepare/cleanup cascade.
214 * @{ */
215 /** Prepares all. */
216 void prepare();
217 /** Cleanups all. */
218 void cleanup();
219 /** @} */
220
221 /** @name Item stuff.
222 * @{ */
223 /** Returns abstractly stored data value for certain @a iKey. */
224 QVariant data(int iKey) const;
225 /** @} */
226
227 /** @name Layout stuff.
228 * @{ */
229 /** Updates pixmaps. */
230 void updatePixmaps();
231 /** Updates pixmap. */
232 void updatePixmap();
233 /** Updates state pixmap. */
234 void updateStatePixmap();
235 /** Updates tool pixmap. */
236 void updateToolPixmap();
237 /** Updates first row maximum width. */
238 void updateFirstRowMaximumWidth();
239 /** Updates minimum name width. */
240 void updateMinimumNameWidth();
241 /** Updates minimum snapshot name width. */
242 void updateMinimumSnapshotNameWidth();
243 /** Updates maximum name width. */
244 void updateMaximumNameWidth();
245 /** Updates maximum snapshot name width. */
246 void updateMaximumSnapshotNameWidth();
247 /** Updates visible name. */
248 void updateVisibleName();
249 /** Updates visible snapshot name. */
250 void updateVisibleSnapshotName();
251 /** Updates state text size. */
252 void updateStateTextSize();
253 /** @} */
254
255 /** @name Painting stuff.
256 * @{ */
257 /** Paints background using specified @a pPainter and certain @a rectangle. */
258 void paintBackground(QPainter *pPainter, const QRect &rectangle);
259 /** Paints frame using specified @a pPainter and certain @a rectangle. */
260 void paintFrame(QPainter *pPainter, const QRect &rectangle);
261 /** Paints machine info using specified @a pPainter and certain @a rectangle. */
262 void paintMachineInfo(QPainter *pPainter, const QRect &rectangle);
263 /** @} */
264
265 /** @name Navigation stuff.
266 * @{ */
267 /** Returns whether machine items @a list contains passed @a pItem. */
268 static bool checkIfContains(const QList<UIChooserItemMachine*> &list,
269 UIChooserItemMachine *pItem);
270 /** @} */
271
272 /** @name Item stuff.
273 * @{ */
274 /** Holds item start default lightness. */
275 int m_iDefaultLightnessStart;
276 /** Holds item final default lightness. */
277 int m_iDefaultLightnessFinal;
278 /** Holds item start hover lightness. */
279 int m_iHoverLightnessStart;
280 /** Holds item final hover lightness. */
281 int m_iHoverLightnessFinal;
282 /** Holds item start highlight lightness. */
283 int m_iHighlightLightnessStart;
284 /** Holds item final highlight lightness. */
285 int m_iHighlightLightnessFinal;
286
287 /** Holds item pixmap. */
288 QPixmap m_pixmap;
289 /** Holds item state pixmap. */
290 QPixmap m_statePixmap;
291 /** Holds item tool pixmap. */
292 QPixmap m_toolPixmap;
293
294 /** Holds item visible name. */
295 QString m_strVisibleName;
296 /** Holds item visible snapshot name. */
297 QString m_strVisibleSnapshotName;
298
299 /** Holds item name font. */
300 QFont m_nameFont;
301 /** Holds item snapshot name font. */
302 QFont m_snapshotNameFont;
303 /** Holds item state text font. */
304 QFont m_stateTextFont;
305 /** @} */
306
307 /** @name Layout stuff.
308 * @{ */
309 /** Holds pixmap size. */
310 QSize m_pixmapSize;
311 /** Holds state pixmap size. */
312 QSize m_statePixmapSize;
313 /** Holds tool pixmap size. */
314 QSize m_toolPixmapSize;
315 /** Holds visible name size. */
316 QSize m_visibleNameSize;
317 /** Holds visible snapshot name size. */
318 QSize m_visibleSnapshotNameSize;
319 /** Holds state text size. */
320 QSize m_stateTextSize;
321
322 /** Holds first row maximum width. */
323 int m_iFirstRowMaximumWidth;
324 /** Holds minimum name width. */
325 int m_iMinimumNameWidth;
326 /** Holds maximum name width. */
327 int m_iMaximumNameWidth;
328 /** Holds minimum snapshot name width. */
329 int m_iMinimumSnapshotNameWidth;
330 /** Holds maximum snapshot name width. */
331 int m_iMaximumSnapshotNameWidth;
332 /** @} */
333};
334
335
336#endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooserItemMachine_h */
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