Changeset 82878 in vbox for trunk/src/VBox
- Timestamp:
- Jan 27, 2020 5:30:46 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.cpp
r79365 r82878 5 5 6 6 /* 7 * Copyright (C) 2006-20 19Oracle Corporation7 * Copyright (C) 2006-2020 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 34 34 35 35 36 UIVirtualMachineItem::UIVirtualMachineItem(const CMachine &aMachine) 37 : m_machine(aMachine) 36 /********************************************************************************************************************************* 37 * Class UIVirtualMachineItem implementation. * 38 *********************************************************************************************************************************/ 39 40 UIVirtualMachineItem::UIVirtualMachineItem(const CMachine &comMachine) 41 : m_comMachine(comMachine) 42 , m_fAccessible(false) 43 , m_fHasDetails(false) 44 , m_cSnaphot(0) 45 , m_enmMachineState(KMachineState_Null) 46 , m_enmSessionState(KSessionState_Null) 47 , m_enmConfigurationAccessLevel(ConfigurationAccessLevel_Null) 38 48 { 39 49 recache(); … … 53 63 QString UIVirtualMachineItem::machineStateName() const 54 64 { 55 return m_fAccessible ? gpConverter->toString(m_machineState) : 56 QApplication::translate("UIVMListView", "Inaccessible"); 65 return m_fAccessible 66 ? gpConverter->toString(m_enmMachineState) 67 : QApplication::translate("UIVMListView", "Inaccessible"); 68 } 69 70 QString UIVirtualMachineItem::sessionStateName() const 71 { 72 return m_fAccessible 73 ? gpConverter->toString(m_enmSessionState) 74 : QApplication::translate("UIVMListView", "Inaccessible"); 57 75 } 58 76 59 77 QIcon UIVirtualMachineItem::machineStateIcon() const 60 78 { 61 return m_fAccessible ? gpConverter->toIcon(m_machineState) : 62 gpConverter->toIcon(KMachineState_Aborted); 63 } 64 65 QString UIVirtualMachineItem::sessionStateName() const 66 { 67 return m_fAccessible ? gpConverter->toString(m_sessionState) : 68 QApplication::translate("UIVMListView", "Inaccessible"); 79 return m_fAccessible 80 ? gpConverter->toIcon(m_enmMachineState) 81 : gpConverter->toIcon(KMachineState_Aborted); 69 82 } 70 83 71 84 QString UIVirtualMachineItem::toolTipText() const 72 85 { 73 QString dateTime = (m_lastStateChange.date() == QDate::currentDate()) ?74 m_lastStateChange.time().toString(Qt::LocalDate) : 75 m_lastStateChange.toString(Qt::LocalDate);76 77 QString toolTip;86 QString strToolTip; 87 88 const QString strDateTime = (m_lastStateChange.date() == QDate::currentDate()) 89 ? m_lastStateChange.time().toString(Qt::LocalDate) 90 : m_lastStateChange.toString(Qt::LocalDate); 78 91 79 92 if (m_fAccessible) 80 93 { 81 toolTip = QString("<b>%1</b>").arg(m_strName);94 strToolTip = QString("<b>%1</b>").arg(m_strName); 82 95 if (!m_strSnapshotName.isNull()) 83 toolTip += QString(" (%1)").arg(m_strSnapshotName);84 toolTip = QApplication::translate("UIVMListView",85 "<nobr>%1<br></nobr>"86 "<nobr>%2 since %3</nobr><br>"87 "<nobr>Session %4</nobr>",88 "VM tooltip (name, last state change, session state)")89 .arg(toolTip)90 .arg(gpConverter->toString(m_machineState))91 .arg(dateTime)92 .arg(gpConverter->toString(m_sessionState).toLower());96 strToolTip += QString(" (%1)").arg(m_strSnapshotName); 97 strToolTip = QApplication::translate("UIVMListView", 98 "<nobr>%1<br></nobr>" 99 "<nobr>%2 since %3</nobr><br>" 100 "<nobr>Session %4</nobr>", 101 "VM tooltip (name, last state change, session state)") 102 .arg(strToolTip) 103 .arg(gpConverter->toString(m_enmMachineState)) 104 .arg(strDateTime) 105 .arg(gpConverter->toString(m_enmSessionState).toLower()); 93 106 } 94 107 else 95 108 { 96 toolTip = QApplication::translate("UIVMListView", 97 "<nobr><b>%1</b><br></nobr>" 98 "<nobr>Inaccessible since %2</nobr>", 99 "Inaccessible VM tooltip (name, last state change)") 100 .arg(m_strSettingsFile) 101 .arg(dateTime); 102 } 103 104 return toolTip; 105 } 106 107 const QStringList& UIVirtualMachineItem::groups() 108 { 109 return m_groups; 110 } 111 112 bool UIVirtualMachineItem::recache() 113 { 114 bool needsResort = true; 115 116 m_uId = m_machine.GetId(); 117 m_strSettingsFile = m_machine.GetSettingsFilePath(); 118 119 m_fAccessible = m_machine.GetAccessible(); 109 strToolTip = QApplication::translate("UIVMListView", 110 "<nobr><b>%1</b><br></nobr>" 111 "<nobr>Inaccessible since %2</nobr>", 112 "Inaccessible VM tooltip (name, last state change)") 113 .arg(m_strSettingsFile) 114 .arg(strDateTime); 115 } 116 117 return strToolTip; 118 } 119 120 void UIVirtualMachineItem::recache() 121 { 122 /* Determine attributes which are always available: */ 123 m_uId = m_comMachine.GetId(); 124 m_strSettingsFile = m_comMachine.GetSettingsFilePath(); 125 126 /* Now determine whether VM is accessible: */ 127 m_fAccessible = m_comMachine.GetAccessible(); 120 128 if (m_fAccessible) 121 129 { 122 QString name = m_machine.GetName(); 123 124 CSnapshot snp = m_machine.GetCurrentSnapshot(); 125 m_strSnapshotName = snp.isNull() ? QString::null : snp.GetName(); 126 needsResort = name != m_strName; 127 m_strName = name; 128 129 m_machineState = m_machine.GetState(); 130 m_lastStateChange.setTime_t(m_machine.GetLastStateChange() / 1000); 131 m_sessionState = m_machine.GetSessionState(); 132 m_strOSTypeId = m_machine.GetOSTypeId(); 133 m_cSnaphot = m_machine.GetSnapshotCount(); 134 135 m_groups = m_machine.GetGroups().toList(); 136 137 if ( m_machineState == KMachineState_PoweredOff 138 || m_machineState == KMachineState_Saved 139 || m_machineState == KMachineState_Teleported 140 || m_machineState == KMachineState_Aborted 130 /* Reset last access error information: */ 131 m_comAccessError = CVirtualBoxErrorInfo(); 132 133 /* Determine own VM attributes: */ 134 m_strName = m_comMachine.GetName(); 135 m_strOSTypeId = m_comMachine.GetOSTypeId(); 136 m_groups = m_comMachine.GetGroups().toList(); 137 138 /* Determine snapshot attributes: */ 139 CSnapshot comSnapshot = m_comMachine.GetCurrentSnapshot(); 140 m_strSnapshotName = comSnapshot.isNull() ? QString() : comSnapshot.GetName(); 141 m_lastStateChange.setTime_t(m_comMachine.GetLastStateChange() / 1000); 142 m_cSnaphot = m_comMachine.GetSnapshotCount(); 143 144 /* Determine VM states: */ 145 m_enmMachineState = m_comMachine.GetState(); 146 m_enmSessionState = m_comMachine.GetSessionState(); 147 148 /* Determine configuration access level: */ 149 m_enmConfigurationAccessLevel = ::configurationAccessLevel(m_enmSessionState, m_enmMachineState); 150 /* Also take restrictions into account: */ 151 if ( m_enmConfigurationAccessLevel != ConfigurationAccessLevel_Null 152 && !gEDataManager->machineReconfigurationEnabled(m_uId)) 153 m_enmConfigurationAccessLevel = ConfigurationAccessLevel_Null; 154 155 /* Determine PID finally: */ 156 if ( m_enmMachineState == KMachineState_PoweredOff 157 || m_enmMachineState == KMachineState_Saved 158 || m_enmMachineState == KMachineState_Teleported 159 || m_enmMachineState == KMachineState_Aborted 141 160 ) 142 161 { … … 145 164 else 146 165 { 147 m_pid = m_ machine.GetSessionPID();166 m_pid = m_comMachine.GetSessionPID(); 148 167 } 149 168 150 /* Determine configuration access level: */ 151 m_configurationAccessLevel = ::configurationAccessLevel(m_sessionState, m_machineState); 152 /* Also take restrictions into account: */ 153 if ( m_configurationAccessLevel != ConfigurationAccessLevel_Null 154 && !gEDataManager->machineReconfigurationEnabled(m_uId)) 155 m_configurationAccessLevel = ConfigurationAccessLevel_Null; 156 157 /* Should we show details for this item? */ 169 /* Determine whether we should show this VM details: */ 158 170 m_fHasDetails = gEDataManager->showMachineInVirtualBoxManagerDetails(m_uId); 159 171 } 160 172 else 161 173 { 162 m_accessError = m_machine.GetAccessError();163 164 /* this should be in sync with 165 * UIMessageCenter::confirm_machineDeletion()*/174 /* Update last access error information: */ 175 m_comAccessError = m_comMachine.GetAccessError(); 176 177 /* Determine machine name on the basis of settings file only: */ 166 178 QFileInfo fi(m_strSettingsFile); 167 QString name = UICommon::hasAllowedExtension(fi.completeSuffix(), VBoxFileExts) ? 168 fi.completeBaseName() : fi.fileName(); 169 needsResort = name != m_strName; 170 m_strName = name; 171 m_machineState = KMachineState_Null; 172 m_sessionState = KSessionState_Null; 179 m_strName = UICommon::hasAllowedExtension(fi.completeSuffix(), VBoxFileExts) 180 ? fi.completeBaseName() 181 : fi.fileName(); 182 /* Reset other VM attributes: */ 183 m_strOSTypeId = QString(); 184 m_groups.clear(); 185 186 /* Reset snapshot attributes: */ 187 m_strSnapshotName = QString(); 173 188 m_lastStateChange = QDateTime::currentDateTime(); 174 m_strOSTypeId = QString::null;175 189 m_cSnaphot = 0; 176 190 177 m_groups.clear(); 191 /* Reset VM states: */ 192 m_enmMachineState = KMachineState_Null; 193 m_enmSessionState = KSessionState_Null; 194 195 /* Reset configuration access level: */ 196 m_enmConfigurationAccessLevel = ConfigurationAccessLevel_Null; 197 198 /* Reset PID finally: */ 178 199 m_pid = (ULONG) ~0; 179 200 180 /* Set configuration access level to NULL: */ 181 m_configurationAccessLevel = ConfigurationAccessLevel_Null; 182 183 /* Should we show details for this item? */ 201 /* Reset whether we should show this VM details: */ 184 202 m_fHasDetails = true; 185 203 } … … 187 205 /* Recache item pixmap: */ 188 206 recachePixmap(); 189 190 return needsResort;191 207 } 192 208 … … 197 213 { 198 214 /* First, we are trying to acquire personal machine guest OS type icon: */ 199 m_pixmap = uiCommon().vmUserPixmapDefault(m_ machine, &m_logicalPixmapSize);215 m_pixmap = uiCommon().vmUserPixmapDefault(m_comMachine, &m_logicalPixmapSize); 200 216 /* If there is nothing, we are using icon corresponding to cached guest OS type: */ 201 217 if (m_pixmap.isNull()) … … 210 226 } 211 227 212 /**213 * Returns @a true if we can activate and bring the VM console window to214 * foreground, and @a false otherwise.215 */216 228 bool UIVirtualMachineItem::canSwitchTo() const 217 229 { 218 return const_cast <CMachine &>(m_machine).CanShowConsoleWindow(); 219 } 220 221 /** 222 * Tries to switch to the main window of the VM process. 223 * 224 * @return true if successfully switched and false otherwise. 225 */ 230 return const_cast <CMachine &>(m_comMachine).CanShowConsoleWindow(); 231 } 232 226 233 bool UIVirtualMachineItem::switchTo() 227 234 { 228 235 #ifdef VBOX_WS_MAC 229 ULONG64 id = m_ machine.ShowConsoleWindow();236 ULONG64 id = m_comMachine.ShowConsoleWindow(); 230 237 #else 231 WId id = (WId) m_ machine.ShowConsoleWindow();238 WId id = (WId) m_comMachine.ShowConsoleWindow(); 232 239 #endif 233 AssertWrapperOk(m_ machine);234 if (!m_ machine.isOk())240 AssertWrapperOk(m_comMachine); 241 if (!m_comMachine.isOk()) 235 242 return false; 236 243 … … 245 252 246 253 #elif defined (VBOX_WS_MAC) 247 /* 248 * This is just for the case were the other process cannot steal249 * the focus from us. It will send us a PSN so we can try.250 */254 255 // WORKAROUND: 256 // This is just for the case were the other process cannot steal 257 // the focus from us. It will send us a PSN so we can try. 251 258 ProcessSerialNumber psn; 252 259 psn.highLongOfPSN = id >> 32; … … 260 267 261 268 #else 269 262 270 return false; 271 263 272 #endif 264 273 } … … 267 276 bool UIVirtualMachineItem::isItemEditable(UIVirtualMachineItem *pItem) 268 277 { 269 return pItem &&270 pItem->accessible() &&271 pItem->sessionState() == KSessionState_Unlocked;278 return pItem 279 && pItem->accessible() 280 && pItem->sessionState() == KSessionState_Unlocked; 272 281 } 273 282 … … 275 284 bool UIVirtualMachineItem::isItemSaved(UIVirtualMachineItem *pItem) 276 285 { 277 return pItem &&278 pItem->accessible() &&279 pItem->machineState() == KMachineState_Saved;286 return pItem 287 && pItem->accessible() 288 && pItem->machineState() == KMachineState_Saved; 280 289 } 281 290 … … 283 292 bool UIVirtualMachineItem::isItemPoweredOff(UIVirtualMachineItem *pItem) 284 293 { 285 return pItem &&286 pItem->accessible() &&287 (pItem->machineState() == KMachineState_PoweredOff ||288 pItem->machineState() == KMachineState_Saved ||289 pItem->machineState() == KMachineState_Teleported ||290 pItem->machineState() == KMachineState_Aborted);294 return pItem 295 && pItem->accessible() 296 && ( pItem->machineState() == KMachineState_PoweredOff 297 || pItem->machineState() == KMachineState_Saved 298 || pItem->machineState() == KMachineState_Teleported 299 || pItem->machineState() == KMachineState_Aborted); 291 300 } 292 301 … … 294 303 bool UIVirtualMachineItem::isItemStarted(UIVirtualMachineItem *pItem) 295 304 { 296 return isItemRunning(pItem) || isItemPaused(pItem); 305 return isItemRunning(pItem) 306 || isItemPaused(pItem); 297 307 } 298 308 … … 300 310 bool UIVirtualMachineItem::isItemRunning(UIVirtualMachineItem *pItem) 301 311 { 302 return pItem &&303 pItem->accessible() &&304 (pItem->machineState() == KMachineState_Running ||305 pItem->machineState() == KMachineState_Teleporting ||306 pItem->machineState() == KMachineState_LiveSnapshotting);312 return pItem 313 && pItem->accessible() 314 && ( pItem->machineState() == KMachineState_Running 315 || pItem->machineState() == KMachineState_Teleporting 316 || pItem->machineState() == KMachineState_LiveSnapshotting); 307 317 } 308 318 … … 313 323 { 314 324 /* Open session to determine which frontend VM is started with: */ 315 CSession session = uiCommon().openExistingSession(pItem->id());316 if (! session.isNull())325 CSession comSession = uiCommon().openExistingSession(pItem->id()); 326 if (!comSession.isNull()) 317 327 { 318 328 /* Acquire the session name: */ 319 const QString strSessionName = session.GetMachine().GetSessionName();329 const QString strSessionName = comSession.GetMachine().GetSessionName(); 320 330 /* Close the session early: */ 321 session.UnlockMachine();331 comSession.UnlockMachine(); 322 332 /* Check whether we are in 'headless' session: */ 323 333 return strSessionName == "headless"; … … 330 340 bool UIVirtualMachineItem::isItemPaused(UIVirtualMachineItem *pItem) 331 341 { 332 return pItem &&333 pItem->accessible() &&334 (pItem->machineState() == KMachineState_Paused ||335 pItem->machineState() == KMachineState_TeleportingPausedVM);342 return pItem 343 && pItem->accessible() 344 && ( pItem->machineState() == KMachineState_Paused 345 || pItem->machineState() == KMachineState_TeleportingPausedVM); 336 346 } 337 347 … … 339 349 bool UIVirtualMachineItem::isItemStuck(UIVirtualMachineItem *pItem) 340 350 { 341 return pItem && 342 pItem->accessible() && 343 pItem->machineState() == KMachineState_Stuck; 344 } 351 return pItem 352 && pItem->accessible() 353 && pItem->machineState() == KMachineState_Stuck; 354 } 355 356 357 /********************************************************************************************************************************* 358 * Class UIVirtualMachineItemMimeData implementation. * 359 *********************************************************************************************************************************/ 345 360 346 361 QString UIVirtualMachineItemMimeData::m_type = "application/org.virtualbox.gui.vmselector.UIVirtualMachineItem"; 347 362 348 363 UIVirtualMachineItemMimeData::UIVirtualMachineItemMimeData(UIVirtualMachineItem *pItem) 349 : m_pItem(pItem) 350 { 351 } 352 353 UIVirtualMachineItem *UIVirtualMachineItemMimeData::item() const 354 { 355 return m_pItem; 364 : m_pItem(pItem) 365 { 356 366 } 357 367 … … 362 372 return types; 363 373 } 364 365 /* static */366 QString UIVirtualMachineItemMimeData::type()367 {368 return m_type;369 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItem.h
r76581 r82878 5 5 6 6 /* 7 * Copyright (C) 2006-20 19Oracle Corporation7 * Copyright (C) 2006-2020 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 /* COM includes: */ 33 33 #include "COMEnums.h" 34 #include "CMachine.h" 34 35 #include "CVirtualBoxErrorInfo.h" 35 #include "CMachine.h"36 36 37 37 /* Using declarations: */ 38 38 using namespace UISettingsDefs; 39 39 40 /** Virtual Machine item interface. 41 * A wrapper caching data about local VM. */ 40 42 class UIVirtualMachineItem 41 43 { 42 44 public: 43 45 44 UIVirtualMachineItem(const CMachine &aMachine); 46 /** Constructs local VM item on the basis of taken @a comMachine. */ 47 UIVirtualMachineItem(const CMachine &comMachine); 48 /** Destructs local VM item. */ 45 49 virtual ~UIVirtualMachineItem(); 46 50 47 CMachine machine() const { return m_machine; } 48 49 QString name() const { return m_strName; } 50 QPixmap osPixmap(QSize *pLogicalSize = 0) const; 51 QString osTypeId() const { return m_strOSTypeId; } 52 QUuid id() const { return m_uId; } 53 54 QString machineStateName() const; 55 QIcon machineStateIcon() const; 56 57 QString sessionStateName() const; 58 59 QString snapshotName() const { return m_strSnapshotName; } 60 ULONG snapshotCount() const { return m_cSnaphot; } 61 62 QString toolTipText() const; 63 64 bool accessible() const { return m_fAccessible; } 65 const CVirtualBoxErrorInfo &accessError() const { return m_accessError; } 66 KMachineState machineState() const { return m_machineState; } 67 KSessionState sessionState() const { return m_sessionState; } 68 69 QString settingsFile() const { return m_strSettingsFile; } 70 const QStringList &groups(); 71 bool recache(); 72 /** Recaches item pixmap. */ 73 void recachePixmap(); 74 75 bool canSwitchTo() const; 76 bool switchTo(); 77 78 bool hasDetails() const { return m_fHasDetails; } 79 80 /** Returns configuration access level. */ 81 ConfigurationAccessLevel configurationAccessLevel() const { return m_configurationAccessLevel; } 82 83 static bool isItemEditable(UIVirtualMachineItem *pItem); 84 static bool isItemSaved(UIVirtualMachineItem *pItem); 85 static bool isItemPoweredOff(UIVirtualMachineItem *pItem); 86 static bool isItemStarted(UIVirtualMachineItem *pItem); 87 static bool isItemRunning(UIVirtualMachineItem *pItem); 88 static bool isItemRunningHeadless(UIVirtualMachineItem *pItem); 89 static bool isItemPaused(UIVirtualMachineItem *pItem); 90 static bool isItemStuck(UIVirtualMachineItem *pItem); 51 /** @name Arguments. 52 * @{ */ 53 /** Returns cached virtual machine object. */ 54 CMachine machine() const { return m_comMachine; } 55 /** @} */ 56 57 /** @name Basic attributes. 58 * @{ */ 59 /** Returns cached machine id. */ 60 QUuid id() const { return m_uId; } 61 /** Returns cached machine settings file name. */ 62 QString settingsFile() const { return m_strSettingsFile; } 63 /** @} */ 64 65 /** @name VM access attributes. 66 * @{ */ 67 /** Returns whether VM was accessible. */ 68 bool accessible() const { return m_fAccessible; } 69 /** Returns the last cached access error. */ 70 const CVirtualBoxErrorInfo &accessError() const { return m_comAccessError; } 71 /** @} */ 72 73 /** @name Advanced attributes. 74 * @{ */ 75 /** Returns cached machine name. */ 76 QString name() const { return m_strName; } 77 /** Returns cached machine OS type id. */ 78 QString osTypeId() const { return m_strOSTypeId; } 79 /** Returns cached machine OS type pixmap. 80 * @param pLogicalSize Argument to assign actual pixmap size to. */ 81 QPixmap osPixmap(QSize *pLogicalSize = 0) const; 82 /** Returns cached machine group list. */ 83 const QStringList &groups() { return m_groups; } 84 /** @} */ 85 86 /** @name Snapshot attributes. 87 * @{ */ 88 /** Returns cached snapshot name. */ 89 QString snapshotName() const { return m_strSnapshotName; } 90 /** Returns cached snapshot children count. */ 91 ULONG snapshotCount() const { return m_cSnaphot; } 92 /** @} */ 93 94 /** @name State attributes. 95 * @{ */ 96 /** Returns cached machine state. */ 97 KMachineState machineState() const { return m_enmMachineState; } 98 /** Returns cached session state. */ 99 KSessionState sessionState() const { return m_enmSessionState; } 100 /** Returns cached machine state name. */ 101 QString machineStateName() const; 102 /** Returns cached session state name. */ 103 QString sessionStateName() const; 104 /** Returns cached machine state icon. */ 105 QIcon machineStateIcon() const; 106 /** Returns cached configuration access level. */ 107 ConfigurationAccessLevel configurationAccessLevel() const { return m_enmConfigurationAccessLevel; } 108 /** @} */ 109 110 /** @name Visual attributes. 111 * @{ */ 112 /** Returns cached machine tool-tip. */ 113 QString toolTipText() const; 114 /** @} */ 115 116 /** @name Console attributes. 117 * @{ */ 118 /** Returns whether we can switch to main window of VM process. */ 119 bool canSwitchTo() const; 120 /** Tries to switch to the main window of the VM process. 121 * @return true if switched successfully. */ 122 bool switchTo(); 123 /** @} */ 124 125 /** @name Extra-data options. 126 * @{ */ 127 /** Returns whether we should show machine details. */ 128 bool hasDetails() const { return m_fHasDetails; } 129 /** @} */ 130 131 /** @name Update stuff. 132 * @{ */ 133 /** Recaches machine data. */ 134 void recache(); 135 /** Recaches machine item pixmap. */ 136 void recachePixmap(); 137 /** @} */ 138 139 /** @name Validation stuff. 140 * @{ */ 141 /** Returns whether passed machine @a pItem is editable. */ 142 static bool isItemEditable(UIVirtualMachineItem *pItem); 143 /** Returns whether passed machine @a pItem is saved. */ 144 static bool isItemSaved(UIVirtualMachineItem *pItem); 145 /** Returns whether passed machine @a pItem is powered off. */ 146 static bool isItemPoweredOff(UIVirtualMachineItem *pItem); 147 /** Returns whether passed machine @a pItem is started. */ 148 static bool isItemStarted(UIVirtualMachineItem *pItem); 149 /** Returns whether passed machine @a pItem is running. */ 150 static bool isItemRunning(UIVirtualMachineItem *pItem); 151 /** Returns whether passed machine @a pItem is running headless. */ 152 static bool isItemRunningHeadless(UIVirtualMachineItem *pItem); 153 /** Returns whether passed machine @a pItem is paused. */ 154 static bool isItemPaused(UIVirtualMachineItem *pItem); 155 /** Returns whether passed machine @a pItem is stuck. */ 156 static bool isItemStuck(UIVirtualMachineItem *pItem); 157 /** @} */ 91 158 92 159 private: 93 160 94 /* Private member vars */ 95 CMachine m_machine; 96 97 /* Cached machine data (to minimize server requests) */ 98 QUuid m_uId; 99 QString m_strSettingsFile; 100 101 bool m_fAccessible; 102 CVirtualBoxErrorInfo m_accessError; 103 104 QString m_strName; 105 QPixmap m_pixmap; 106 QSize m_logicalPixmapSize; 107 QString m_strSnapshotName; 108 QDateTime m_lastStateChange; 109 KMachineState m_machineState; 110 KSessionState m_sessionState; 111 QString m_strOSTypeId; 112 ULONG m_cSnaphot; 113 114 ULONG m_pid; 115 116 bool m_fHasDetails; 117 118 QStringList m_groups; 119 /** Holds configuration access level. */ 120 ConfigurationAccessLevel m_configurationAccessLevel; 161 /** @name Arguments. 162 * @{ */ 163 /** Holds cached machine object reference. */ 164 CMachine m_comMachine; 165 /** @} */ 166 167 /** @name Basic attributes. 168 * @{ */ 169 /** Holds cached machine id. */ 170 QUuid m_uId; 171 /** Holds cached machine settings file name. */ 172 QString m_strSettingsFile; 173 /** @} */ 174 175 /** @name VM access attributes. 176 * @{ */ 177 /** Holds whether VM was accessible. */ 178 bool m_fAccessible; 179 /** Holds the last cached access error. */ 180 CVirtualBoxErrorInfo m_comAccessError; 181 /** @} */ 182 183 /** @name Advanced attributes. 184 * @{ */ 185 /** Holds cached machine name. */ 186 QString m_strName; 187 /** Holds cached machine OS type id. */ 188 QString m_strOSTypeId; 189 /** Holds cached machine OS type pixmap. */ 190 QPixmap m_pixmap; 191 /** Holds cached machine OS type pixmap size. */ 192 QSize m_logicalPixmapSize; 193 /** Holds cached machine group list. */ 194 QStringList m_groups; 195 /** @} */ 196 197 /** @name Snapshot attributes. 198 * @{ */ 199 /** Holds cached snapshot name. */ 200 QString m_strSnapshotName; 201 /** Holds cached last state change date/time. */ 202 QDateTime m_lastStateChange; 203 /** Holds cached snapshot children count. */ 204 ULONG m_cSnaphot; 205 /** @} */ 206 207 /** @name State attributes. 208 * @{ */ 209 /** Holds cached machine state. */ 210 KMachineState m_enmMachineState; 211 /** Holds cached session state. */ 212 KSessionState m_enmSessionState; 213 /** Holds configuration access level. */ 214 ConfigurationAccessLevel m_enmConfigurationAccessLevel; 215 /** @} */ 216 217 /** @name Console attributes. 218 * @{ */ 219 /** Holds machine PID. */ 220 ULONG m_pid; 221 /** @} */ 222 223 /** @name Extra-data options. 224 * @{ */ 225 /** Holds whether we should show machine details. */ 226 bool m_fHasDetails; 227 /** @} */ 121 228 }; 122 229 … … 124 231 Q_DECLARE_METATYPE(UIVirtualMachineItem *); 125 232 126 class UIVirtualMachineItemMimeData: public QMimeData 233 /** QMimeData subclass for handling UIVirtualMachineItem mime data. */ 234 class UIVirtualMachineItemMimeData : public QMimeData 127 235 { 128 236 Q_OBJECT; … … 130 238 public: 131 239 240 /** Constructs mime data for passed VM @a pItem. */ 132 241 UIVirtualMachineItemMimeData(UIVirtualMachineItem *pItem); 133 242 134 UIVirtualMachineItem *item() const; 135 QStringList formats() const; 136 137 static QString type(); 243 /** Returns cached VM item. */ 244 UIVirtualMachineItem *item() const { return m_pItem; } 245 246 /** Returns supported format list. */ 247 virtual QStringList formats() const /* override */; 248 249 /** Returns UIVirtualMachineItem mime data type. */ 250 static QString type() { return m_type; } 138 251 139 252 private: 140 253 141 /* Private member vars*/254 /** Holds cached VM item. */ 142 255 UIVirtualMachineItem *m_pItem; 143 256 144 static QString m_type; 257 /** Holds UIVirtualMachineItem mime data type. */ 258 static QString m_type; 145 259 }; 146 260
Note:
See TracChangeset
for help on using the changeset viewer.