Changeset 83008 in vbox
- Timestamp:
- Feb 6, 2020 2:59:10 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r82998 r83008 631 631 src/manager/chooser/UIChooserNodeMachine.h \ 632 632 src/manager/chooser/UIChooserSearchWidget.h \ 633 src/manager/chooser/UITaskCloudAcquireInstances.h \ 633 634 src/manager/details/UIDetails.h \ 634 635 src/manager/details/UIDetailsContextMenu.h \ … … 1076 1077 src/manager/chooser/UIChooserNodeMachine.cpp \ 1077 1078 src/manager/chooser/UIChooserSearchWidget.cpp \ 1079 src/manager/chooser/UITaskCloudAcquireInstances.cpp \ 1078 1080 src/manager/details/UIDetails.cpp \ 1079 1081 src/manager/details/UIDetailsContextMenu.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UITask.h
r82998 r83008 44 44 enum Type 45 45 { 46 Type_MediumEnumeration = 1, 47 Type_DetailsPopulation = 2, 46 Type_MediumEnumeration = 1, 47 Type_DetailsPopulation = 2, 48 Type_CloudAcquireInstances = 3, 48 49 }; 49 50 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r82999 r83008 28 28 #include "UIVirtualBoxEventHandler.h" 29 29 #include "UIVirtualMachineItem.h" 30 #ifdef VBOX_GUI_WITH_CLOUD_VMS 31 # include "UITaskCloudAcquireInstances.h" 32 # include "UIThreadPool.h" 33 #endif 30 34 31 35 /* COM includes: */ … … 259 263 saveGroupOrders(); 260 264 } 265 266 #ifdef VBOX_GUI_WITH_CLOUD_VMS 267 void UIChooserAbstractModel::sltHandleCloudAcquireInstancesTaskComplete(UITask *pTask) 268 { 269 /* Skip unrelated tasks: */ 270 if (!pTask || pTask->type() != UITask::Type_CloudAcquireInstances) 271 return; 272 273 /* Cast task to corresponding sub-class: */ 274 UITaskCloudAcquireInstances *pAcquiringTask = static_cast<UITaskCloudAcquireInstances*>(pTask); 275 276 /* Add real cloud VM items: */ 277 int iPosition = 1; /* we've got item with index 0 already, the "Empty" one .. */ 278 foreach (const QString &strInstanceName, pAcquiringTask->instanceNames()) 279 { 280 new UIChooserNodeMachine(pAcquiringTask->parentNode(), 281 false /* favorite */, 282 iPosition++ /* position */, 283 strInstanceName); 284 } 285 } 286 #endif /* VBOX_GUI_WITH_CLOUD_VMS */ 261 287 262 288 void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete() … … 374 400 new UIChooserNodeGroup(m_pInvisibleRootNode, 375 401 false /* favorite */, 376 getDesiredNodePosition(m_pInvisibleRootNode, UIChooserItemType_Group, strProviderName), 402 getDesiredNodePosition(m_pInvisibleRootNode, 403 UIChooserItemType_Group, 404 strProviderName), 377 405 strProviderName, 378 406 true /* opened */); … … 394 422 /* Create Cloud Client: */ 395 423 CCloudClient comCloudClient = comCloudProfile.CreateCloudClient(); 396 Q_UNUSED(comCloudClient);397 424 /* Show error message if necessary: */ 398 425 if (!comCloudProfile.isOk()) … … 404 431 new UIChooserNodeGroup(pProviderNode, 405 432 false /* favorite */, 406 getDesiredNodePosition(pProviderNode, UIChooserItemType_Group, strProfileName), 433 getDesiredNodePosition(pProviderNode, 434 UIChooserItemType_Group, 435 strProfileName), 407 436 strProfileName, 408 437 true /* opened */); … … 411 440 false /* favorite */, 412 441 0 /* position */); 442 443 /* Create cloud acquire isntances task: */ 444 UITaskCloudAcquireInstances *pTask = new UITaskCloudAcquireInstances(comCloudClient, 445 pProfileNode); 446 if (pTask) 447 { 448 connect(pTask, &UITask::sigComplete, 449 this, &UIChooserAbstractModel::sltHandleCloudAcquireInstancesTaskComplete); 450 uiCommon().threadPool()->enqueueTask(pTask); 451 } 413 452 } 414 453 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r82968 r83008 36 36 class UIChooserNode; 37 37 class CMachine; 38 #ifdef VBOX_GUI_WITH_CLOUD_VMS 39 class UITask; 40 #endif 38 41 39 42 … … 130 133 virtual void sltReloadMachine(const QUuid &uMachineId); 131 134 /** @} */ 135 136 #ifdef VBOX_GUI_WITH_CLOUD_VMS 137 /** @name Cloud stuff. 138 * @{ */ 139 /** Handles acquire cloud instances task complete signal. */ 140 virtual void sltHandleCloudAcquireInstancesTaskComplete(UITask *pTask); 141 /** @} */ 142 #endif /* VBOX_GUI_WITH_CLOUD_VMS */ 132 143 133 144 private slots: -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r82968 r83008 705 705 emit sigSelectionChanged(); 706 706 } 707 708 #ifdef VBOX_GUI_WITH_CLOUD_VMS 709 void UIChooserModel::sltHandleCloudAcquireInstancesTaskComplete(UITask *pTask) 710 { 711 /* Call to base-class: */ 712 UIChooserAbstractModel::sltHandleCloudAcquireInstancesTaskComplete(pTask); 713 714 /* Rebuild tree for main root: */ 715 buildTreeForMainRoot(); 716 updateNavigationItemList(); 717 updateLayout(); 718 } 719 #endif /* VBOX_GUI_WITH_CLOUD_VMS */ 707 720 708 721 void UIChooserModel::sltMakeSureCurrentItemVisible() -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r82968 r83008 248 248 virtual void sltReloadMachine(const QUuid &uId) /* override */; 249 249 /** @} */ 250 251 #ifdef VBOX_GUI_WITH_CLOUD_VMS 252 /** @name Cloud stuff. 253 * @{ */ 254 /** Handles acquire cloud machine task complete signal. */ 255 virtual void sltHandleCloudAcquireInstancesTaskComplete(UITask *pTask) /* override */; 256 /** @} */ 257 #endif /* VBOX_GUI_WITH_CLOUD_VMS */ 250 258 251 259 private slots: -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UITaskCloudAcquireInstances.cpp
r82998 r83008 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UITask class implementation.3 * VBox Qt GUI - UITaskCloudAcquireInstances class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 20 13-2020 Oracle Corporation7 * Copyright (C) 2020 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 /* GUI includes: */ 19 #include "UITask .h"19 #include "UITaskCloudAcquireInstances.h" 20 20 21 void UITask::start() 21 /* COM includes: */ 22 #include "CProgress.h" 23 #include "CStringArray.h" 24 25 26 UITaskCloudAcquireInstances::UITaskCloudAcquireInstances(const CCloudClient &comCloudClient, UIChooserNode *pParentNode) 27 : UITask(Type_CloudAcquireInstances) 28 , m_comCloudClient(comCloudClient) 29 , m_pParentNode(pParentNode) 22 30 { 23 /* Run task: */24 run();25 /* Notify listeners: */26 emit sigComplete(this);27 31 } 32 33 QStringList UITaskCloudAcquireInstances::instanceNames() const 34 { 35 m_mutex.lock(); 36 const QStringList instanceNames = m_instanceNames; 37 m_mutex.unlock(); 38 return instanceNames; 39 } 40 41 QStringList UITaskCloudAcquireInstances::instanceIds() const 42 { 43 m_mutex.lock(); 44 const QStringList instanceIds = m_instanceIds; 45 m_mutex.unlock(); 46 return instanceIds; 47 } 48 49 CVirtualBoxErrorInfo UITaskCloudAcquireInstances::errorInfo() 50 { 51 m_mutex.lock(); 52 CVirtualBoxErrorInfo comErrorInfo = m_comErrorInfo; 53 m_mutex.unlock(); 54 return comErrorInfo; 55 } 56 57 void UITaskCloudAcquireInstances::run() 58 { 59 m_mutex.lock(); 60 61 do 62 { 63 /* Gather VM names, ids and states. 64 * Currently we are interested in Running and Stopped VMs only. */ 65 CStringArray comNames; 66 CStringArray comIDs; 67 const QVector<KCloudMachineState> cloudMachineStates = QVector<KCloudMachineState>() 68 << KCloudMachineState_Running 69 << KCloudMachineState_Stopped; 70 71 /* Ask for cloud instance list: */ 72 CProgress comProgress = m_comCloudClient.ListInstances(cloudMachineStates, comNames, comIDs); 73 if (!m_comCloudClient.isOk()) 74 { 75 /// @todo pack error info to m_comErrorInfo 76 break; 77 } 78 79 /* Wait for "Acquire cloud instances" progress: */ 80 comProgress.WaitForCompletion(-1); 81 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 82 { 83 /// @todo pack error info to m_comErrorInfo 84 break; 85 } 86 87 /* Fetch acquired names/ids to lists: */ 88 m_instanceNames = comNames.GetValues().toList(); 89 m_instanceIds = comIDs.GetValues().toList(); 90 } 91 while (0); 92 93 m_mutex.unlock(); 94 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UITaskCloudAcquireInstances.h
r82998 r83008 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UITask class declaration.3 * VBox Qt GUI - UITaskCloudAcquireInstances class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 20 13-2020 Oracle Corporation7 * Copyright (C) 2020 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_ globals_UITask_h19 #define FEQT_INCLUDED_SRC_ globals_UITask_h18 #ifndef FEQT_INCLUDED_SRC_manager_chooser_UITaskCloudAcquireInstances_h 19 #define FEQT_INCLUDED_SRC_manager_chooser_UITaskCloudAcquireInstances_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 23 23 24 24 /* Qt includes: */ 25 #include <Q Object>25 #include <QMutex> 26 26 27 27 /* GUI includes: */ 28 #include "UI LibraryDefs.h"28 #include "UITask.h" 29 29 30 /** QObject extension used as worker-thread task interface. 31 * Describes task to be handled by the UIThreadPool object. */ 32 class SHARED_LIBRARY_STUFF UITask : public QObject 30 /* COM includes: */ 31 #include "COMEnums.h" 32 #include "CCloudClient.h" 33 #include "CVirtualBoxErrorInfo.h" 34 35 /* Forward declaratiuons: */ 36 class UIChooserNode; 37 38 /** UITask extension used to load cloud instance list. */ 39 class UITaskCloudAcquireInstances : public UITask 33 40 { 34 41 Q_OBJECT; 35 42 36 signals:37 38 /** Notifies listeners about @a pTask complete. */39 void sigComplete(UITask *pTask);40 41 43 public: 42 44 43 /** Task types. */ 44 enum Type 45 { 46 Type_MediumEnumeration = 1, 47 Type_DetailsPopulation = 2, 48 }; 45 /** Constructs update task taking @a comCloudClient and @a pParentNode as data. */ 46 UITaskCloudAcquireInstances(const CCloudClient &comCloudClient, UIChooserNode *pParentNode); 49 47 50 /** Constructs the task of passed @a enmType. */ 51 UITask(UITask::Type enmType) : m_enmType(enmType) {} 48 /** Returns cloud client object. */ 49 CCloudClient cloudClient() const { return m_comCloudClient; } 50 /** Returns parent node reference. */ 51 UIChooserNode *parentNode() const { return m_pParentNode; } 52 52 53 /** Returns the type of the task. */54 UITask::Type type() const { return m_enmType; }53 /** Returns error info. */ 54 CVirtualBoxErrorInfo errorInfo(); 55 55 56 /** Starts the task. */ 57 void start(); 56 /** Returns the instance name list. */ 57 QStringList instanceNames() const; 58 /** Returns the instance ID list. */ 59 QStringList instanceIds() const; 58 60 59 61 protected: 60 62 61 /** Contains the abstracttask body. */62 virtual void run() = 0;63 /** Contains the task body. */ 64 virtual void run() /* override */; 63 65 64 66 private: 65 67 66 /** Holds the type of the task. */ 67 const UITask::Type m_enmType; 68 /** Holds the mutex to access m_guiMedium member. */ 69 mutable QMutex m_mutex; 70 71 /** Holds the cloud client object. */ 72 CCloudClient m_comCloudClient; 73 /** Holds the parent node reference. */ 74 UIChooserNode *m_pParentNode; 75 76 /** Holds the error info object. */ 77 CVirtualBoxErrorInfo m_comErrorInfo; 78 79 /** Holds the instance name list. */ 80 QStringList m_instanceNames; 81 /** Holds the instance ID list. */ 82 QStringList m_instanceIds; 68 83 }; 69 84 70 #endif /* !FEQT_INCLUDED_SRC_ globals_UITask_h */85 #endif /* !FEQT_INCLUDED_SRC_manager_chooser_UITaskCloudAcquireInstances_h */
Note:
See TracChangeset
for help on using the changeset viewer.