1 | /* $Id: UIVirtualMachineItemCloud.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIVirtualMachineItemCloud class declaration.
|
---|
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_UIVirtualMachineItemCloud_h
|
---|
29 | #define FEQT_INCLUDED_SRC_manager_UIVirtualMachineItemCloud_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* GUI includes: */
|
---|
35 | #include "UIVirtualMachineItem.h"
|
---|
36 |
|
---|
37 | /* COM includes: */
|
---|
38 | #include "CCloudMachine.h"
|
---|
39 |
|
---|
40 | /* Forward declarations: */
|
---|
41 | class UIProgressTask;
|
---|
42 |
|
---|
43 | /** UIVirtualMachineItem sub-class used as cloud Virtual Machine item interface. */
|
---|
44 | class UIVirtualMachineItemCloud : public UIVirtualMachineItem
|
---|
45 | {
|
---|
46 | Q_OBJECT;
|
---|
47 |
|
---|
48 | signals:
|
---|
49 |
|
---|
50 | /** Notifies listeners about refresh started. */
|
---|
51 | void sigRefreshStarted();
|
---|
52 | /** Notifies listeners about refresh finished. */
|
---|
53 | void sigRefreshFinished();
|
---|
54 |
|
---|
55 | public:
|
---|
56 |
|
---|
57 | /** Constructs fake cloud VM item of certain @a enmState. */
|
---|
58 | UIVirtualMachineItemCloud(UIFakeCloudVirtualMachineItemState enmState);
|
---|
59 | /** Constructs real cloud VM item on the basis of taken @a comCloudMachine. */
|
---|
60 | UIVirtualMachineItemCloud(const CCloudMachine &comCloudMachine);
|
---|
61 | /** Destructs cloud VM item. */
|
---|
62 | virtual ~UIVirtualMachineItemCloud() RT_OVERRIDE;
|
---|
63 |
|
---|
64 | /** @name Arguments.
|
---|
65 | * @{ */
|
---|
66 | /** Returns cached cloud machine object. */
|
---|
67 | CCloudMachine machine() const { return m_comCloudMachine; }
|
---|
68 | /** @} */
|
---|
69 |
|
---|
70 | /** @name Data attributes.
|
---|
71 | * @{ */
|
---|
72 | /** Returns cached machine state. */
|
---|
73 | KCloudMachineState machineState() const { return m_enmMachineState; }
|
---|
74 | QUuid machineId() const { return m_comCloudMachine.isOk() ? m_comCloudMachine.GetId() : QUuid(); }
|
---|
75 |
|
---|
76 | /** Defines fake cloud item @a enmState. */
|
---|
77 | void setFakeCloudItemState(UIFakeCloudVirtualMachineItemState enmState);
|
---|
78 | /** Returns fake cloud item state. */
|
---|
79 | UIFakeCloudVirtualMachineItemState fakeCloudItemState() const { return m_enmFakeCloudItemState; }
|
---|
80 |
|
---|
81 | /** Defines fake cloud item @a strErrorMessage. */
|
---|
82 | void setFakeCloudItemErrorMessage(const QString &strErrorMessage);
|
---|
83 | /** Returns fake cloud item error message. */
|
---|
84 | QString fakeCloudItemErrorMessage() const { return m_strFakeCloudItemErrorMessage; }
|
---|
85 |
|
---|
86 | /** Defines whether update is @a fRequired by global reason. */
|
---|
87 | void setUpdateRequiredByGlobalReason(bool fRequired);
|
---|
88 | /** Defines whether update is @a fRequired by local reason. */
|
---|
89 | void setUpdateRequiredByLocalReason(bool fRequired);
|
---|
90 | /** Updates cloud VM info async way, @a fDelayed if requested or instantly otherwise. */
|
---|
91 | void updateInfoAsync(bool fDelayed);
|
---|
92 | /** Makes sure async info update is finished.
|
---|
93 | * @note This method creates own event-loop to avoid blocking calling thread event processing,
|
---|
94 | * so it's safe to call it from the GUI thread, ofc the method itself will be blocked. */
|
---|
95 | void waitForAsyncInfoUpdateFinished();
|
---|
96 | /** @} */
|
---|
97 |
|
---|
98 | /** @name Update stuff.
|
---|
99 | * @{ */
|
---|
100 | /** Recaches machine data. */
|
---|
101 | virtual void recache() RT_OVERRIDE;
|
---|
102 | /** Recaches machine item pixmap. */
|
---|
103 | virtual void recachePixmap() RT_OVERRIDE;
|
---|
104 | /** @} */
|
---|
105 |
|
---|
106 | /** @name Validation stuff.
|
---|
107 | * @{ */
|
---|
108 | /** Returns whether this item is editable. */
|
---|
109 | virtual bool isItemEditable() const RT_OVERRIDE;
|
---|
110 | /** Returns whether this item is removable. */
|
---|
111 | virtual bool isItemRemovable() const RT_OVERRIDE;
|
---|
112 | /** Returns whether this item is saved. */
|
---|
113 | virtual bool isItemSaved() const RT_OVERRIDE;
|
---|
114 | /** Returns whether this item is powered off. */
|
---|
115 | virtual bool isItemPoweredOff() const RT_OVERRIDE;
|
---|
116 | /** Returns whether this item is started. */
|
---|
117 | virtual bool isItemStarted() const RT_OVERRIDE;
|
---|
118 | /** Returns whether this item is running. */
|
---|
119 | virtual bool isItemRunning() const RT_OVERRIDE;
|
---|
120 | /** Returns whether this item is running headless. */
|
---|
121 | virtual bool isItemRunningHeadless() const RT_OVERRIDE;
|
---|
122 | /** Returns whether this item is paused. */
|
---|
123 | virtual bool isItemPaused() const RT_OVERRIDE;
|
---|
124 | /** Returns whether this item is stuck. */
|
---|
125 | virtual bool isItemStuck() const RT_OVERRIDE;
|
---|
126 | /** Returns whether this item can be switched to. */
|
---|
127 | virtual bool isItemCanBeSwitchedTo() const RT_OVERRIDE;
|
---|
128 | /** @} */
|
---|
129 |
|
---|
130 | protected:
|
---|
131 |
|
---|
132 | /** @name Event handling.
|
---|
133 | * @{ */
|
---|
134 | /** Handles translation event. */
|
---|
135 | virtual void retranslateUi() RT_OVERRIDE;
|
---|
136 | /** @} */
|
---|
137 |
|
---|
138 | private slots:
|
---|
139 |
|
---|
140 | /** Handles signal about cloud VM info refresh progress is done. */
|
---|
141 | void sltHandleRefreshCloudMachineInfoDone();
|
---|
142 |
|
---|
143 | private:
|
---|
144 |
|
---|
145 | /** @name Prepare/Cleanup cascade.
|
---|
146 | * @{ */
|
---|
147 | /** Prepares all. */
|
---|
148 | void prepare();
|
---|
149 | /** Cleanups all. */
|
---|
150 | void cleanup();
|
---|
151 | /** @} */
|
---|
152 |
|
---|
153 | /** @name Arguments.
|
---|
154 | * @{ */
|
---|
155 | /** Holds cached cloud machine object. */
|
---|
156 | CCloudMachine m_comCloudMachine;
|
---|
157 | /** @} */
|
---|
158 |
|
---|
159 | /** @name Data attributes.
|
---|
160 | * @{ */
|
---|
161 | /** Holds cached machine state. */
|
---|
162 | KCloudMachineState m_enmMachineState;
|
---|
163 |
|
---|
164 | /** Holds fake cloud item state. */
|
---|
165 | UIFakeCloudVirtualMachineItemState m_enmFakeCloudItemState;
|
---|
166 | /** Holds fake cloud item error message. */
|
---|
167 | QString m_strFakeCloudItemErrorMessage;
|
---|
168 |
|
---|
169 | /** Holds whether update is required by global reason. */
|
---|
170 | bool m_fUpdateRequiredByGlobalReason;
|
---|
171 | /** Holds whether update is required by local reason. */
|
---|
172 | bool m_fUpdateRequiredByLocalReason;
|
---|
173 | /** Holds the refresh progress-task instance. */
|
---|
174 | UIProgressTask *m_pProgressTaskRefresh;
|
---|
175 | /** @} */
|
---|
176 | };
|
---|
177 |
|
---|
178 | #endif /* !FEQT_INCLUDED_SRC_manager_UIVirtualMachineItemCloud_h */
|
---|