Changeset 50343 in vbox
- Timestamp:
- Feb 6, 2014 2:12:00 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r50340 r50343 146 146 147 147 148 /** Functor allowing to check if passed UIMediumItem is suitable by ID. */148 /** Functor allowing to check if passed UIMediumItem is suitable by @a strID. */ 149 149 class CheckIfSuitableByID : public CheckIfSuitableBy 150 150 { 151 151 public: 152 /** Constructor . */152 /** Constructor accepting @a strID to compare with. */ 153 153 CheckIfSuitableByID(const QString &strID) : m_strID(strID) {} 154 154 155 155 private: 156 /** Determines whether passed UIMediumItem is suitable by ID. */156 /** Determines whether passed UIMediumItem is suitable by @a strID. */ 157 157 bool isItSuitable(UIMediumItem *pItem) const { return pItem->id() == m_strID; } 158 /** Holds the ID to compare to. */158 /** Holds the @a strID to compare to. */ 159 159 QString m_strID; 160 160 }; … … 164 164 { 165 165 public: 166 /** Constructor . */166 /** Constructor accepting @a state to compare with. */ 167 167 CheckIfSuitableByState(KMediumState state) : m_state(state) {} 168 168 … … 175 175 176 176 177 /* Medium manager progress-bar: */ 177 /** Medium manager progress-bar. 178 * Reflects medium-enumeration progress, stays hidden otherwise. */ 178 179 class UIEnumerationProgressBar : public QWidget 179 180 { … … 182 183 public: 183 184 184 /* Constructor:*/185 /** Constructor on the basis of passed @a pParent. */ 185 186 UIEnumerationProgressBar(QWidget *pParent) 186 187 : QWidget(pParent) … … 190 191 } 191 192 192 /* API: Text stuff:*/193 void setText(const QString &strText) { m Text->setText(strText); }194 195 /* API: Value stuff:*/193 /** Defines progress-bar label-text. */ 194 void setText(const QString &strText) { m_pLabel->setText(strText); } 195 196 /** Returns progress-bar current-value. */ 196 197 int value() const { return m_pProgressBar->value(); } 198 /** Defines progress-bar current-value. */ 197 199 void setValue(int iValue) { m_pProgressBar->setValue(iValue); } 200 /** Defines progress-bar maximum-value. */ 198 201 void setMaximum(int iValue) { m_pProgressBar->setMaximum(iValue); } 199 202 200 203 private: 201 204 202 /* Helper: Prepare stuff:*/205 /** Prepares progress-bar content. */ 203 206 void prepare() 204 207 { … … 209 212 pLayout->setContentsMargins(0, 0, 0, 0); 210 213 /* Create label: */ 211 m Text= new QLabel;214 m_pLabel = new QLabel; 212 215 /* Create progress-bar: */ 213 216 m_pProgressBar = new QProgressBar; … … 217 220 } 218 221 /* Add widgets into layout: */ 219 pLayout->addWidget(m Text);222 pLayout->addWidget(m_pLabel); 220 223 pLayout->addWidget(m_pProgressBar); 221 224 } 222 225 } 223 226 224 /* Widgets: */ 225 QLabel *mText; 227 /** Progress-bar label. */ 228 QLabel *m_pLabel; 229 /** Progress-bar itself. */ 226 230 QProgressBar *m_pProgressBar; 227 231 }; … … 313 317 updateTabIcons(pMediumItem, ItemAction_Removed); 314 318 315 /* We need to silently delete item without selecting319 /* We need to silently delete medium-item without selecting 316 320 * the new one because of complex selection mechanism 317 321 * which could provoke a segfault choosing the new … … 322 326 pTree->blockSignals(false); 323 327 324 /* Set new current-item: */328 /* Make sure current medium-item is selected: */ 325 329 setCurrentItem(pTree, pTree->currentItem()); 326 330 } … … 388 392 void UIMediumManager::sltCopyMedium() 389 393 { 390 /* Get current -item: */394 /* Get current medium-item: */ 391 395 UIMediumItem *pMediumItem = currentMediumItem(); 396 AssertMsgReturnVoid(pMediumItem, ("Current item must not be null")); 397 AssertReturnVoid(!pMediumItem->id().isNull()); 392 398 393 399 /* Show Clone VD wizard: */ … … 403 409 void UIMediumManager::sltModifyMedium() 404 410 { 405 /* Get current -item: */411 /* Get current medium-item: */ 406 412 UIMediumItem *pMediumItem = currentMediumItem(); 413 AssertMsgReturnVoid(pMediumItem, ("Current item must not be null")); 414 AssertReturnVoid(!pMediumItem->id().isNull()); 407 415 408 416 /* Show Modify VD dialog: */ … … 410 418 if (pDialog->exec() == QDialog::Accepted) 411 419 { 412 /* Safe spot because if dialog is deleted inside ::exec() => 413 * returned result will be QDialog::Rejected. */ 420 /* Update medium-item: */ 414 421 pMediumItem->refreshAll(); 415 m_pTypePane->setText(pMediumItem->hardDiskType()); 422 /* Update HD information-panes: */ 423 updateInformationPanesHD(); 416 424 } 417 425 … … 426 434 UIMediumItem *pMediumItem = currentMediumItem(); 427 435 AssertMsgReturnVoid(pMediumItem, ("Current item must not be null")); 436 AssertReturnVoid(!pMediumItem->id().isNull()); 428 437 429 438 /* Remember ID/type as they may get lost after the closure/deletion: */ … … 561 570 void UIMediumManager::sltHandleCurrentTabChanged() 562 571 { 563 /* Get current -tree: */572 /* Get current tree-widget: */ 564 573 QTreeWidget *pTree = currentTreeWidget(); 565 574 566 /* If other tree was focused previously, moving focus to new tree: */ 575 /* If another tree-widget was focused before, 576 * move focus to current tree-widget: */ 567 577 if (qobject_cast<QTreeWidget*>(focusWidget())) 568 578 pTree->setFocus(); 569 579 570 /* Update current tree-item: */580 /* Make sure current medium-item is selected: */ 571 581 sltHandleCurrentItemChanged(pTree->currentItem()); 572 582 } … … 575 585 QTreeWidgetItem *pPrevItem /* = 0 */) 576 586 { 577 /* Get medium-item: */587 /* Get current medium-item: */ 578 588 UIMediumItem *pMediumItem = toMediumItem(pItem); 579 589 580 /* We have to make sure some item is always selected: */590 /* We have to make sure some medium-item is always selected: */ 581 591 if (!pMediumItem && pPrevItem) 582 592 { 583 /* If the new item is 0, set the old itemagain. */593 /* If new medium-item is 0, choose the old one again. */ 584 594 UIMediumItem *pPrevMediumItem = toMediumItem(pPrevItem); 585 595 setCurrentItem(currentTreeWidget(), pPrevMediumItem); 586 596 } 587 597 598 /* If item is set: */ 588 599 if (pMediumItem) 589 600 { 590 601 /* Set the file for the proxy icon: */ 591 602 setFileForProxyIcon(pMediumItem->location()); 592 /* Ensures current item visible every time we are switching page: */603 /* Make sure current medium-item visible: */ 593 604 pMediumItem->treeWidget()->scrollToItem(pMediumItem, QAbstractItemView::EnsureVisible); 594 605 } … … 603 614 void UIMediumManager::sltHandleDoubleClick() 604 615 { 605 /* Call for modify-action if hard-d iskdouble-clicked: */616 /* Call for modify-action if hard-drive medium-item double-clicked: */ 606 617 if (currentMediumType() == UIMediumType_HardDisk) 607 618 sltModifyMedium(); … … 610 621 void UIMediumManager::sltHandleContextMenuCall(const QPoint &position) 611 622 { 612 /* Get surrentwidget/item: */623 /* Get corresponding widget/item: */ 613 624 QTreeWidget *pTree = currentTreeWidget(); 614 625 QTreeWidgetItem *pItem = pTree->itemAt(position); … … 617 628 /* Make sure the item is selected and current: */ 618 629 setCurrentItem(pTree, pItem); 619 /* Show context menu: */630 /* Show item context menu: */ 620 631 m_pContextMenu->exec(pTree->viewport()->mapToGlobal(position)); 621 632 } … … 870 881 /* Tab-widget created in .ui file. */ 871 882 { 872 /* Setuptab-widget: */883 /* Configure tab-widget: */ 873 884 mTabWidget->setFocusPolicy(Qt::TabFocus); 874 885 mTabWidget->setTabIcon(HDTab, m_iconHD); … … 896 907 /* HD tree-widget created in .ui file. */ 897 908 { 898 /* SetupHD tree-widget: */909 /* Configure HD tree-widget: */ 899 910 mTwHD->setColumnCount(3); 900 911 mTwHD->sortItems(0, Qt::AscendingOrder); … … 921 932 /* CD tree-widget created in .ui file. */ 922 933 { 923 /* SetupCD tree-widget: */934 /* Configure CD tree-widget: */ 924 935 mTwCD->setColumnCount(2); 925 936 mTwCD->sortItems(0, Qt::AscendingOrder); … … 945 956 /* FD tree-widget created in .ui file. */ 946 957 { 947 /* SetupFD tree-widget: */958 /* Configure FD tree-widget: */ 948 959 mTwFD->setColumnCount(2); 949 960 mTwFD->sortItems(0, Qt::AscendingOrder); … … 992 1003 m_pProgressBar = new UIEnumerationProgressBar(this); 993 1004 { 994 /* Hidden by default: */1005 /* Configure progress-bar: */ 995 1006 m_pProgressBar->hide(); 996 /* Integrate to the button-box: */997 1007 mButtonBox->addExtraWidget(m_pProgressBar); 998 1008 } … … 1023 1033 mTwFD->clear(); 1024 1034 1025 /* Populate allmedium-items: */1035 /* Create medium-items: */ 1026 1036 foreach (const QString &strMediumID, vboxGlobal().mediumIDs()) 1027 1037 sltHandleMediumCreated(strMediumID); 1028 1038 1029 /* Select first -item as current medium-itemif nothing selected: */1039 /* Select first medium-item as current one if nothing selected: */ 1030 1040 if (!mediumItem(UIMediumType_HardDisk)) 1031 1041 if (QTreeWidgetItem *pItem = mTwHD->topLevelItem(0)) … … 1041 1051 void UIMediumManager::updateActions() 1042 1052 { 1043 /* Get current -item: */1044 UIMediumItem *p CurrentItem = currentMediumItem();1053 /* Get current medium-item: */ 1054 UIMediumItem *pMediumItem = currentMediumItem(); 1045 1055 1046 1056 /* Calculate actions accessibility: */ 1047 1057 bool fNotInEnumeration = !vboxGlobal().isMediumEnumerationInProgress(); 1048 1058 bool fActionEnabledCopy = currentMediumType() == UIMediumType_HardDisk && 1049 fNotInEnumeration && p CurrentItem && checkMediumFor(pCurrentItem, Action_Copy);1059 fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Copy); 1050 1060 bool fActionEnabledModify = currentMediumType() == UIMediumType_HardDisk && 1051 fNotInEnumeration && p CurrentItem && checkMediumFor(pCurrentItem, Action_Modify);1052 bool fActionEnabledRemove = fNotInEnumeration && p CurrentItem && checkMediumFor(pCurrentItem, Action_Remove);1053 bool fActionEnabledRelease = fNotInEnumeration && p CurrentItem && checkMediumFor(pCurrentItem, Action_Release);1054 1055 /* Update actions: */1061 fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Modify); 1062 bool fActionEnabledRemove = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Remove); 1063 bool fActionEnabledRelease = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Release); 1064 1065 /* Apply actions accessibility: */ 1056 1066 m_pActionCopy->setEnabled(fActionEnabledCopy); 1057 1067 m_pActionModify->setEnabled(fActionEnabledModify); … … 1167 1177 void UIMediumManager::updateInformationPanesHD() 1168 1178 { 1169 /* Get current HDitem: */1179 /* Get current hard-drive medium-item: */ 1170 1180 UIMediumItem *pCurrentItem = mediumItem(UIMediumType_HardDisk); 1171 1181 … … 1669 1679 AssertReturn(!medium.medium().isNull(), 0); 1670 1680 1671 /* Search for medium-item: */1681 /* Search for existing medium-item: */ 1672 1682 UIMediumItem *pMediumItem = searchItem(pTree, CheckIfSuitableByID(medium.id())); 1673 1683 … … 1683 1693 if (!pParentMediumItem) 1684 1694 { 1685 /* Make sure suchcorresponding parent medium is already cached! */1695 /* Make sure corresponding parent medium is already cached! */ 1686 1696 UIMedium parentMedium = vboxGlobal().medium(medium.parentID()); 1687 1697 if (parentMedium.isNull()) … … 1706 1716 } 1707 1717 1708 /* Return medium-item: */1718 /* Return created medium-item: */ 1709 1719 return pMediumItem; 1710 1720 }
Note:
See TracChangeset
for help on using the changeset viewer.