Index: /trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp	(revision 83688)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp	(revision 83689)
@@ -62,321 +62,4 @@
 void UIChooserAbstractModel::init()
 {
-    /* Load tree: */
-    loadTree();
-}
-
-void UIChooserAbstractModel::deinit()
-{
-    // WORKAROUND:
-    // Currently we are not saving group descriptors
-    // (which reflecting group toggle-state) on-the-fly,
-    // so for now we are additionally save group orders
-    // when exiting application:
-    saveGroupOrders();
-
-    /* Make sure all saving steps complete: */
-    makeSureGroupDefinitionsSaveIsFinished();
-    makeSureGroupOrdersSaveIsFinished();
-
-    /* Delete tree: */
-    delete m_pInvisibleRootNode;
-    m_pInvisibleRootNode = 0;
-}
-
-UIChooserNode *UIChooserAbstractModel::invisibleRoot() const
-{
-    return m_pInvisibleRootNode;
-}
-
-void UIChooserAbstractModel::wipeOutEmptyGroups()
-{
-    wipeOutEmptyGroupsStartingFrom(invisibleRoot());
-}
-
-/* static */
-QString UIChooserAbstractModel::uniqueGroupName(UIChooserNode *pRoot)
-{
-    /* Enumerate all the group names: */
-    QStringList groupNames;
-    foreach (UIChooserNode *pNode, pRoot->nodes(UIChooserNodeType_Group))
-        groupNames << pNode->name();
-
-    /* Prepare reg-exp: */
-    const QString strMinimumName = tr("New group");
-    const QString strShortTemplate = strMinimumName;
-    const QString strFullTemplate = strShortTemplate + QString(" (\\d+)");
-    const QRegExp shortRegExp(strShortTemplate);
-    const QRegExp fullRegExp(strFullTemplate);
-
-    /* Search for the maximum index: */
-    int iMinimumPossibleNumber = 0;
-    foreach (const QString &strName, groupNames)
-    {
-        if (shortRegExp.exactMatch(strName))
-            iMinimumPossibleNumber = qMax(iMinimumPossibleNumber, 2);
-        else if (fullRegExp.exactMatch(strName))
-            iMinimumPossibleNumber = qMax(iMinimumPossibleNumber, fullRegExp.cap(1).toInt() + 1);
-    }
-
-    /* Prepare/return result: */
-    QString strResult = strMinimumName;
-    if (iMinimumPossibleNumber)
-        strResult += " " + QString::number(iMinimumPossibleNumber);
-    return strResult;
-}
-
-void UIChooserAbstractModel::performSearch(const QString &strSearchTerm, int iItemSearchFlags)
-{
-    /* Make sure invisible root exists: */
-    AssertPtrReturnVoid(invisibleRoot());
-
-    /* Currently we perform the search only for machines, when this to be changed make
-     * sure the disabled flags of the other item types are also managed correctly. */
-
-    /* Reset the search first to erase the disabled flag,
-     * this also returns a full list of all machine nodes: */
-    const QList<UIChooserNode*> nodes = resetSearch();
-
-    /* Stop here if no search conditions specified: */
-    if (strSearchTerm.isEmpty())
-        return;
-
-    /* Search for all the nodes matching required condition: */
-    invisibleRoot()->searchForNodes(strSearchTerm, iItemSearchFlags, m_searchResults);
-
-    /* Assign/reset the disabled flag for required nodes: */
-    foreach (UIChooserNode *pNode, nodes)
-    {
-        if (!pNode)
-            continue;
-        pNode->setDisabled(!m_searchResults.contains(pNode));
-    }
-}
-
-QList<UIChooserNode*> UIChooserAbstractModel::resetSearch()
-{
-    /* Prepare resulting nodes: */
-    QList<UIChooserNode*> nodes;
-
-    /* Make sure invisible root exists: */
-    AssertPtrReturn(invisibleRoot(), nodes);
-
-    /* Calling UIChooserNode::searchForNodes with an empty search string
-     * returns a list all nodes (of the whole tree) of the required type: */
-    invisibleRoot()->searchForNodes(QString(), UIChooserItemSearchFlag_Machine, nodes);
-
-    /* Reset the disabled flag of the nodes first: */
-    foreach (UIChooserNode *pNode, nodes)
-    {
-        if (!pNode)
-            continue;
-        pNode->setDisabled(false);
-    }
-
-    /* Reset the search result related data: */
-    m_searchResults.clear();
-
-    /* Return  nodes: */
-    return nodes;
-}
-
-QList<UIChooserNode*> UIChooserAbstractModel::searchResult() const
-{
-    return m_searchResults;
-}
-
-void UIChooserAbstractModel::saveGroupSettings()
-{
-    emit sigStartGroupSaving();
-}
-
-bool UIChooserAbstractModel::isGroupSavingInProgress() const
-{
-    return    UIThreadGroupDefinitionSave::instance()
-           || UIThreadGroupOrderSave::instance();
-}
-
-void UIChooserAbstractModel::sltMachineStateChanged(const QUuid &uMachineId, const KMachineState)
-{
-    /* Update machine-nodes with passed id: */
-    invisibleRoot()->updateAllNodes(uMachineId);
-}
-
-void UIChooserAbstractModel::sltMachineDataChanged(const QUuid &uMachineId)
-{
-    /* Update machine-nodes with passed id: */
-    invisibleRoot()->updateAllNodes(uMachineId);
-}
-
-void UIChooserAbstractModel::sltMachineRegistered(const QUuid &uMachineId, const bool fRegistered)
-{
-    /* Existing VM unregistered? */
-    if (!fRegistered)
-    {
-        /* Remove machine-items with passed id: */
-        invisibleRoot()->removeAllNodes(uMachineId);
-        /* Wipe out empty groups: */
-        wipeOutEmptyGroups();
-    }
-    /* New VM registered? */
-    else
-    {
-        /* Should we show this VM? */
-        if (gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId))
-        {
-            /* Add new machine-item: */
-            const CMachine comMachine = uiCommon().virtualBox().FindMachine(uMachineId.toString());
-            addMachineIntoTheTree(comMachine, true /* make it visible */);
-        }
-    }
-}
-
-void UIChooserAbstractModel::sltSessionStateChanged(const QUuid &uMachineId, const KSessionState)
-{
-    /* Update machine-nodes with passed id: */
-    invisibleRoot()->updateAllNodes(uMachineId);
-}
-
-void UIChooserAbstractModel::sltSnapshotChanged(const QUuid &uMachineId, const QUuid &)
-{
-    /* Update machine-nodes with passed id: */
-    invisibleRoot()->updateAllNodes(uMachineId);
-}
-
-void UIChooserAbstractModel::sltReloadMachine(const QUuid &uMachineId)
-{
-    /* Remove machine-items with passed id: */
-    invisibleRoot()->removeAllNodes(uMachineId);
-    /* Wipe out empty groups: */
-    wipeOutEmptyGroups();
-
-    /* Should we show this VM? */
-    if (gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId))
-    {
-        /* Add new machine-item: */
-        const CMachine comMachine = uiCommon().virtualBox().FindMachine(uMachineId.toString());
-        addMachineIntoTheTree(comMachine, true /* make it visible */);
-    }
-}
-
-void UIChooserAbstractModel::sltStartGroupSaving()
-{
-    saveGroupDefinitions();
-    saveGroupOrders();
-}
-
-#ifdef VBOX_GUI_WITH_CLOUD_VMS
-void UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete(UITask *pTask)
-{
-    /* Skip unrelated tasks: */
-    if (!pTask || pTask->type() != UITask::Type_CloudAcquireInstances)
-        return;
-
-    /* Cast task to corresponding sub-class: */
-    UITaskCloudListMachines *pAcquiringTask = static_cast<UITaskCloudListMachines*>(pTask);
-
-    /* Make sure there were no errors: */
-    if (!pAcquiringTask->errorInfo().isNull())
-        return msgCenter().cannotAcquireCloudInstanceList(pAcquiringTask->errorInfo());
-
-    /* Acquire parent node and make sure it has children: */
-    /// @todo rework task to bring parent by id instead of pointer
-    ///       to object which maybe deleted to this moment already
-    UIChooserNode *pParentNode = pAcquiringTask->parentNode();
-    AssertPtrReturnVoid(pParentNode);
-    AssertReturnVoid(pParentNode->hasNodes());
-
-    /* Make sure this node have first child: */
-    UIChooserNode *pFirstChildNode = pParentNode->nodes().first();
-    AssertPtrReturnVoid(pFirstChildNode);
-
-    /* Which is machine node and has cache of fake-cloud-item type: */
-    UIChooserNodeMachine *pFirstChildNodeMachine = pFirstChildNode->toMachineNode();
-    AssertPtrReturnVoid(pFirstChildNodeMachine);
-    AssertPtrReturnVoid(pFirstChildNodeMachine->cache());
-    AssertReturnVoid(pFirstChildNodeMachine->cache()->itemType() == UIVirtualMachineItem::ItemType_CloudFake);
-
-    /* And if we have at least one cloud machine: */
-    const QVector<CCloudMachine> machines = pAcquiringTask->result();
-    if (!machines.isEmpty())
-    {
-        /* Remove the "Empty" node: */
-        delete pFirstChildNodeMachine;
-
-        /* Add real cloud VM nodes: */
-        int iPosition = 0;
-        foreach (const CCloudMachine &comCloudMachine, machines)
-            new UIChooserNodeMachine(pParentNode,
-                                     false /* favorite */,
-                                     iPosition++ /* position */,
-                                     comCloudMachine);
-    }
-    else
-    {
-        /* Otherwise toggle and update "Empty" node: */
-        UIVirtualMachineItemCloud *pFakeCloudMachineItem = pFirstChildNodeMachine->cache()->toCloud();
-        AssertPtrReturnVoid(pFakeCloudMachineItem);
-        pFakeCloudMachineItem->setFakeCloudItemState(UIVirtualMachineItemCloud::FakeCloudItemState_Done);
-        pFakeCloudMachineItem->recache();
-    }
-}
-#endif /* VBOX_GUI_WITH_CLOUD_VMS */
-
-void UIChooserAbstractModel::sltHandleCloudMachineStateChange()
-{
-    UIVirtualMachineItem *pCache = qobject_cast<UIVirtualMachineItem*>(sender());
-    AssertPtrReturnVoid(pCache);
-    emit sigCloudMachineStateChange(pCache->id());
-}
-
-void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete()
-{
-    makeSureGroupDefinitionsSaveIsFinished();
-    emit sigGroupSavingStateChanged();
-}
-
-void UIChooserAbstractModel::sltGroupOrdersSaveComplete()
-{
-    makeSureGroupOrdersSaveIsFinished();
-    emit sigGroupSavingStateChanged();
-}
-
-void UIChooserAbstractModel::prepare()
-{
-    prepareConnections();
-}
-
-void UIChooserAbstractModel::prepareConnections()
-{
-    /* Setup parent connections: */
-    connect(this, &UIChooserAbstractModel::sigGroupSavingStateChanged,
-            m_pParent, &UIChooser::sigGroupSavingStateChanged);
-
-    /* Setup global connections: */
-    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange,
-            this, &UIChooserAbstractModel::sltMachineStateChanged);
-    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineDataChange,
-            this, &UIChooserAbstractModel::sltMachineDataChanged);
-    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineRegistered,
-            this, &UIChooserAbstractModel::sltMachineRegistered);
-    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange,
-            this, &UIChooserAbstractModel::sltSessionStateChanged);
-    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotTake,
-            this, &UIChooserAbstractModel::sltSnapshotChanged);
-    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotDelete,
-            this, &UIChooserAbstractModel::sltSnapshotChanged);
-    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotChange,
-            this, &UIChooserAbstractModel::sltSnapshotChanged);
-    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotRestore,
-            this, &UIChooserAbstractModel::sltSnapshotChanged);
-
-    /* Setup group saving connections: */
-    connect(this, &UIChooserAbstractModel::sigStartGroupSaving,
-            this, &UIChooserAbstractModel::sltStartGroupSaving,
-            Qt::QueuedConnection);
-}
-
-void UIChooserAbstractModel::loadTree()
-{
     /* Create invisible root group node: */
     m_pInvisibleRootNode = new UIChooserNodeGroup(0 /* parent */,
@@ -389,9 +72,9 @@
     {
         /* Link root to this model: */
-        m_pInvisibleRootNode->setModel(this);
+        invisibleRoot()->setModel(this);
 
         /* Create global node: */
-        new UIChooserNodeGlobal(m_pInvisibleRootNode,
-                                isGlobalNodeFavorite(m_pInvisibleRootNode),
+        new UIChooserNodeGlobal(invisibleRoot(),
+                                isGlobalNodeFavorite(invisibleRoot()),
                                 0 /* position */,
                                 QString() /* tip */);
@@ -446,7 +129,7 @@
                         /* Add provider group node: */
                         UIChooserNodeGroup *pProviderNode =
-                            new UIChooserNodeGroup(m_pInvisibleRootNode,
+                            new UIChooserNodeGroup(invisibleRoot(),
                                                    false /* favorite */,
-                                                   getDesiredNodePosition(m_pInvisibleRootNode,
+                                                   getDesiredNodePosition(invisibleRoot(),
                                                                           UIChooserNodeType_Group,
                                                                           strProviderName),
@@ -512,4 +195,310 @@
 }
 
+void UIChooserAbstractModel::deinit()
+{
+    // WORKAROUND:
+    // Currently we are not saving group descriptors
+    // (which reflecting group toggle-state) on-the-fly,
+    // so for now we are additionally save group orders
+    // when exiting application:
+    saveGroupOrders();
+
+    /* Make sure all saving steps complete: */
+    makeSureGroupDefinitionsSaveIsFinished();
+    makeSureGroupOrdersSaveIsFinished();
+
+    /* Delete tree: */
+    delete m_pInvisibleRootNode;
+    m_pInvisibleRootNode = 0;
+}
+
+void UIChooserAbstractModel::wipeOutEmptyGroups()
+{
+    wipeOutEmptyGroupsStartingFrom(invisibleRoot());
+}
+
+/* static */
+QString UIChooserAbstractModel::uniqueGroupName(UIChooserNode *pRoot)
+{
+    /* Enumerate all the group names: */
+    QStringList groupNames;
+    foreach (UIChooserNode *pNode, pRoot->nodes(UIChooserNodeType_Group))
+        groupNames << pNode->name();
+
+    /* Prepare reg-exp: */
+    const QString strMinimumName = tr("New group");
+    const QString strShortTemplate = strMinimumName;
+    const QString strFullTemplate = strShortTemplate + QString(" (\\d+)");
+    const QRegExp shortRegExp(strShortTemplate);
+    const QRegExp fullRegExp(strFullTemplate);
+
+    /* Search for the maximum index: */
+    int iMinimumPossibleNumber = 0;
+    foreach (const QString &strName, groupNames)
+    {
+        if (shortRegExp.exactMatch(strName))
+            iMinimumPossibleNumber = qMax(iMinimumPossibleNumber, 2);
+        else if (fullRegExp.exactMatch(strName))
+            iMinimumPossibleNumber = qMax(iMinimumPossibleNumber, fullRegExp.cap(1).toInt() + 1);
+    }
+
+    /* Prepare/return result: */
+    QString strResult = strMinimumName;
+    if (iMinimumPossibleNumber)
+        strResult += " " + QString::number(iMinimumPossibleNumber);
+    return strResult;
+}
+
+void UIChooserAbstractModel::performSearch(const QString &strSearchTerm, int iItemSearchFlags)
+{
+    /* Make sure invisible root exists: */
+    AssertPtrReturnVoid(invisibleRoot());
+
+    /* Currently we perform the search only for machines, when this to be changed make
+     * sure the disabled flags of the other item types are also managed correctly. */
+
+    /* Reset the search first to erase the disabled flag,
+     * this also returns a full list of all machine nodes: */
+    const QList<UIChooserNode*> nodes = resetSearch();
+
+    /* Stop here if no search conditions specified: */
+    if (strSearchTerm.isEmpty())
+        return;
+
+    /* Search for all the nodes matching required condition: */
+    invisibleRoot()->searchForNodes(strSearchTerm, iItemSearchFlags, m_searchResults);
+
+    /* Assign/reset the disabled flag for required nodes: */
+    foreach (UIChooserNode *pNode, nodes)
+    {
+        if (!pNode)
+            continue;
+        pNode->setDisabled(!m_searchResults.contains(pNode));
+    }
+}
+
+QList<UIChooserNode*> UIChooserAbstractModel::resetSearch()
+{
+    /* Prepare resulting nodes: */
+    QList<UIChooserNode*> nodes;
+
+    /* Make sure invisible root exists: */
+    AssertPtrReturn(invisibleRoot(), nodes);
+
+    /* Calling UIChooserNode::searchForNodes with an empty search string
+     * returns a list all nodes (of the whole tree) of the required type: */
+    invisibleRoot()->searchForNodes(QString(), UIChooserItemSearchFlag_Machine, nodes);
+
+    /* Reset the disabled flag of the nodes first: */
+    foreach (UIChooserNode *pNode, nodes)
+    {
+        if (!pNode)
+            continue;
+        pNode->setDisabled(false);
+    }
+
+    /* Reset the search result related data: */
+    m_searchResults.clear();
+
+    /* Return  nodes: */
+    return nodes;
+}
+
+QList<UIChooserNode*> UIChooserAbstractModel::searchResult() const
+{
+    return m_searchResults;
+}
+
+void UIChooserAbstractModel::saveGroupSettings()
+{
+    emit sigStartGroupSaving();
+}
+
+bool UIChooserAbstractModel::isGroupSavingInProgress() const
+{
+    return    UIThreadGroupDefinitionSave::instance()
+           || UIThreadGroupOrderSave::instance();
+}
+
+void UIChooserAbstractModel::sltMachineStateChanged(const QUuid &uMachineId, const KMachineState)
+{
+    /* Update machine-nodes with passed id: */
+    invisibleRoot()->updateAllNodes(uMachineId);
+}
+
+void UIChooserAbstractModel::sltMachineDataChanged(const QUuid &uMachineId)
+{
+    /* Update machine-nodes with passed id: */
+    invisibleRoot()->updateAllNodes(uMachineId);
+}
+
+void UIChooserAbstractModel::sltMachineRegistered(const QUuid &uMachineId, const bool fRegistered)
+{
+    /* Existing VM unregistered? */
+    if (!fRegistered)
+    {
+        /* Remove machine-items with passed id: */
+        invisibleRoot()->removeAllNodes(uMachineId);
+        /* Wipe out empty groups: */
+        wipeOutEmptyGroups();
+    }
+    /* New VM registered? */
+    else
+    {
+        /* Should we show this VM? */
+        if (gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId))
+        {
+            /* Add new machine-item: */
+            const CMachine comMachine = uiCommon().virtualBox().FindMachine(uMachineId.toString());
+            addMachineIntoTheTree(comMachine, true /* make it visible */);
+        }
+    }
+}
+
+void UIChooserAbstractModel::sltSessionStateChanged(const QUuid &uMachineId, const KSessionState)
+{
+    /* Update machine-nodes with passed id: */
+    invisibleRoot()->updateAllNodes(uMachineId);
+}
+
+void UIChooserAbstractModel::sltSnapshotChanged(const QUuid &uMachineId, const QUuid &)
+{
+    /* Update machine-nodes with passed id: */
+    invisibleRoot()->updateAllNodes(uMachineId);
+}
+
+void UIChooserAbstractModel::sltReloadMachine(const QUuid &uMachineId)
+{
+    /* Remove machine-items with passed id: */
+    invisibleRoot()->removeAllNodes(uMachineId);
+    /* Wipe out empty groups: */
+    wipeOutEmptyGroups();
+
+    /* Should we show this VM? */
+    if (gEDataManager->showMachineInVirtualBoxManagerChooser(uMachineId))
+    {
+        /* Add new machine-item: */
+        const CMachine comMachine = uiCommon().virtualBox().FindMachine(uMachineId.toString());
+        addMachineIntoTheTree(comMachine, true /* make it visible */);
+    }
+}
+
+void UIChooserAbstractModel::sltStartGroupSaving()
+{
+    saveGroupDefinitions();
+    saveGroupOrders();
+}
+
+#ifdef VBOX_GUI_WITH_CLOUD_VMS
+void UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete(UITask *pTask)
+{
+    /* Skip unrelated tasks: */
+    if (!pTask || pTask->type() != UITask::Type_CloudAcquireInstances)
+        return;
+
+    /* Cast task to corresponding sub-class: */
+    UITaskCloudListMachines *pAcquiringTask = static_cast<UITaskCloudListMachines*>(pTask);
+
+    /* Make sure there were no errors: */
+    if (!pAcquiringTask->errorInfo().isNull())
+        return msgCenter().cannotAcquireCloudInstanceList(pAcquiringTask->errorInfo());
+
+    /* Acquire parent node and make sure it has children: */
+    /// @todo rework task to bring parent by id instead of pointer
+    ///       to object which maybe deleted to this moment already
+    UIChooserNode *pParentNode = pAcquiringTask->parentNode();
+    AssertPtrReturnVoid(pParentNode);
+    AssertReturnVoid(pParentNode->hasNodes());
+
+    /* Make sure this node have first child: */
+    UIChooserNode *pFirstChildNode = pParentNode->nodes().first();
+    AssertPtrReturnVoid(pFirstChildNode);
+
+    /* Which is machine node and has cache of fake-cloud-item type: */
+    UIChooserNodeMachine *pFirstChildNodeMachine = pFirstChildNode->toMachineNode();
+    AssertPtrReturnVoid(pFirstChildNodeMachine);
+    AssertPtrReturnVoid(pFirstChildNodeMachine->cache());
+    AssertReturnVoid(pFirstChildNodeMachine->cache()->itemType() == UIVirtualMachineItem::ItemType_CloudFake);
+
+    /* And if we have at least one cloud machine: */
+    const QVector<CCloudMachine> machines = pAcquiringTask->result();
+    if (!machines.isEmpty())
+    {
+        /* Remove the "Empty" node: */
+        delete pFirstChildNodeMachine;
+
+        /* Add real cloud VM nodes: */
+        int iPosition = 0;
+        foreach (const CCloudMachine &comCloudMachine, machines)
+            new UIChooserNodeMachine(pParentNode,
+                                     false /* favorite */,
+                                     iPosition++ /* position */,
+                                     comCloudMachine);
+    }
+    else
+    {
+        /* Otherwise toggle and update "Empty" node: */
+        UIVirtualMachineItemCloud *pFakeCloudMachineItem = pFirstChildNodeMachine->cache()->toCloud();
+        AssertPtrReturnVoid(pFakeCloudMachineItem);
+        pFakeCloudMachineItem->setFakeCloudItemState(UIVirtualMachineItemCloud::FakeCloudItemState_Done);
+        pFakeCloudMachineItem->recache();
+    }
+}
+#endif /* VBOX_GUI_WITH_CLOUD_VMS */
+
+void UIChooserAbstractModel::sltHandleCloudMachineStateChange()
+{
+    UIVirtualMachineItem *pCache = qobject_cast<UIVirtualMachineItem*>(sender());
+    AssertPtrReturnVoid(pCache);
+    emit sigCloudMachineStateChange(pCache->id());
+}
+
+void UIChooserAbstractModel::sltGroupDefinitionsSaveComplete()
+{
+    makeSureGroupDefinitionsSaveIsFinished();
+    emit sigGroupSavingStateChanged();
+}
+
+void UIChooserAbstractModel::sltGroupOrdersSaveComplete()
+{
+    makeSureGroupOrdersSaveIsFinished();
+    emit sigGroupSavingStateChanged();
+}
+
+void UIChooserAbstractModel::prepare()
+{
+    prepareConnections();
+}
+
+void UIChooserAbstractModel::prepareConnections()
+{
+    /* Setup parent connections: */
+    connect(this, &UIChooserAbstractModel::sigGroupSavingStateChanged,
+            m_pParent, &UIChooser::sigGroupSavingStateChanged);
+
+    /* Setup global connections: */
+    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange,
+            this, &UIChooserAbstractModel::sltMachineStateChanged);
+    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineDataChange,
+            this, &UIChooserAbstractModel::sltMachineDataChanged);
+    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineRegistered,
+            this, &UIChooserAbstractModel::sltMachineRegistered);
+    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange,
+            this, &UIChooserAbstractModel::sltSessionStateChanged);
+    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotTake,
+            this, &UIChooserAbstractModel::sltSnapshotChanged);
+    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotDelete,
+            this, &UIChooserAbstractModel::sltSnapshotChanged);
+    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotChange,
+            this, &UIChooserAbstractModel::sltSnapshotChanged);
+    connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSnapshotRestore,
+            this, &UIChooserAbstractModel::sltSnapshotChanged);
+
+    /* Setup group saving connections: */
+    connect(this, &UIChooserAbstractModel::sigStartGroupSaving,
+            this, &UIChooserAbstractModel::sltStartGroupSaving,
+            Qt::QueuedConnection);
+}
+
 void UIChooserAbstractModel::addMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible /* = false */)
 {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h	(revision 83688)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h	(revision 83689)
@@ -80,5 +80,5 @@
       * @{ */
         /** Returns invisible root node instance. */
-        UIChooserNode *invisibleRoot() const;
+        UIChooserNode *invisibleRoot() const { return m_pInvisibleRootNode; }
 
         /** Wipes out empty groups. */
@@ -174,6 +174,4 @@
     /** @name Children stuff.
       * @{ */
-        /** Loads tree. */
-        void loadTree();
         /** Adds machine item based on certain @a comMachine and optionally @a fMakeItVisible. */
         void addMachineIntoTheTree(const CMachine &comMachine, bool fMakeItVisible = false);
