VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.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: 7.3 KB
Line 
1/* $Id: UIVirtualMachineItem.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIVirtualMachineItem class declarations.
4 */
5
6/*
7 * Copyright (C) 2006-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_UIVirtualMachineItem_h
29#define FEQT_INCLUDED_SRC_manager_UIVirtualMachineItem_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QIcon>
36#include <QMimeData>
37#include <QPixmap>
38#include <QUuid>
39
40/* GUI includes: */
41#include "UIManagerDefs.h"
42#include "UISettingsDefs.h"
43
44/* Forward declarations: */
45class UIVirtualMachineItemCloud;
46class UIVirtualMachineItemLocal;
47
48/* Using declarations: */
49using namespace UISettingsDefs;
50
51/** Virtual Machine item interface. A wrapper caching VM data. */
52class UIVirtualMachineItem : public QObject
53{
54 Q_OBJECT;
55
56public:
57
58 /** Constructs VM item on the basis of taken @a enmType. */
59 UIVirtualMachineItem(UIVirtualMachineItemType enmType);
60 /** Destructs VM item. */
61 virtual ~UIVirtualMachineItem();
62
63 /** @name RTTI stuff.
64 * @{ */
65 /** Returns item type. */
66 UIVirtualMachineItemType itemType() const { return m_enmType; }
67 /** Returns item casted to local type. */
68 UIVirtualMachineItemLocal *toLocal();
69 /** Returns item casted to cloud type. */
70 UIVirtualMachineItemCloud *toCloud();
71 /** @} */
72
73 /** @name VM access attributes.
74 * @{ */
75 /** Returns whether VM was accessible. */
76 bool accessible() const { return m_fAccessible; }
77 /** Returns the last cached access error. */
78 QString accessError() const { return m_strAccessError; }
79 /** @} */
80
81 /** @name Basic attributes.
82 * @{ */
83 /** Returns cached machine id. */
84 QUuid id() const { return m_uId; }
85 /** Returns cached machine name. */
86 QString name() const { return m_strName; }
87 /** Returns cached machine OS type id. */
88 QString osTypeId() const { return m_strOSTypeId; }
89 /** Returns cached machine OS type pixmap.
90 * @param pLogicalSize Argument to assign actual pixmap size to. */
91 QPixmap osPixmap(QSize *pLogicalSize = 0) const;
92 /** @} */
93
94 /** @name State attributes.
95 * @{ */
96 /** Returns cached machine state name. */
97 QString machineStateName() const { return m_strMachineStateName; }
98 /** Returns cached machine state icon. */
99 QIcon machineStateIcon() const { return m_machineStateIcon; }
100
101 /** Returns cached configuration access level. */
102 ConfigurationAccessLevel configurationAccessLevel() const { return m_enmConfigurationAccessLevel; }
103 /** @} */
104
105 /** @name Visual attributes.
106 * @{ */
107 /** Returns cached machine tool-tip. */
108 QString toolTipText() const { return m_strToolTipText; }
109 /** @} */
110
111 /** @name Extra-data options.
112 * @{ */
113 /** Returns whether we should show machine details. */
114 bool hasDetails() const { return m_fHasDetails; }
115 /** @} */
116
117 /** @name Update stuff.
118 * @{ */
119 /** Recaches machine data. */
120 virtual void recache() = 0;
121 /** Recaches machine item pixmap. */
122 virtual void recachePixmap() = 0;
123 /** @} */
124
125 /** @name Validation stuff.
126 * @{ */
127 /** Returns whether this item is editable. */
128 virtual bool isItemEditable() const = 0;
129 /** Returns whether this item is removable. */
130 virtual bool isItemRemovable() const = 0;
131 /** Returns whether this item is saved. */
132 virtual bool isItemSaved() const = 0;
133 /** Returns whether this item is powered off. */
134 virtual bool isItemPoweredOff() const = 0;
135 /** Returns whether this item is started. */
136 virtual bool isItemStarted() const = 0;
137 /** Returns whether this item is running. */
138 virtual bool isItemRunning() const = 0;
139 /** Returns whether this item is running headless. */
140 virtual bool isItemRunningHeadless() const = 0;
141 /** Returns whether this item is paused. */
142 virtual bool isItemPaused() const = 0;
143 /** Returns whether this item is stuck. */
144 virtual bool isItemStuck() const = 0;
145 /** Returns whether this item can be switched to. */
146 virtual bool isItemCanBeSwitchedTo() const = 0;
147 /** @} */
148
149protected:
150
151 /** @name RTTI stuff.
152 * @{ */
153 /** Holds item type. */
154 UIVirtualMachineItemType m_enmType;
155 /** @} */
156
157 /** @name VM access attributes.
158 * @{ */
159 /** Holds whether VM was accessible. */
160 bool m_fAccessible;
161 /** Holds the last cached access error. */
162 QString m_strAccessError;
163 /** @} */
164
165 /** @name Basic attributes.
166 * @{ */
167 /** Holds cached machine id. */
168 QUuid m_uId;
169 /** Holds cached machine name. */
170 QString m_strName;
171 /** Holds cached machine OS type id. */
172 QString m_strOSTypeId;
173 /** Holds cached machine OS type pixmap. */
174 QPixmap m_pixmap;
175 /** Holds cached machine OS type pixmap size. */
176 QSize m_logicalPixmapSize;
177 /** @} */
178
179 /** @name State attributes.
180 * @{ */
181 /** Holds cached machine state name. */
182 QString m_strMachineStateName;
183 /** Holds cached machine state name. */
184 QIcon m_machineStateIcon;
185
186 /** Holds configuration access level. */
187 ConfigurationAccessLevel m_enmConfigurationAccessLevel;
188 /** @} */
189
190 /** @name Visual attributes.
191 * @{ */
192 /** Holds cached machine tool-tip. */
193 QString m_strToolTipText;
194 /** @} */
195
196 /** @name Extra-data options.
197 * @{ */
198 /** Holds whether we should show machine details. */
199 bool m_fHasDetails;
200 /** @} */
201};
202
203/* Make the pointer of this class public to the QVariant framework */
204Q_DECLARE_METATYPE(UIVirtualMachineItem *);
205
206/** QMimeData subclass for handling UIVirtualMachineItem mime data. */
207class UIVirtualMachineItemMimeData : public QMimeData
208{
209 Q_OBJECT;
210
211public:
212
213 /** Constructs mime data for passed VM @a pItem. */
214 UIVirtualMachineItemMimeData(UIVirtualMachineItem *pItem);
215
216 /** Returns cached VM item. */
217 UIVirtualMachineItem *item() const { return m_pItem; }
218
219 /** Returns supported format list. */
220 virtual QStringList formats() const RT_OVERRIDE;
221
222 /** Returns UIVirtualMachineItem mime data type. */
223 static QString type() { return m_type; }
224
225private:
226
227 /** Holds cached VM item. */
228 UIVirtualMachineItem *m_pItem;
229
230 /** Holds UIVirtualMachineItem mime data type. */
231 static QString m_type;
232};
233
234#endif /* !FEQT_INCLUDED_SRC_manager_UIVirtualMachineItem_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