- Timestamp:
- Oct 31, 2016 3:32:19 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 111631
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r64494 r64495 28 28 # include <QPointer> 29 29 # include <QScrollBar> 30 # include <QTreeWidget>31 30 # include <QWriteLocker> 32 31 33 32 /* GUI includes: */ 33 # include "QITreeWidget.h" 34 34 # include "UIConverter.h" 35 35 # include "UIExtraDataManager.h" … … 55 55 56 56 57 /** Q TreeWidgetItem subclass for snapshots items. */58 class UISnapshotItem : public Q Object, public QTreeWidgetItem57 /** QITreeWidgetItem subclass for snapshots items. */ 58 class UISnapshotItem : public QITreeWidgetItem 59 59 { 60 60 Q_OBJECT; … … 67 67 static const UISnapshotItem *toSnapshotItem(const QTreeWidgetItem *pItem); 68 68 69 /** Item type for UISnapshotItem. */70 enum { ItemType = QTreeWidgetItem::UserType + 1 };71 72 69 /** Constructs normal snapshot item (child of tree-widget). */ 73 UISnapshotItem(UISnapshotPane *pSnapshotWidget, Q TreeWidget *pTreeWidget, const CSnapshot &comSnapshot);70 UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidget *pTreeWidget, const CSnapshot &comSnapshot); 74 71 /** Constructs normal snapshot item (child of tree-widget-item). */ 75 UISnapshotItem(UISnapshotPane *pSnapshotWidget, Q TreeWidgetItem *pRootItem, const CSnapshot &comSnapshot);72 UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidgetItem *pRootItem, const CSnapshot &comSnapshot); 76 73 77 74 /** Constructs "current state" item (child of tree-widget). */ 78 UISnapshotItem(UISnapshotPane *pSnapshotWidget, Q TreeWidget *pTreeWidget, const CMachine &comMachine);75 UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidget *pTreeWidget, const CMachine &comMachine); 79 76 /** Constructs "current state" item (child of tree-widget-item). */ 80 UISnapshotItem(UISnapshotPane *pSnapshotWidget, Q TreeWidgetItem *pRootItem, const CMachine &comMachine);77 UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidgetItem *pRootItem, const CMachine &comMachine); 81 78 82 79 /** Returns item machine. */ … … 87 84 QString snapshotID() const { return m_strSnapshotID; } 88 85 89 /** Returns the parent snapshot tree. */90 UISnapshotTree *parentSnapshotTree() const;91 /** Returns the parent snapshot item. */92 UISnapshotItem *parentSnapshotItem() const;93 /** Returns the child snapshot item with @a iIndex. */94 UISnapshotItem *childSnapshotItem(int iIndex) const;95 96 86 /** Returns item data for corresponding @a iColumn and @a iRole. */ 97 87 QVariant data(int iColumn, int iRole) const; … … 166 156 167 157 168 /** Q TreeWidget subclass for snapshots items. */169 class UISnapshotTree : public Q TreeWidget158 /** QITreeWidget subclass for snapshots items. */ 159 class UISnapshotTree : public QITreeWidget 170 160 { 171 161 Q_OBJECT; … … 175 165 /** Constructs snapshot tree passing @a pParent to the base-class. */ 176 166 UISnapshotTree(QWidget *pParent); 177 178 /** Returns the number of children. */179 int childCount() const;180 /** Returns the child snapshot item with @a iIndex. */181 UISnapshotItem *childSnapshotItem(int iIndex) const;182 167 }; 183 168 … … 190 175 UISnapshotItem *UISnapshotItem::toSnapshotItem(QTreeWidgetItem *pItem) 191 176 { 192 /* Make sure alive UISnapshotItem passed: */ 193 if (!pItem || pItem->type() != UISnapshotItem::ItemType) 177 /* Get QITreeWidgetItem item first: */ 178 QITreeWidgetItem *pIItem = QITreeWidgetItem::toItem(pItem); 179 if (!pIItem) 194 180 return 0; 195 181 196 182 /* Return casted UISnapshotItem then: */ 197 return static_cast<UISnapshotItem*>(pItem);183 return qobject_cast<UISnapshotItem*>(pIItem); 198 184 } 199 185 … … 201 187 const UISnapshotItem *UISnapshotItem::toSnapshotItem(const QTreeWidgetItem *pItem) 202 188 { 203 /* Make sure alive UISnapshotItem passed: */ 204 if (!pItem || pItem->type() != UISnapshotItem::ItemType) 189 /* Get QITreeWidgetItem item first: */ 190 const QITreeWidgetItem *pIItem = QITreeWidgetItem::toItem(pItem); 191 if (!pIItem) 205 192 return 0; 206 193 207 194 /* Return casted UISnapshotItem then: */ 208 return static_cast<const UISnapshotItem*>(pItem);209 } 210 211 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, Q TreeWidget *pTreeWidget, const CSnapshot &comSnapshot)212 : Q TreeWidgetItem(pTreeWidget, ItemType)195 return qobject_cast<const UISnapshotItem*>(pIItem); 196 } 197 198 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidget *pTreeWidget, const CSnapshot &comSnapshot) 199 : QITreeWidgetItem(pTreeWidget) 213 200 , m_pSnapshotWidget(pSnapshotWidget) 214 201 , m_fCurrentState(false) … … 217 204 } 218 205 219 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, Q TreeWidgetItem *pRootItem, const CSnapshot &comSnapshot)220 : Q TreeWidgetItem(pRootItem, ItemType)206 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidgetItem *pRootItem, const CSnapshot &comSnapshot) 207 : QITreeWidgetItem(pRootItem) 221 208 , m_pSnapshotWidget(pSnapshotWidget) 222 209 , m_fCurrentState(false) … … 225 212 } 226 213 227 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, Q TreeWidget *pTreeWidget, const CMachine &comMachine)228 : Q TreeWidgetItem(pTreeWidget, ItemType)214 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidget *pTreeWidget, const CMachine &comMachine) 215 : QITreeWidgetItem(pTreeWidget) 229 216 , m_pSnapshotWidget(pSnapshotWidget) 230 217 , m_fCurrentState(true) … … 235 222 } 236 223 237 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, Q TreeWidgetItem *pRootItem, const CMachine &comMachine)238 : Q TreeWidgetItem(pRootItem, ItemType)224 UISnapshotItem::UISnapshotItem(UISnapshotPane *pSnapshotWidget, QITreeWidgetItem *pRootItem, const CMachine &comMachine) 225 : QITreeWidgetItem(pRootItem) 239 226 , m_pSnapshotWidget(pSnapshotWidget) 240 227 , m_fCurrentState(true) … … 243 230 /* Fetch current machine state: */ 244 231 updateCurrentState(m_comMachine.GetState()); 245 }246 247 UISnapshotTree *UISnapshotItem::parentSnapshotTree() const248 {249 /* Return the parent snapshot tree if any: */250 return treeWidget() ? qobject_cast<UISnapshotTree*>(treeWidget()) : 0;251 }252 253 UISnapshotItem *UISnapshotItem::parentSnapshotItem() const254 {255 /* Return the parent snapshot item if any: */256 return QTreeWidgetItem::parent() ? toSnapshotItem(QTreeWidgetItem::parent()) : 0;257 }258 259 UISnapshotItem *UISnapshotItem::childSnapshotItem(int iIndex) const260 {261 /* Return the child snapshot item with iIndex if any: */262 return QTreeWidgetItem::child(iIndex) ? toSnapshotItem(QTreeWidgetItem::child(iIndex)) : 0;263 232 } 264 233 … … 531 500 532 501 UISnapshotTree::UISnapshotTree(QWidget *pParent) 533 : Q TreeWidget(pParent)502 : QITreeWidget(pParent) 534 503 { 535 504 /* No header: */ … … 555 524 // #endif 556 525 #endif /* QT_VERSION < 0x050000 */ 557 }558 559 int UISnapshotTree::childCount() const560 {561 /* Return the number of children: */562 return invisibleRootItem()->childCount();563 }564 565 UISnapshotItem *UISnapshotTree::childSnapshotItem(int iIndex) const566 {567 /* Return the child snapshot item with iIndex if any: */568 return invisibleRootItem()->child(iIndex) ? UISnapshotItem::toSnapshotItem(invisibleRootItem()->child(iIndex)) : 0;569 526 } 570 527 … … 709 666 { 710 667 /* Translate snapshot tree: */ 711 m_pSnapshotTree->set ToolTip(tr("Contains snapshot tree of current virtual machine"));668 m_pSnapshotTree->setWhatsThis(tr("Contains snapshot tree of current virtual machine")); 712 669 713 670 /* Translate actions names: */ … … 1281 1238 } 1282 1239 1283 void UISnapshotPane::populateSnapshots(const CSnapshot &comSnapshot, Q TreeWidgetItem *pItem)1240 void UISnapshotPane::populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem) 1284 1241 { 1285 1242 /* Create a child of passed item: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.h
r64494 r64495 35 35 class UISnapshotItem; 36 36 class QTreeWidgetItem; 37 class QITreeWidgetItem; 37 38 38 39 … … 132 133 void refreshAll(); 133 134 /** Populates snapshot items for corresponding @a comSnapshot using @a pItem as parent. */ 134 void populateSnapshots(const CSnapshot &comSnapshot, Q TreeWidgetItem *pItem);135 void populateSnapshots(const CSnapshot &comSnapshot, QITreeWidgetItem *pItem); 135 136 136 137 /** Searches for an item with corresponding @a strSnapshotID. */
Note:
See TracChangeset
for help on using the changeset viewer.