[55401] | 1 | /* $Id: UIVirtualMachineItemCloud.h 104251 2024-04-09 12:36:47Z vboxsync $ */
|
---|
[382] | 2 | /** @file
|
---|
[83108] | 3 | * VBox Qt GUI - UIVirtualMachineItemCloud class declaration.
|
---|
[382] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[382] | 8 | *
|
---|
[96407] | 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
|
---|
[382] | 26 | */
|
---|
| 27 |
|
---|
[82960] | 28 | #ifndef FEQT_INCLUDED_SRC_manager_UIVirtualMachineItemCloud_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_manager_UIVirtualMachineItemCloud_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[382] | 33 |
|
---|
[50907] | 34 | /* GUI includes: */
|
---|
[82944] | 35 | #include "UIVirtualMachineItem.h"
|
---|
[50907] | 36 |
|
---|
[83654] | 37 | /* COM includes: */
|
---|
| 38 | #include "CCloudMachine.h"
|
---|
| 39 |
|
---|
[83050] | 40 | /* Forward declarations: */
|
---|
[86774] | 41 | class UIProgressTask;
|
---|
[83050] | 42 |
|
---|
[82960] | 43 | /** UIVirtualMachineItem sub-class used as cloud Virtual Machine item interface. */
|
---|
| 44 | class UIVirtualMachineItemCloud : public UIVirtualMachineItem
|
---|
[8159] | 45 | {
|
---|
[82931] | 46 | Q_OBJECT;
|
---|
| 47 |
|
---|
[83055] | 48 | signals:
|
---|
| 49 |
|
---|
[86748] | 50 | /** Notifies listeners about refresh started. */
|
---|
| 51 | void sigRefreshStarted();
|
---|
| 52 | /** Notifies listeners about refresh finished. */
|
---|
| 53 | void sigRefreshFinished();
|
---|
[83055] | 54 |
|
---|
[8159] | 55 | public:
|
---|
[13790] | 56 |
|
---|
[84610] | 57 | /** Constructs fake cloud VM item of certain @a enmState. */
|
---|
| 58 | UIVirtualMachineItemCloud(UIFakeCloudVirtualMachineItemState enmState);
|
---|
[83654] | 59 | /** Constructs real cloud VM item on the basis of taken @a comCloudMachine. */
|
---|
| 60 | UIVirtualMachineItemCloud(const CCloudMachine &comCloudMachine);
|
---|
[82960] | 61 | /** Destructs cloud VM item. */
|
---|
[93990] | 62 | virtual ~UIVirtualMachineItemCloud() RT_OVERRIDE;
|
---|
[382] | 63 |
|
---|
[83147] | 64 | /** @name Arguments.
|
---|
| 65 | * @{ */
|
---|
[83654] | 66 | /** Returns cached cloud machine object. */
|
---|
| 67 | CCloudMachine machine() const { return m_comCloudMachine; }
|
---|
[83147] | 68 | /** @} */
|
---|
| 69 |
|
---|
[83129] | 70 | /** @name Data attributes.
|
---|
[82878] | 71 | * @{ */
|
---|
[84189] | 72 | /** Returns cached machine state. */
|
---|
| 73 | KCloudMachineState machineState() const { return m_enmMachineState; }
|
---|
[103127] | 74 | QUuid machineId() const { return m_comCloudMachine.isOk() ? m_comCloudMachine.GetId() : QUuid(); }
|
---|
[84189] | 75 |
|
---|
[83012] | 76 | /** Defines fake cloud item @a enmState. */
|
---|
[84085] | 77 | void setFakeCloudItemState(UIFakeCloudVirtualMachineItemState enmState);
|
---|
[82960] | 78 | /** Returns fake cloud item state. */
|
---|
[83921] | 79 | UIFakeCloudVirtualMachineItemState fakeCloudItemState() const { return m_enmFakeCloudItemState; }
|
---|
[83055] | 80 |
|
---|
[84087] | 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 |
|
---|
[102838] | 86 | /** Defines whether update is @a fRequired by global reason. */
|
---|
| 87 | void setUpdateRequiredByGlobalReason(bool fRequired);
|
---|
[102836] | 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);
|
---|
[86201] | 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();
|
---|
[82878] | 96 | /** @} */
|
---|
[8159] | 97 |
|
---|
[82878] | 98 | /** @name Update stuff.
|
---|
| 99 | * @{ */
|
---|
| 100 | /** Recaches machine data. */
|
---|
[93990] | 101 | virtual void recache() RT_OVERRIDE;
|
---|
[82878] | 102 | /** Recaches machine item pixmap. */
|
---|
[93990] | 103 | virtual void recachePixmap() RT_OVERRIDE;
|
---|
[82878] | 104 | /** @} */
|
---|
[45050] | 105 |
|
---|
[82878] | 106 | /** @name Validation stuff.
|
---|
| 107 | * @{ */
|
---|
[83755] | 108 | /** Returns whether this item is editable. */
|
---|
[93990] | 109 | virtual bool isItemEditable() const RT_OVERRIDE;
|
---|
[84102] | 110 | /** Returns whether this item is removable. */
|
---|
[93990] | 111 | virtual bool isItemRemovable() const RT_OVERRIDE;
|
---|
[83755] | 112 | /** Returns whether this item is saved. */
|
---|
[93990] | 113 | virtual bool isItemSaved() const RT_OVERRIDE;
|
---|
[83755] | 114 | /** Returns whether this item is powered off. */
|
---|
[93990] | 115 | virtual bool isItemPoweredOff() const RT_OVERRIDE;
|
---|
[83755] | 116 | /** Returns whether this item is started. */
|
---|
[93990] | 117 | virtual bool isItemStarted() const RT_OVERRIDE;
|
---|
[83755] | 118 | /** Returns whether this item is running. */
|
---|
[93990] | 119 | virtual bool isItemRunning() const RT_OVERRIDE;
|
---|
[83755] | 120 | /** Returns whether this item is running headless. */
|
---|
[93990] | 121 | virtual bool isItemRunningHeadless() const RT_OVERRIDE;
|
---|
[83755] | 122 | /** Returns whether this item is paused. */
|
---|
[93990] | 123 | virtual bool isItemPaused() const RT_OVERRIDE;
|
---|
[83755] | 124 | /** Returns whether this item is stuck. */
|
---|
[93990] | 125 | virtual bool isItemStuck() const RT_OVERRIDE;
|
---|
[83755] | 126 | /** Returns whether this item can be switched to. */
|
---|
[93990] | 127 | virtual bool isItemCanBeSwitchedTo() const RT_OVERRIDE;
|
---|
[82878] | 128 | /** @} */
|
---|
[50907] | 129 |
|
---|
[104251] | 130 | private slots:
|
---|
[82931] | 131 |
|
---|
| 132 | /** @name Event handling.
|
---|
| 133 | * @{ */
|
---|
| 134 | /** Handles translation event. */
|
---|
[104251] | 135 | void sltRetranslateUI();
|
---|
[82931] | 136 | /** @} */
|
---|
| 137 |
|
---|
[104251] | 138 | /** Handles signal about cloud VM info refresh progress is done. */
|
---|
| 139 | void sltHandleRefreshCloudMachineInfoDone();
|
---|
[83094] | 140 |
|
---|
[83050] | 141 | private:
|
---|
| 142 |
|
---|
[86215] | 143 | /** @name Prepare/Cleanup cascade.
|
---|
| 144 | * @{ */
|
---|
| 145 | /** Prepares all. */
|
---|
| 146 | void prepare();
|
---|
| 147 | /** Cleanups all. */
|
---|
| 148 | void cleanup();
|
---|
| 149 | /** @} */
|
---|
| 150 |
|
---|
[83050] | 151 | /** @name Arguments.
|
---|
| 152 | * @{ */
|
---|
[83654] | 153 | /** Holds cached cloud machine object. */
|
---|
| 154 | CCloudMachine m_comCloudMachine;
|
---|
[83050] | 155 | /** @} */
|
---|
| 156 |
|
---|
[83129] | 157 | /** @name Data attributes.
|
---|
[82878] | 158 | * @{ */
|
---|
[84189] | 159 | /** Holds cached machine state. */
|
---|
| 160 | KCloudMachineState m_enmMachineState;
|
---|
| 161 |
|
---|
[82960] | 162 | /** Holds fake cloud item state. */
|
---|
[83921] | 163 | UIFakeCloudVirtualMachineItemState m_enmFakeCloudItemState;
|
---|
[84087] | 164 | /** Holds fake cloud item error message. */
|
---|
| 165 | QString m_strFakeCloudItemErrorMessage;
|
---|
[83095] | 166 |
|
---|
[102838] | 167 | /** Holds whether update is required by global reason. */
|
---|
| 168 | bool m_fUpdateRequiredByGlobalReason;
|
---|
[102836] | 169 | /** Holds whether update is required by local reason. */
|
---|
| 170 | bool m_fUpdateRequiredByLocalReason;
|
---|
[86774] | 171 | /** Holds the refresh progress-task instance. */
|
---|
| 172 | UIProgressTask *m_pProgressTaskRefresh;
|
---|
[82878] | 173 | /** @} */
|
---|
[8159] | 174 | };
|
---|
| 175 |
|
---|
[82960] | 176 | #endif /* !FEQT_INCLUDED_SRC_manager_UIVirtualMachineItemCloud_h */
|
---|