VirtualBox

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

Last change on this file since 103538 was 98103, checked in by vboxsync, 17 months 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 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIChooserItemMachine 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_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 translation event. */
98 virtual void retranslateUi() RT_OVERRIDE;
99
100 /** Handles show @a pEvent. */
101 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
102
103 /** Handles resize @a pEvent. */
104 virtual void resizeEvent(QGraphicsSceneResizeEvent *pEvent) RT_OVERRIDE;
105
106 /** Handles mouse press @a pEvent. */
107 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) RT_OVERRIDE;
108
109 /** Performs painting using passed @a pPainter, @a pOptions and optionally specified @a pWidget. */
110 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget *pWidget = 0) RT_OVERRIDE;
111 /** @} */
112
113 /** @name Item stuff.
114 * @{ */
115 /** Returns RTTI item type. */
116 virtual int type() const RT_OVERRIDE { return Type; }
117
118 /** Defines item as @a fSelected. */
119 virtual void setSelected(bool fSelected) RT_OVERRIDE;
120
121 /** Starts item editing. */
122 virtual void startEditing() RT_OVERRIDE;
123
124 /** Updates item. */
125 virtual void updateItem() RT_OVERRIDE;
126 /** Updates item tool-tip. */
127 virtual void updateToolTip() RT_OVERRIDE;
128 /** @} */
129
130 /** @name Children stuff.
131 * @{ */
132 /** Returns children items of certain @a enmType. */
133 virtual QList<UIChooserItem*> items(UIChooserNodeType enmType = UIChooserNodeType_Any) const RT_OVERRIDE;
134
135 /** Adds possible @a fFavorite child @a pItem to certain @a iPosition. */
136 virtual void addItem(UIChooserItem *pItem, bool fFavorite, int iPosition) RT_OVERRIDE;
137 /** Removes child @a pItem. */
138 virtual void removeItem(UIChooserItem *pItem) RT_OVERRIDE;
139
140 /** Searches for a first child item answering to specified @a strSearchTag and @a iSearchFlags. */
141 virtual UIChooserItem *searchForItem(const QString &strSearchTag, int iSearchFlags) RT_OVERRIDE;
142
143 /** Searches for a first machine child item. */
144 virtual UIChooserItem *firstMachineItem() RT_OVERRIDE;
145 /** @} */
146
147 /** @name Layout stuff.
148 * @{ */
149 /** Updates layout. */
150 virtual void updateLayout() RT_OVERRIDE;
151
152 /** Returns minimum width-hint. */
153 virtual int minimumWidthHint() const RT_OVERRIDE;
154 /** Returns minimum height-hint. */
155 virtual int minimumHeightHint() const RT_OVERRIDE;
156
157 /** Returns size-hint.
158 * @param enmWhich Brings size-hint type.
159 * @param constraint Brings size constraint. */
160 virtual QSizeF sizeHint(Qt::SizeHint enmWhich, const QSizeF &constraint = QSizeF()) const RT_OVERRIDE;
161 /** @} */
162
163 /** @name Navigation stuff.
164 * @{ */
165 /** Returns pixmap item representation. */
166 virtual QPixmap toPixmap() RT_OVERRIDE;
167
168 /** Returns whether item drop is allowed.
169 * @param pEvent Brings information about drop event.
170 * @param enmPlace Brings the place of drag token to the drop moment. */
171 virtual bool isDropAllowed(QGraphicsSceneDragDropEvent *pEvent, UIChooserItemDragToken where) const RT_OVERRIDE;
172 /** Processes item drop.
173 * @param pEvent Brings information about drop event.
174 * @param pFromWho Brings the item according to which we choose drop position.
175 * @param enmPlace Brings the place of drag token to the drop moment (according to item mentioned above). */
176 virtual void processDrop(QGraphicsSceneDragDropEvent *pEvent, UIChooserItem *pFromWho, UIChooserItemDragToken where) RT_OVERRIDE;
177 /** Reset drag token. */
178 virtual void resetDragToken() RT_OVERRIDE;
179
180 /** Returns D&D mime data. */
181 virtual QMimeData *createMimeData() RT_OVERRIDE;
182 /** @} */
183
184private slots:
185
186 /** @name Item stuff.
187 * @{ */
188 /** Handles top-level window remaps. */
189 void sltHandleWindowRemapped();
190
191 /** Updates first row maximum width. */
192 void sltUpdateFirstRowMaximumWidth() { updateFirstRowMaximumWidth(); }
193 /** @} */
194
195private:
196
197 /** Data field types. */
198 enum MachineItemData
199 {
200 /* Layout hints: */
201 MachineItemData_MarginHL,
202 MachineItemData_MarginHR,
203 MachineItemData_MarginV,
204 MachineItemData_MajorSpacing,
205 MachineItemData_MinorSpacing,
206 MachineItemData_TextSpacing,
207 MachineItemData_ButtonMargin,
208 };
209
210 /** @name Prepare/cleanup cascade.
211 * @{ */
212 /** Prepares all. */
213 void prepare();
214 /** Cleanups all. */
215 void cleanup();
216 /** @} */
217
218 /** @name Item stuff.
219 * @{ */
220 /** Returns abstractly stored data value for certain @a iKey. */
221 QVariant data(int iKey) const;
222 /** @} */
223
224 /** @name Layout stuff.
225 * @{ */
226 /** Updates pixmaps. */
227 void updatePixmaps();
228 /** Updates pixmap. */
229 void updatePixmap();
230 /** Updates state pixmap. */
231 void updateStatePixmap();
232 /** Updates tool pixmap. */
233 void updateToolPixmap();
234 /** Updates first row maximum width. */
235 void updateFirstRowMaximumWidth();
236 /** Updates minimum name width. */
237 void updateMinimumNameWidth();
238 /** Updates minimum snapshot name width. */
239 void updateMinimumSnapshotNameWidth();
240 /** Updates maximum name width. */
241 void updateMaximumNameWidth();
242 /** Updates maximum snapshot name width. */
243 void updateMaximumSnapshotNameWidth();
244 /** Updates visible name. */
245 void updateVisibleName();
246 /** Updates visible snapshot name. */
247 void updateVisibleSnapshotName();
248 /** Updates state text size. */
249 void updateStateTextSize();
250 /** @} */
251
252 /** @name Painting stuff.
253 * @{ */
254 /** Paints background using specified @a pPainter and certain @a rectangle. */
255 void paintBackground(QPainter *pPainter, const QRect &rectangle);
256 /** Paints frame using specified @a pPainter and certain @a rectangle. */
257 void paintFrame(QPainter *pPainter, const QRect &rectangle);
258 /** Paints machine info using specified @a pPainter and certain @a rectangle. */
259 void paintMachineInfo(QPainter *pPainter, const QRect &rectangle);
260 /** @} */
261
262 /** @name Navigation stuff.
263 * @{ */
264 /** Returns whether machine items @a list contains passed @a pItem. */
265 static bool checkIfContains(const QList<UIChooserItemMachine*> &list,
266 UIChooserItemMachine *pItem);
267 /** @} */
268
269 /** @name Item stuff.
270 * @{ */
271 /** Holds item start default lightness. */
272 int m_iDefaultLightnessStart;
273 /** Holds item final default lightness. */
274 int m_iDefaultLightnessFinal;
275 /** Holds item start hover lightness. */
276 int m_iHoverLightnessStart;
277 /** Holds item final hover lightness. */
278 int m_iHoverLightnessFinal;
279 /** Holds item start highlight lightness. */
280 int m_iHighlightLightnessStart;
281 /** Holds item final highlight lightness. */
282 int m_iHighlightLightnessFinal;
283
284 /** Holds item pixmap. */
285 QPixmap m_pixmap;
286 /** Holds item state pixmap. */
287 QPixmap m_statePixmap;
288 /** Holds item tool pixmap. */
289 QPixmap m_toolPixmap;
290
291 /** Holds item visible name. */
292 QString m_strVisibleName;
293 /** Holds item visible snapshot name. */
294 QString m_strVisibleSnapshotName;
295
296 /** Holds item name font. */
297 QFont m_nameFont;
298 /** Holds item snapshot name font. */
299 QFont m_snapshotNameFont;
300 /** Holds item state text font. */
301 QFont m_stateTextFont;
302 /** @} */
303
304 /** @name Layout stuff.
305 * @{ */
306 /** Holds pixmap size. */
307 QSize m_pixmapSize;
308 /** Holds state pixmap size. */
309 QSize m_statePixmapSize;
310 /** Holds tool pixmap size. */
311 QSize m_toolPixmapSize;
312 /** Holds visible name size. */
313 QSize m_visibleNameSize;
314 /** Holds visible snapshot name size. */
315 QSize m_visibleSnapshotNameSize;
316 /** Holds state text size. */
317 QSize m_stateTextSize;
318
319 /** Holds first row maximum width. */
320 int m_iFirstRowMaximumWidth;
321 /** Holds minimum name width. */
322 int m_iMinimumNameWidth;
323 /** Holds maximum name width. */
324 int m_iMaximumNameWidth;
325 /** Holds minimum snapshot name width. */
326 int m_iMinimumSnapshotNameWidth;
327 /** Holds maximum snapshot name width. */
328 int m_iMaximumSnapshotNameWidth;
329 /** @} */
330};
331
332
333#endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooserItemMachine_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use