Changeset 63833 in vbox
- Timestamp:
- Sep 14, 2016 1:11:01 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r63832 r63833 583 583 void UISnapshotPane::sltCurrentItemChanged(QTreeWidgetItem *pItem) 584 584 { 585 /* Acquire corresponding snapshot item: */ 586 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem); 587 585 588 /* Make the selected item visible: */ 586 const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0;587 589 if (pSnapshotItem) 588 590 { … … 644 646 void UISnapshotPane::sltContextMenuRequested(const QPoint &point) 645 647 { 646 /* Search for corresponding snapshotitem: */648 /* Search for corresponding item: */ 647 649 const QTreeWidgetItem *pItem = m_pTreeWidget->itemAt(point); 648 const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0; 649 if (!pSnapshotItem) 650 if (!pItem) 650 651 return; 652 653 /* Acquire corresponding snapshot item: */ 654 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem); 655 AssertReturnVoid(pSnapshotItem); 651 656 652 657 /* Prepare menu: */ … … 679 684 return; 680 685 681 /* Make sure snapshot item was changed: */ 682 const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0; 683 if (!pSnapshotItem) 684 return; 686 /* Acquire corresponding snapshot item: */ 687 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem); 688 AssertReturnVoid(pSnapshotItem); 685 689 686 690 /* Rename corresponding snapshot: */ … … 696 700 return; 697 701 698 /* Make sure snapshot item was double-clicked: */ 699 const SnapshotWgtItem *pSnapshotItem = pItem ? static_cast<const SnapshotWgtItem*>(pItem) : 0; 700 if (!pSnapshotItem) 701 return; 702 /* Acquire corresponding snapshot item: */ 703 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem); 704 AssertReturnVoid(pSnapshotItem); 702 705 703 706 /* Handle Ctrl+DoubleClick: */ … … 711 714 void UISnapshotPane::sltRestoreSnapshot(bool fSuppressNonCriticalWarnings /* = false */) 712 715 { 713 /* Get currently chosenitem: */714 const SnapshotWgtItem *pSnapshotItem = m_pTreeWidget->currentItem() ? static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()) : 0;716 /* Acquire currently chosen snapshot item: */ 717 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem()); 715 718 AssertReturnVoid(pSnapshotItem); 716 719 … … 760 763 void UISnapshotPane::sltDeleteSnapshot() 761 764 { 762 /* Get currently chosen item: */ 763 const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 : 764 static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()); 765 /* Acquire currently chosen snapshot item: */ 766 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem()); 765 767 AssertReturnVoid(pSnapshotItem); 766 768 … … 810 812 void UISnapshotPane::sltShowSnapshotDetails() 811 813 { 812 /* Get currently chosen item: */ 813 const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 : 814 static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()); 814 /* Acquire currently chosen snapshot item: */ 815 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem()); 815 816 AssertReturnVoid(pSnapshotItem); 816 817 … … 830 831 void UISnapshotPane::sltCloneSnapshot() 831 832 { 832 /* Get currently chosen item: */ 833 const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 : 834 static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()); 833 /* Acquire currently chosen snapshot item: */ 834 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem()); 835 835 AssertReturnVoid(pSnapshotItem); 836 836 … … 1014 1014 /* Remember the selected item and it's first child: */ 1015 1015 QString strSelectedItem, strFirstChildOfSelectedItem; 1016 const SnapshotWgtItem *pSnapshotItem = !m_pTreeWidget->currentItem() ? 0 : 1017 static_cast<const SnapshotWgtItem*>(m_pTreeWidget->currentItem()); 1016 const SnapshotWgtItem *pSnapshotItem = toSnapshotItem(m_pTreeWidget->currentItem()); 1018 1017 if (pSnapshotItem) 1019 1018 { 1020 1019 strSelectedItem = pSnapshotItem->snapshotID(); 1021 1020 if (pSnapshotItem->child(0)) 1022 strFirstChildOfSelectedItem = static_cast<const SnapshotWgtItem*>(pSnapshotItem->child(0))->snapshotID();1021 strFirstChildOfSelectedItem = toSnapshotItem(pSnapshotItem->child(0))->snapshotID(); 1023 1022 } 1024 1023 … … 1083 1082 while (*it) 1084 1083 { 1085 SnapshotWgtItem *pSnapshotItem = static_cast<SnapshotWgtItem*>(*it);1084 SnapshotWgtItem *pSnapshotItem = toSnapshotItem(*it); 1086 1085 if (pSnapshotItem->snapshotID() == strSnapshotID) 1087 1086 return pSnapshotItem; … … 1130 1129 SnapshotAgeFormat UISnapshotPane::traverseSnapshotAge(QTreeWidgetItem *pItem) const 1131 1130 { 1132 /* Make sure passed root is of valid type: */ 1133 SnapshotWgtItem *pSnapshotItem = pItem->type() == SnapshotWgtItem::ItemType ? 1134 static_cast<SnapshotWgtItem*>(pItem) : 0; 1131 /* Acquire corresponding snapshot item: */ 1132 SnapshotWgtItem *pSnapshotItem = toSnapshotItem(pItem); 1135 1133 1136 1134 /* Fetch the snapshot age of the root if it's valid: */ … … 1150 1148 } 1151 1149 1150 /* static */ 1151 SnapshotWgtItem *UISnapshotPane::toSnapshotItem(QTreeWidgetItem *pItem) 1152 { 1153 /* Make sure alive SnapshotWgtItem passed: */ 1154 if (!pItem || pItem->type() != SnapshotWgtItem::ItemType) 1155 return 0; 1156 1157 /* Return casted SnapshotWgtItem then: */ 1158 return static_cast<SnapshotWgtItem*>(pItem); 1159 } 1160 1161 /* static */ 1162 const SnapshotWgtItem *UISnapshotPane::toSnapshotItem(const QTreeWidgetItem *pItem) 1163 { 1164 /* Make sure alive SnapshotWgtItem passed: */ 1165 if (!pItem || pItem->type() != SnapshotWgtItem::ItemType) 1166 return 0; 1167 1168 /* Return casted SnapshotWgtItem then: */ 1169 return static_cast<const SnapshotWgtItem*>(pItem); 1170 } 1171 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r63832 r63833 141 141 SnapshotAgeFormat traverseSnapshotAge(QTreeWidgetItem *pItem) const; 142 142 143 /** Casts QTreeWidgetItem to SnapshotWgtItem if possible. */ 144 static SnapshotWgtItem *toSnapshotItem(QTreeWidgetItem *pItem); 145 /** Casts const QTreeWidgetItem to const SnapshotWgtItem if possible. */ 146 static const SnapshotWgtItem *toSnapshotItem(const QTreeWidgetItem *pItem); 147 143 148 /** Holds the machine COM wrapper. */ 144 149 CMachine m_comMachine;
Note:
See TracChangeset
for help on using the changeset viewer.