VirtualBox

Ignore:
Timestamp:
Oct 22, 2020 2:55:41 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Cloud Profile Manager: Restore current item by definition while loading cloud stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.cpp

    r86669 r86671  
    2525#include "QIInputDialog.h"
    2626#include "QIMessageBox.h"
     27#include "QIToolBar.h"
    2728#include "QITreeWidget.h"
    28 #include "UICommon.h"
    2929#include "UIActionPoolManager.h"
    3030#include "UICloudNetworkingStuff.h"
     31#include "UICloudProfileDetailsWidget.h"
     32#include "UICloudProfileManager.h"
     33#include "UICommon.h"
    3134#include "UIExtraDataManager.h"
    3235#include "UIIconPool.h"
    33 #include "UICloudProfileDetailsWidget.h"
    34 #include "UICloudProfileManager.h"
    3536#include "UIMessageCenter.h"
    36 #include "QIToolBar.h"
     37#include "UIVirtualBoxEventHandler.h"
    3738
    3839/* COM includes: */
     
    814815void UICloudProfileManagerWidget::loadCloudStuff()
    815816{
     817    /* Save current item definition: */
     818    QITreeWidgetItem *pCurrentItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem());
     819    const QString strDefinition = pCurrentItem ? pCurrentItem->data(Column_Name, Data_Definition).toString() : QString();
     820
    816821    /* Clear tree first of all: */
    817822    m_pTreeWidget->clear();
     
    852857    }
    853858
    854     /* Choose the 1st item as current initially: */
    855     m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0));
     859    /* Try to restore current item by definition: */
     860    if (!strDefinition.isEmpty())
     861        m_pTreeWidget->setCurrentItem(searchItem(strDefinition));
     862    /* Choose the 1st item as current if nothing chosen: */
     863    if (!m_pTreeWidget->currentItem())
     864        m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0));
     865    /* Handle current item change in any case: */
    856866    sltHandleCurrentItemChange();
    857867}
     
    915925    if (!comProfile.isOk())
    916926        msgCenter().cannotAcquireCloudProfileParameter(comProfile, this);
     927}
     928
     929QTreeWidgetItem *UICloudProfileManagerWidget::searchItem(const QString &strDefinition,
     930                                                         QTreeWidgetItem *pParentItem /* = 0 */) const
     931{
     932    /* If no parent-item passed => we will start from the invisible-root-item: */
     933    if (!pParentItem)
     934        pParentItem = m_pTreeWidget->invisibleRootItem();
     935
     936    /* Check whether parent-item is of required type: */
     937    QITreeWidgetItem *pParentItemOfType = QITreeWidgetItem::toItem(pParentItem);
     938    if (pParentItemOfType)
     939    {
     940        /* Check if parent-item has required definition: */
     941        if (pParentItemOfType->data(Column_Name, Data_Definition).toString() == strDefinition)
     942            return pParentItem;
     943    }
     944
     945    /* Iterate through parent-item children: */
     946    for (int i = 0; i < pParentItem->childCount(); ++i)
     947        if (QTreeWidgetItem *pChildItem = searchItem(strDefinition, pParentItem->child(i)))
     948            return pChildItem;
     949
     950    /* Null by default: */
     951    return 0;
    917952}
    918953
  • trunk/src/VBox/Frontends/VirtualBox/src/cloud/profilemanager/UICloudProfileManager.h

    r86250 r86671  
    168168    /** @name Tree-widget stuff.
    169169      * @{ */
    170         /** Seearches a provider item with specified @a uId. */
     170        /** Recursively searches for an item with specified @a strDefinition,
     171          * using @a pParentItem as an item to start search from. */
     172        QTreeWidgetItem *searchItem(const QString &strDefinition,
     173                                    QTreeWidgetItem *pParentItem = 0) const;
     174        /** Searches for a provider item with specified @a uId. */
    171175        UIItemCloudProvider *searchItem(const QUuid &uId) const;
    172176
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette