VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.h@ 103977

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