Changeset 49658 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Nov 26, 2013 12:16:23 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r49657 r49658 388 388 mTabWidget->setTabIcon(FDTab, m_iconFD); 389 389 390 /* Load mediums: */390 /* Repopulate all medium-items: */ 391 391 QList<QString> mediumIDs = vboxGlobal().mediumIDs(); 392 QList<QString> loadedMediumIDs;393 392 prepareToRefresh(mediumIDs.size()); 394 while (!mediumIDs.isEmpty()) 395 { 396 /* Get first available medium: */ 397 QString strMediumID = mediumIDs.first(); 398 UIMedium medium = vboxGlobal().medium(strMediumID); 399 /* Make sure medium parent (if any) is already in list: */ 400 while (medium.parentID() != UIMedium::nullID() && 401 !loadedMediumIDs.contains(medium.parentID())) 402 { 403 medium = medium.parent(); 404 strMediumID = medium.id(); 405 } 406 /* Insert resulting medium into tree: */ 407 int iItemIndex = mediumIDs.indexOf(strMediumID); 408 AssertReturnVoid(iItemIndex != -1); 409 loadedMediumIDs.append(mediumIDs.takeAt(iItemIndex)); 393 foreach (const QString &strMediumID, mediumIDs) 410 394 sltHandleMediumCreated(strMediumID); 411 }412 395 413 396 /* Select the first item to be the current one … … 441 424 return; 442 425 443 /* Preparemedium-item: */426 /* Search for corresponding medium-item: */ 444 427 UIMediumItem *pMediumItem = 0; 445 428 switch (medium.type()) … … 450 433 default: AssertFailed(); 451 434 } 452 AssertPtrReturnVoid(pMediumItem); 435 436 /* If medium-item was not found it's time to create it: */ 437 if (!pMediumItem) 438 return sltHandleMediumCreated(strMediumID); 453 439 454 440 /* Update medium-item: */ … … 1143 1129 /* Emulate (possible partial) medium-enumeration: */ 1144 1130 QList<QString> mediumIDs = vboxGlobal().mediumIDs(); 1145 QList<QString> loadedMediumIDs;1146 1131 prepareToRefresh(mediumIDs.size()); 1147 while (!mediumIDs.isEmpty()) 1148 { 1149 /* Get first available medium: */ 1150 QString strMediumID = mediumIDs.first(); 1151 UIMedium medium = vboxGlobal().medium(strMediumID); 1152 /* Make sure medium parent (if any) is already in list: */ 1153 while (medium.parentID() != UIMedium::nullID() && 1154 !loadedMediumIDs.contains(medium.parentID())) 1155 { 1156 medium = medium.parent(); 1157 strMediumID = medium.id(); 1158 } 1159 /* Insert resulting medium into tree: */ 1160 int iItemIndex = mediumIDs.indexOf(strMediumID); 1161 AssertReturnVoid(iItemIndex != -1); 1162 loadedMediumIDs.append(mediumIDs.takeAt(iItemIndex)); 1132 foreach (const QString &strMediumID, mediumIDs) 1133 { 1134 /* Get corresponding medium: */ 1135 const UIMedium medium = vboxGlobal().medium(strMediumID); 1136 /* Create corresponding medium-item: */ 1163 1137 sltHandleMediumCreated(strMediumID); 1164 1138 /* Advance progress-bar only for created mediums: */ … … 1512 1486 AssertReturn(!medium.medium().isNull(), 0); 1513 1487 1514 /* Prepare medium-item: */ 1515 UIMediumItem *pMediumItem = 0; 1516 1517 /* First try to create item under corresponding parent: */ 1518 if (medium.parentID() != UIMedium::nullID()) 1519 if (UIMediumItem *pRoot = searchItem(pTree, CheckIfSuitableByID(medium.parentID()))) 1520 pMediumItem = new UIMediumItem(medium, pRoot); 1521 /* Else just create item as top-level one: */ 1488 /* Search for medium-item: */ 1489 UIMediumItem *pMediumItem = searchItem(pTree, CheckIfSuitableByID(medium.id())); 1490 1491 /* If medium-item do not exists: */ 1522 1492 if (!pMediumItem) 1523 pMediumItem = new UIMediumItem(medium, pTree); 1524 1525 /* Return created item: */ 1493 { 1494 /* If medium have a parent: */ 1495 if (medium.parentID() != UIMedium::nullID()) 1496 { 1497 /* Try to find parent medium-item: */ 1498 UIMediumItem *pParentMediumItem = searchItem(pTree, CheckIfSuitableByID(medium.parentID())); 1499 /* If parent medium-item was not found: */ 1500 if (!pParentMediumItem) 1501 { 1502 /* Make sure such corresponding parent medium is already cached! */ 1503 UIMedium parentMedium = vboxGlobal().medium(medium.parentID()); 1504 if (parentMedium.isNull()) 1505 AssertMsgFailed(("Parent medium with ID={%s} was not found!\n", medium.parentID().toAscii().constData())); 1506 /* Try to create parent medium-item: */ 1507 else 1508 pParentMediumItem = createHardDiskItem(pTree, parentMedium); 1509 } 1510 /* If parent medium-item was found: */ 1511 if (pParentMediumItem) 1512 pMediumItem = new UIMediumItem(medium, pParentMediumItem); 1513 } 1514 /* Else just create item as top-level one: */ 1515 if (!pMediumItem) 1516 pMediumItem = new UIMediumItem(medium, pTree); 1517 } 1518 1519 /* Return medium-item: */ 1526 1520 return pMediumItem; 1527 1521 }
Note:
See TracChangeset
for help on using the changeset viewer.