Changeset 83929 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 22, 2020 2:44:48 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r83924 r83929 328 328 int iCountOfStartedMachineItems = 0; 329 329 foreach (UIChooserItem *pItem, items(UIChooserNodeType_Machine)) 330 if (pItem->node()->toMachineNode()->cache()->isItemStarted()) 330 { 331 AssertPtrReturnVoid(pItem); 332 UIChooserItemMachine *pMachineItem = pItem->toMachineItem(); 333 AssertPtrReturnVoid(pMachineItem); 334 AssertPtrReturnVoid(pMachineItem->cache()); 335 if (pMachineItem->cache()->isItemStarted()) 331 336 ++iCountOfStartedMachineItems; 337 } 332 338 /* Template: */ 333 339 QString strMachineCount = tr("%n machine(s)", "Group item tool-tip / Machine info", items(UIChooserNodeType_Machine).size()); … … 731 737 /* For local items: */ 732 738 if ( nodeToGroupType()->groupType() == UIChooserNodeGroupType_Local 733 && pMachineItem-> nodeToMachineType()->cacheType() == UIVirtualMachineItemType_Local)739 && pMachineItem->cacheType() == UIVirtualMachineItemType_Local) 734 740 { 735 741 /* Make sure passed machine isn't immutable within own group: */ … … 756 762 else 757 763 if ( nodeToGroupType()->groupType() == UIChooserNodeGroupType_Profile 758 && pMachineItem-> nodeToMachineType()->cacheType() == UIVirtualMachineItemType_CloudReal)764 && pMachineItem->cacheType() == UIVirtualMachineItemType_CloudReal) 759 765 { 760 766 /* Make sure passed item is ours: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.cpp
r83924 r83929 64 64 } 65 65 66 UIVirtualMachineItem *UIChooserItemMachine::cache() const 67 { 68 return nodeToMachineType() ? nodeToMachineType()->cache() : 0; 69 } 70 71 UIVirtualMachineItemType UIChooserItemMachine::cacheType() const 72 { 73 return cache() ? cache()->itemType() : UIVirtualMachineItemType_Invalid; 74 } 75 66 76 QUuid UIChooserItemMachine::id() const 67 77 { 68 return nodeToMachineType()->cache()->id();78 return cache() ? cache()->id() : QUuid(); 69 79 } 70 80 71 81 bool UIChooserItemMachine::accessible() const 72 82 { 73 return nodeToMachineType()->cache()->accessible();83 return cache() ? cache()->accessible() : false; 74 84 } 75 85 76 86 void UIChooserItemMachine::recache() 77 87 { 78 nodeToMachineType()->cache()->recache(); 88 if (cache()) 89 cache()->recache(); 79 90 } 80 91 81 92 bool UIChooserItemMachine::isLockedMachine() const 82 93 { 83 const KMachineState enmState = nodeToMachineType()->cache()->machineState(); 94 const KMachineState enmState = cacheType() == UIVirtualMachineItemType_Local 95 ? cache()->machineState() 96 : KMachineState_Null; 84 97 return enmState != KMachineState_PoweredOff && 85 98 enmState != KMachineState_Saved && … … 159 172 160 173 /* Recache and update pixmaps: */ 161 nodeToMachineType()->cache()->recachePixmap(); 174 AssertPtrReturnVoid(cache()); 175 cache()->recachePixmap(); 162 176 updatePixmaps(); 163 177 } … … 225 239 void UIChooserItemMachine::updateToolTip() 226 240 { 227 setToolTip(nodeToMachineType()->cache()->toolTipText()); 241 AssertPtrReturnVoid(cache()); 242 setToolTip(cache()->toolTipText()); 228 243 } 229 244 … … 302 317 /* And machine-item content to take into account: */ 303 318 int iTopLineWidth = m_iMinimumNameWidth; 304 if ( nodeToMachineType()->cacheType() == UIVirtualMachineItemType_Local 305 && !nodeToMachineType()->cache()->toLocal()->snapshotName().isEmpty()) 319 /* Only local items can have snapshots: */ 320 if ( cacheType() == UIVirtualMachineItemType_Local 321 && !cache()->toLocal()->snapshotName().isEmpty()) 306 322 iTopLineWidth += (iMinorSpacing + 307 323 m_iMinimumSnapshotNameWidth); … … 400 416 401 417 /* No drops for cloud items: */ 402 if ( nodeToMachineType()->cacheType() != UIVirtualMachineItemType_Local403 || pMachineItem-> nodeToMachineType()->cacheType() != UIVirtualMachineItemType_Local)418 if ( cacheType() != UIVirtualMachineItemType_Local 419 || pMachineItem->cacheType() != UIVirtualMachineItemType_Local) 404 420 return false; 405 421 /* No drops for immutable item: */ … … 498 514 { 499 515 /* Recache and update pixmaps: */ 500 nodeToMachineType()->cache()->recachePixmap(); 516 AssertPtrReturnVoid(cache()); 517 cache()->recachePixmap(); 501 518 updatePixmaps(); 502 519 } … … 614 631 { 615 632 /* Get new pixmap and pixmap-size: */ 633 AssertPtrReturnVoid(cache()); 616 634 QSize pixmapSize; 617 QPixmap pixmap = nodeToMachineType()->cache()->osPixmap(&pixmapSize);635 QPixmap pixmap = cache()->osPixmap(&pixmapSize); 618 636 /* Update linked values: */ 619 637 if (m_pixmapSize != pixmapSize) … … 635 653 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize); 636 654 /* Get new state-pixmap and state-pixmap size: */ 637 const QIcon stateIcon = nodeToMachineType()->cache()->machineStateIcon(); 655 AssertPtrReturnVoid(cache()); 656 const QIcon stateIcon = cache()->machineStateIcon(); 638 657 AssertReturnVoid(!stateIcon.isNull()); 639 658 const QSize statePixmapSize = QSize(iIconMetric, iIconMetric); … … 726 745 int iMinimumSnapshotNameWidth = 0; 727 746 /* Is there any snapshot exists? */ 728 if ( nodeToMachineType()->cacheType() == UIVirtualMachineItemType_Local729 && ! nodeToMachineType()->cache()->toLocal()->snapshotName().isEmpty())747 if ( cacheType() == UIVirtualMachineItemType_Local 748 && !cache()->toLocal()->snapshotName().isEmpty()) 730 749 { 731 750 QFontMetrics fm(m_snapshotNameFont, model()->paintDevice()); 732 751 int iBracketWidth = fm.width("()"); /* bracket width */ 733 int iActualTextWidth = fm.width( nodeToMachineType()->cache()->toLocal()->snapshotName()); /* snapshot-name width */752 int iActualTextWidth = fm.width(cache()->toLocal()->snapshotName()); /* snapshot-name width */ 734 753 int iMinimumTextWidth = fm.width("..."); /* ellipsis width */ 735 754 iMinimumSnapshotNameWidth = iBracketWidth + qMin(iActualTextWidth, iMinimumTextWidth); … … 812 831 { 813 832 /* Make sure this is local machine item: */ 814 if ( nodeToMachineType()->cacheType() != UIVirtualMachineItemType_Local)833 if (cacheType() != UIVirtualMachineItemType_Local) 815 834 return; 816 835 … … 820 839 /* Calculate new visible snapshot-name: */ 821 840 int iBracketWidth = QFontMetrics(m_snapshotNameFont, pPaintDevice).width("()"); 822 QString strVisibleSnapshotName = compressText(m_snapshotNameFont, pPaintDevice, nodeToMachineType()->cache()->toLocal()->snapshotName(),841 QString strVisibleSnapshotName = compressText(m_snapshotNameFont, pPaintDevice, cache()->toLocal()->snapshotName(), 823 842 m_iMaximumSnapshotNameWidth - iBracketWidth); 824 843 strVisibleSnapshotName = QString("(%1)").arg(strVisibleSnapshotName); … … 841 860 { 842 861 /* Get new state-text and state-text size: */ 843 const QSize stateTextSize = textSize(m_stateTextFont, model()->paintDevice(), nodeToMachineType()->cache()->machineStateName()); 862 AssertPtrReturnVoid(cache()); 863 const QSize stateTextSize = textSize(m_stateTextFont, model()->paintDevice(), cache()->machineStateName()); 844 864 845 865 /* Update linked values: */ … … 1118 1138 1119 1139 /* Paint middle element: */ 1120 if ( nodeToMachineType()->cacheType() == UIVirtualMachineItemType_Local1121 && ! nodeToMachineType()->cache()->toLocal()->snapshotName().isEmpty())1140 if ( cacheType() == UIVirtualMachineItemType_Local 1141 && !cache()->toLocal()->snapshotName().isEmpty()) 1122 1142 { 1123 1143 /* Prepare variables: */ … … 1168 1188 int iMachineStateTextY = iBottomLineIndent + 1; 1169 1189 /* Paint state text: */ 1190 AssertPtrReturnVoid(cache()); 1170 1191 paintText(/* Painter: */ 1171 1192 pPainter, … … 1177 1198 model()->paintDevice(), 1178 1199 /* Text to paint: */ 1179 nodeToMachineType()->cache()->machineStateName());1200 cache()->machineStateName()); 1180 1201 } 1181 1202 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemMachine.h
r83924 r83929 24 24 /* GUI includes: */ 25 25 #include "UIChooserItem.h" 26 #include "UIManagerDefs.h" 26 27 27 28 /* Forward declarations: */ 28 29 class UIChooserNodeMachine; 30 class UIVirtualMachineItem; 29 31 30 32 … … 48 50 /** Returns machine node reference. */ 49 51 UIChooserNodeMachine *nodeToMachineType() const; 52 53 /** Returns virtual machine cache instance. */ 54 UIVirtualMachineItem *cache() const; 55 /** Returns virtual machine cache type. */ 56 UIVirtualMachineItemType cacheType() const; 50 57 51 58 /** Returns item machine id. */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r83925 r83929 296 296 return firstSelectedItem() 297 297 && firstSelectedItem()->firstMachineItem() 298 && firstSelectedItem()->firstMachineItem()->node() 299 && firstSelectedItem()->firstMachineItem()->node()->toMachineNode() 300 ? firstSelectedItem()->firstMachineItem()->node()->toMachineNode()->cache() 298 && firstSelectedItem()->firstMachineItem()->toMachineItem() 299 ? firstSelectedItem()->firstMachineItem()->toMachineItem()->cache() 301 300 : 0; 302 301 } … … 312 311 QList<UIVirtualMachineItem*> currentMachineList; 313 312 foreach (UIChooserItemMachine *pItem, currentMachineItemList) 314 currentMachineList << pItem-> nodeToMachineType()->cache();313 currentMachineList << pItem->cache(); 315 314 return currentMachineList; 316 315 } … … 1056 1055 foreach (UIChooserItemMachine *pItem, inaccessibleMachineItemList) 1057 1056 { 1058 switch (pItem-> nodeToMachineType()->cacheType())1057 switch (pItem->cacheType()) 1059 1058 { 1060 1059 case UIVirtualMachineItemType_Local: … … 1082 1081 { 1083 1082 /* Much more simple than for local items, we are not reloading them, just refreshing: */ 1084 pItem-> nodeToMachineType()->cache()->toCloud()->updateInfoAsync(false /* delayed */);1083 pItem->cache()->toCloud()->updateInfoAsync(false /* delayed */); 1085 1084 1086 1085 break; … … 1150 1149 if (fVerdict) 1151 1150 { 1152 if (pMachineItem-> nodeToMachineType()->cacheType() == UIVirtualMachineItemType_Local)1153 localMachinesToUnregister.append(pMachineItem-> nodeToMachineType()->cache()->toLocal()->machine());1154 else if (pMachineItem-> nodeToMachineType()->cacheType() == UIVirtualMachineItemType_CloudReal)1155 cloudMachinesToUnregister.append(pMachineItem-> nodeToMachineType()->cache()->toCloud()->machine());1151 if (pMachineItem->cacheType() == UIVirtualMachineItemType_Local) 1152 localMachinesToUnregister.append(pMachineItem->cache()->toLocal()->machine()); 1153 else if (pMachineItem->cacheType() == UIVirtualMachineItemType_CloudReal) 1154 cloudMachinesToUnregister.append(pMachineItem->cache()->toCloud()->machine()); 1156 1155 } 1157 1156 else
Note:
See TracChangeset
for help on using the changeset viewer.