Changeset 50340 in vbox for trunk/src/VBox
- Timestamp:
- Feb 6, 2014 12:30:14 PM (11 years ago)
- 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 328 328 void UIMediumManager::sltHandleMediumEnumerationStart() 329 329 { 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 330 338 /* Reset inaccessibility flags: */ 331 339 m_fInaccessibleHD = … … 333 341 m_fInaccessibleFD = false; 334 342 335 /* Load default tab-widget icons: */343 /* Reset tab-widget icons: */ 336 344 mTabWidget->setTabIcon(HDTab, m_iconHD); 337 345 mTabWidget->setTabIcon(CDTab, m_iconCD); 338 346 mTabWidget->setTabIcon(FDTab, m_iconFD); 339 347 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(); 357 350 358 351 /* Update current tab: */ … … 388 381 /* Enable 'refresh' action: */ 389 382 m_pActionRefresh->setEnabled(true); 390 391 /* Unset 'busy' cursor: */392 unsetCursor();393 383 394 384 /* Update current tab: */ … … 702 692 centerAccording(m_pCenterWidget); 703 693 704 /* Populate content for tree-widgets: */ 705 populateTreeWidgets(); 706 707 /* Update all information-panes: */ 694 /* Initialize information-panes: */ 708 695 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 } 709 710 } 710 711 … … 1007 1008 #endif /* Q_WS_MAC */ 1008 1009 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()) 1010 void 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)) 1041 1031 if (QTreeWidgetItem *pItem = mTwHD->topLevelItem(0)) 1042 1032 setCurrentItem(mTwHD, pItem); 1043 if (!m TwCD->currentItem())1033 if (!mediumItem(UIMediumType_DVD)) 1044 1034 if (QTreeWidgetItem *pItem = mTwCD->topLevelItem(0)) 1045 1035 setCurrentItem(mTwCD, pItem); 1046 if (!m TwFD->currentItem())1036 if (!mediumItem(UIMediumType_Floppy)) 1047 1037 if (QTreeWidgetItem *pItem = mTwFD->topLevelItem(0)) 1048 1038 setCurrentItem(mTwFD, pItem); … … 1768 1758 } 1769 1759 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' pointing1806 * to already excluded element if this element is not topLevelItem1807 * (has parent). Cause the Hard Disk list has such elements there is1808 * 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 1818 1760 /* static */ 1819 1761 UIMediumItem* UIMediumManager::toMediumItem(QTreeWidgetItem *pItem) -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.h
r50330 r50340 118 118 #endif /* Q_WS_MAC */ 119 119 120 /* Helper: Populate stuff:*/121 void populateTreeWidgets();120 /** Repopulates tree-widgets content. */ 121 void repopulateTreeWidgets(); 122 122 123 123 /** Update actions according currently chosen medium-item. */ … … 174 174 UIMediumItem* createHardDiskItem(QTreeWidget *pTree, const UIMedium &medium) const; 175 175 176 /* Helper s: Other stuff: */176 /* Helper: Other stuff: */ 177 177 bool checkMediumFor(UIMediumItem *pItem, Action action); 178 void prepareToRefresh(int iTotal = 0);179 178 180 179 /** Casts passed QTreeWidgetItem @a pItem to UIMediumItem if possible. */
Note:
See TracChangeset
for help on using the changeset viewer.