- Timestamp:
- Oct 3, 2016 3:38:04 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/extensions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.cpp
r64125 r64126 30 30 31 31 32 /********************************************************************************************************************************* 33 * Class QITreeWidgetItem implementation. * 34 *********************************************************************************************************************************/ 35 36 /* static */ 37 QITreeWidgetItem *QITreeWidgetItem::toItem(QTreeWidgetItem *pItem) 38 { 39 /* Make sure alive QITreeWidgetItem passed: */ 40 if (!pItem || pItem->type() != QITreeWidgetItem::ItemType) 41 return 0; 42 43 /* Return casted QITreeWidgetItem: */ 44 return static_cast<QITreeWidgetItem*>(pItem); 45 } 46 47 /* static */ 48 const QITreeWidgetItem *QITreeWidgetItem::toItem(const QTreeWidgetItem *pItem) 49 { 50 /* Make sure alive QITreeWidgetItem passed: */ 51 if (!pItem || pItem->type() != QITreeWidgetItem::ItemType) 52 return 0; 53 54 /* Return casted QITreeWidgetItem: */ 55 return static_cast<const QITreeWidgetItem*>(pItem); 56 } 57 58 QITreeWidgetItem::QITreeWidgetItem(QITreeWidget *pTreeWidget) 59 : QTreeWidgetItem(pTreeWidget, ItemType) 60 { 61 } 62 63 QITreeWidgetItem::QITreeWidgetItem(QITreeWidgetItem *pTreeWidgetItem) 64 : QTreeWidgetItem(pTreeWidgetItem, ItemType) 65 { 66 } 67 68 QITreeWidgetItem::QITreeWidgetItem(QITreeWidget *pTreeWidget, const QStringList &strings) 69 : QTreeWidgetItem(pTreeWidget, strings, ItemType) 70 { 71 } 72 73 QITreeWidgetItem::QITreeWidgetItem(QITreeWidgetItem *pTreeWidgetItem, const QStringList &strings) 74 : QTreeWidgetItem(pTreeWidgetItem, strings, ItemType) 75 { 76 } 77 78 QITreeWidget *QITreeWidgetItem::parentTree() const 79 { 80 /* Return the parent tree if any: */ 81 return treeWidget() ? qobject_cast<QITreeWidget*>(treeWidget()) : 0; 82 } 83 84 QITreeWidgetItem *QITreeWidgetItem::parentItem() const 85 { 86 /* Return the parent item if any: */ 87 return QTreeWidgetItem::parent() ? toItem(QTreeWidgetItem::parent()) : 0; 88 } 89 90 QITreeWidgetItem *QITreeWidgetItem::childItem(int iIndex) const 91 { 92 /* Return the child item with iIndex if any: */ 93 return QTreeWidgetItem::child(iIndex) ? toItem(QTreeWidgetItem::child(iIndex)) : 0; 94 } 95 96 97 /********************************************************************************************************************************* 98 * Class QITreeWidget implementation. * 99 *********************************************************************************************************************************/ 100 32 101 QITreeWidget::QITreeWidget(QWidget *pParent) 33 102 : QTreeWidget(pParent) … … 48 117 } 49 118 50 Q TreeWidgetItem *QITreeWidget::childItem(int iIndex) const119 QITreeWidgetItem *QITreeWidget::childItem(int iIndex) const 51 120 { 52 121 /* Return the child item with iIndex if any: */ 53 return invisibleRootItem()->child(iIndex) ;122 return invisibleRootItem()->child(iIndex) ? QITreeWidgetItem::toItem(invisibleRootItem()->child(iIndex)) : 0; 54 123 } 55 124 -
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QITreeWidget.h
r64125 r64126 21 21 /* Qt includes: */ 22 22 #include <QTreeWidget> 23 #include <QTreeWidgetItem> 24 25 /* Forward declarations: */ 26 class QITreeWidget; 27 28 29 /** QTreeWidgetItem subclass extending standard functionality. */ 30 class QITreeWidgetItem : public QObject, public QTreeWidgetItem 31 { 32 Q_OBJECT; 33 34 public: 35 36 /** Item type for QITreeWidgetItem. */ 37 enum { ItemType = QTreeWidgetItem::UserType + 1 }; 38 39 /** Casts QTreeWidgetItem* to QITreeWidgetItem* if possible. */ 40 static QITreeWidgetItem *toItem(QTreeWidgetItem *pItem); 41 /** Casts const QTreeWidgetItem* to const QITreeWidgetItem* if possible. */ 42 static const QITreeWidgetItem *toItem(const QTreeWidgetItem *pItem); 43 44 /** Constructs item passing @a pTreeWidget into the base-class. */ 45 QITreeWidgetItem(QITreeWidget *pTreeWidget); 46 /** Constructs item passing @a pTreeWidgetItem into the base-class. */ 47 QITreeWidgetItem(QITreeWidgetItem *pTreeWidgetItem); 48 49 /** Constructs item passing @a pTreeWidget and @a strings into the base-class. */ 50 QITreeWidgetItem(QITreeWidget *pTreeWidget, const QStringList &strings); 51 /** Constructs item passing @a pTreeWidgetItem and @a strings into the base-class. */ 52 QITreeWidgetItem(QITreeWidgetItem *pTreeWidgetItem, const QStringList &strings); 53 54 /** Returns the parent tree-widget. */ 55 QITreeWidget *parentTree() const; 56 /** Returns the parent tree-widget item. */ 57 QITreeWidgetItem *parentItem() const; 58 /** Returns the child tree-widget item with @a iIndex. */ 59 QITreeWidgetItem *childItem(int iIndex) const; 60 }; 23 61 24 62 … … 46 84 int childCount() const; 47 85 /** Returns the child item with @a iIndex. */ 48 Q TreeWidgetItem *childItem(int iIndex) const;86 QITreeWidgetItem *childItem(int iIndex) const; 49 87 50 88 protected:
Note:
See TracChangeset
for help on using the changeset viewer.