VirtualBox

Changeset 50340 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 6, 2014 12:30:14 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: 4397: Medium Manager cleanup/rework (part 6): Tree-widgets re-population stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/medium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r50330 r50340  
    328328void UIMediumManager::sltHandleMediumEnumerationStart()
    329329{
     330    /* Disable 'refresh' action: */
     331    m_pActionRefresh->setEnabled(false);
     332
     333    /* Reset and show progress-bar: */
     334    m_pProgressBar->setMaximum(vboxGlobal().mediumIDs().size());
     335    m_pProgressBar->setValue(0);
     336    m_pProgressBar->show();
     337
    330338    /* Reset inaccessibility flags: */
    331339    m_fInaccessibleHD =
     
    333341            m_fInaccessibleFD = false;
    334342
    335     /* Load default tab-widget icons: */
     343    /* Reset tab-widget icons: */
    336344    mTabWidget->setTabIcon(HDTab, m_iconHD);
    337345    mTabWidget->setTabIcon(CDTab, m_iconCD);
    338346    mTabWidget->setTabIcon(FDTab, m_iconFD);
    339347
    340     /* Repopulate all medium-items: */
    341     QList<QString> mediumIDs = vboxGlobal().mediumIDs();
    342     prepareToRefresh(mediumIDs.size());
    343     foreach (const QString &strMediumID, mediumIDs)
    344         sltHandleMediumCreated(strMediumID);
    345 
    346     /* Select the first item to be the current one
    347      * if the previous saved item was not selected yet. */
    348     if (!mTwHD->currentItem())
    349         if (QTreeWidgetItem *pItem = mTwHD->topLevelItem(0))
    350             setCurrentItem(mTwHD, pItem);
    351     if (!mTwCD->currentItem())
    352         if (QTreeWidgetItem *pItem = mTwCD->topLevelItem(0))
    353             setCurrentItem(mTwCD, pItem);
    354     if (!mTwFD->currentItem())
    355         if (QTreeWidgetItem *pItem = mTwFD->topLevelItem(0))
    356             setCurrentItem(mTwFD, pItem);
     348    /* Repopulate tree-widgets content: */
     349    repopulateTreeWidgets();
    357350
    358351    /* Update current tab: */
     
    388381    /* Enable 'refresh' action: */
    389382    m_pActionRefresh->setEnabled(true);
    390 
    391     /* Unset 'busy' cursor: */
    392     unsetCursor();
    393383
    394384    /* Update current tab: */
     
    702692    centerAccording(m_pCenterWidget);
    703693
    704     /* Populate content for tree-widgets: */
    705     populateTreeWidgets();
    706 
    707     /* Update all information-panes: */
     694    /* Initialize information-panes: */
    708695    updateInformationPanes(UIMediumType_All);
     696
     697    /* Start medium-enumeration (if necessary): */
     698    if (m_fRefresh && !vboxGlobal().isMediumEnumerationInProgress())
     699        vboxGlobal().startMediumEnumeration();
     700    /* Emulate medium-enumeration otherwise: */
     701    else
     702    {
     703        /* Start medium-enumeration: */
     704        sltHandleMediumEnumerationStart();
     705
     706        /* Finish medium-enumeration (if necessary): */
     707        if (!vboxGlobal().isMediumEnumerationInProgress())
     708            sltHandleMediumEnumerationFinish();
     709    }
    709710}
    710711
     
    10071008#endif /* Q_WS_MAC */
    10081009
    1009 void UIMediumManager::populateTreeWidgets()
    1010 {
    1011     /* If refresh was requested and enumeration was not yet started: */
    1012     if (m_fRefresh && !vboxGlobal().isMediumEnumerationInProgress())
    1013     {
    1014         /* Just start medium-enumeration: */
    1015         vboxGlobal().startMediumEnumeration();
    1016     }
    1017     /* If refresh was not requested or enumeration already started: */
    1018     else
    1019     {
    1020         /* Emulate (possible partial) medium-enumeration: */
    1021         QList<QString> mediumIDs = vboxGlobal().mediumIDs();
    1022         prepareToRefresh(mediumIDs.size());
    1023         foreach (const QString &strMediumID, mediumIDs)
    1024         {
    1025             /* Get corresponding medium: */
    1026             const UIMedium medium = vboxGlobal().medium(strMediumID);
    1027             /* Create corresponding medium-item: */
    1028             sltHandleMediumCreated(strMediumID);
    1029             /* Advance progress-bar only for created mediums: */
    1030             if (medium.state() != KMediumState_NotCreated)
    1031                 m_pProgressBar->setValue(m_pProgressBar->value() + 1);
    1032         }
    1033         /* Finally, emulate enumeration finish,
    1034          * if enumeration already finished or wasn't started: */
    1035         if (!vboxGlobal().isMediumEnumerationInProgress())
    1036             sltHandleMediumEnumerationFinish();
    1037     }
    1038 
    1039     /* For a newly opened dialog, select the first item: */
    1040     if (!mTwHD->currentItem())
     1010void UIMediumManager::repopulateTreeWidgets()
     1011{
     1012    /* Remember current medium-items: */
     1013    if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_HardDisk))
     1014        m_strSelectedIdHD = pMediumItem->id();
     1015    if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_DVD))
     1016        m_strSelectedIdCD = pMediumItem->id();
     1017    if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_Floppy))
     1018        m_strSelectedIdFD = pMediumItem->id();
     1019
     1020    /* Clear tree-widgets: */
     1021    mTwHD->clear();
     1022    mTwCD->clear();
     1023    mTwFD->clear();
     1024
     1025    /* Populate all medium-items: */
     1026    foreach (const QString &strMediumID, vboxGlobal().mediumIDs())
     1027        sltHandleMediumCreated(strMediumID);
     1028
     1029    /* Select first-item as current medium-item if nothing selected: */
     1030    if (!mediumItem(UIMediumType_HardDisk))
    10411031        if (QTreeWidgetItem *pItem = mTwHD->topLevelItem(0))
    10421032            setCurrentItem(mTwHD, pItem);
    1043     if (!mTwCD->currentItem())
     1033    if (!mediumItem(UIMediumType_DVD))
    10441034        if (QTreeWidgetItem *pItem = mTwCD->topLevelItem(0))
    10451035            setCurrentItem(mTwCD, pItem);
    1046     if (!mTwFD->currentItem())
     1036    if (!mediumItem(UIMediumType_Floppy))
    10471037        if (QTreeWidgetItem *pItem = mTwFD->topLevelItem(0))
    10481038            setCurrentItem(mTwFD, pItem);
     
    17681758}
    17691759
    1770 void UIMediumManager::prepareToRefresh(int iTotal)
    1771 {
    1772     /* Clear information panes: */
    1773     m_pTypePane->clear(); m_pLocationPane->clear(); m_pFormatPane->clear(); m_pDetailsPane->clear(); m_pUsagePane->clear();
    1774     mIpCD1->clear(); mIpCD2->clear();
    1775     mIpFD1->clear(); mIpFD2->clear();
    1776 
    1777     /* Prepare progressbar: */
    1778     if (m_pProgressBar)
    1779     {
    1780         m_pProgressBar->setMaximum(iTotal);
    1781         m_pProgressBar->setValue(0);
    1782         m_pProgressBar->setVisible(true);
    1783     }
    1784 
    1785     /* Enable refresh action: */
    1786     m_pActionRefresh->setEnabled(false);
    1787 
    1788     /* Set busy cursor: */
    1789     setCursor(QCursor(Qt::BusyCursor));
    1790 
    1791     /* Store the current list selections: */
    1792     UIMediumItem *pMediumItem = 0;
    1793     pMediumItem = mediumItem(UIMediumType_HardDisk);
    1794     if (m_strSelectedIdHD.isNull())
    1795         m_strSelectedIdHD = pMediumItem ? pMediumItem->id() : QString();
    1796     pMediumItem = mediumItem(UIMediumType_DVD);
    1797     if (m_strSelectedIdCD.isNull())
    1798         m_strSelectedIdCD = pMediumItem ? pMediumItem->id() : QString();
    1799     pMediumItem = mediumItem(UIMediumType_Floppy);
    1800     if (m_strSelectedIdFD.isNull())
    1801         m_strSelectedIdFD = pMediumItem ? pMediumItem->id() : QString();
    1802 
    1803     /* Finally, clear all the lists...
    1804      * Qt4 has interesting bug here. It sends the currentChanged (cur, prev)
    1805      * signal during list clearing with 'cur' set to null and 'prev' pointing
    1806      * to already excluded element if this element is not topLevelItem
    1807      * (has parent). Cause the Hard Disk list has such elements there is
    1808      * seg-fault when trying to make 'prev' element the current due to 'cur'
    1809      * is null and at least one element have to be selected (by policy).
    1810      * So just blocking any signals outgoing from the list during clearing. */
    1811     mTwHD->blockSignals(true);
    1812     mTwHD->clear();
    1813     mTwHD->blockSignals(false);
    1814     mTwCD->clear();
    1815     mTwFD->clear();
    1816 }
    1817 
    18181760/* static */
    18191761UIMediumItem* UIMediumManager::toMediumItem(QTreeWidgetItem *pItem)
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h

    r50330 r50340  
    118118#endif /* Q_WS_MAC */
    119119
    120     /* Helper: Populate stuff: */
    121     void populateTreeWidgets();
     120    /** Repopulates tree-widgets content. */
     121    void repopulateTreeWidgets();
    122122
    123123    /** Update actions according currently chosen medium-item. */
     
    174174    UIMediumItem* createHardDiskItem(QTreeWidget *pTree, const UIMedium &medium) const;
    175175
    176     /* Helpers: Other stuff: */
     176    /* Helper: Other stuff: */
    177177    bool checkMediumFor(UIMediumItem *pItem, Action action);
    178     void prepareToRefresh(int iTotal = 0);
    179178
    180179    /** Casts passed QTreeWidgetItem @a pItem to UIMediumItem if possible. */
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