Changeset 9872 in vbox for trunk/src/VBox/Frontends/VirtualBox4
- Timestamp:
- Jun 23, 2008 1:26:35 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/include/QITreeWidget.h
r9867 r9872 24 24 #define __QITreeWidget_h__ 25 25 26 /* Qt includes */27 26 #include <QTreeWidget> 28 27 28 /* 29 * QTreeWidget class which extends standard QTreeWidget's functionality. 30 */ 29 31 class QITreeWidget: public QTreeWidget 30 32 { … … 32 34 33 35 public: 36 37 /* 38 * There are two allowed QTreeWidgetItem types which may be used with 39 * QITreeWidget: basic and complex. 40 * Complex type used in every place where the particular item have to 41 * be separately repainted with it's own content. 42 * Basic are used in all other places. 43 */ 44 enum 45 { 46 BasicItemType = QTreeWidgetItem::UserType + 1, 47 ComplexItemType = QTreeWidgetItem::UserType + 2 48 }; 34 49 35 50 QITreeWidget (QWidget *aParent = 0); … … 41 56 virtual Qt::DropActions supportedDropActions () const; 42 57 58 void paintEvent (QPaintEvent *); 59 43 60 /* Protected member vars */ 44 61 Qt::DropActions mSupportedDropActions; 45 62 }; 46 63 64 /* 65 * Interface for more complex items which requires special repainting 66 * routine inside QITreeWidget's viewport. 67 */ 68 class ComplexTreeWidgetItem : public QTreeWidgetItem 69 { 70 public: 71 72 ComplexTreeWidgetItem (QTreeWidget *aParent) 73 : QTreeWidgetItem (aParent, QITreeWidget::ComplexItemType) {} 74 75 virtual void paintItem (QPainter *aPainter) = 0; 76 }; 77 47 78 #endif /* __QITreeWidget_h__ */ 48 79 -
trunk/src/VBox/Frontends/VirtualBox4/src/QITreeWidget.cpp
r9867 r9872 23 23 #include "QITreeWidget.h" 24 24 25 /* Qt includes */ 26 #include <QMouseEvent> 25 #include <QPainter> 27 26 28 27 QITreeWidget::QITreeWidget (QWidget *aParent) … … 41 40 } 42 41 42 void QITreeWidget::paintEvent (QPaintEvent *aEvent) 43 { 44 /* Painter for items */ 45 QPainter painter (viewport()); 46 47 /* Here we let the items make some painting inside the viewport. */ 48 QTreeWidgetItemIterator it (this); 49 while (*it) 50 { 51 switch ((*it)->type()) 52 { 53 case ComplexItemType: 54 { 55 /* Let the ComplexItem paint itself */ 56 ComplexTreeWidgetItem *i = static_cast<ComplexTreeWidgetItem*> (*it); 57 i->paintItem (&painter); 58 break; 59 } 60 case BasicItemType: 61 { 62 /* Do nothing for BasicItem */ 63 break; 64 } 65 default: 66 { 67 /* Wrong item is used */ 68 break; 69 } 70 } 71 ++ it; 72 } 73 74 QTreeWidget::paintEvent (aEvent); 75 } 76 -
trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDiskImageManagerDlg.cpp
r9867 r9872 57 57 public: 58 58 59 enum { TypeId = QTreeWidgetItem::UserType + 1 };60 61 59 DiskImageItem (DiskImageItem *aParent) : 62 QTreeWidgetItem (aParent, TypeId), mStatus (VBoxMedia::Unknown) {}60 QTreeWidgetItem (aParent, QITreeWidget::BasicItemType), mStatus (VBoxMedia::Unknown) {} 63 61 64 62 DiskImageItem (QTreeWidget *aParent) : 65 QTreeWidgetItem (aParent, TypeId), mStatus (VBoxMedia::Unknown) {}63 QTreeWidgetItem (aParent, QITreeWidget::BasicItemType), mStatus (VBoxMedia::Unknown) {} 66 64 67 65 void setMedia (const VBoxMedia &aMedia) { mMedia = aMedia; } … … 182 180 { 183 181 QTreeWidgetItem *item = QTreeWidgetItemIterator::operator*(); 184 return item && item->type() == DiskImageItem::TypeId?182 return item && item->type() == QITreeWidget::BasicItemType ? 185 183 static_cast<DiskImageItem*> (item) : NULL; 186 184 } … … 1457 1455 DiskImageItem *item = NULL; 1458 1456 if (aItem && 1459 aItem->type() == DiskImageItem::TypeId)1457 aItem->type() == QITreeWidget::BasicItemType) 1460 1458 item = static_cast <DiskImageItem *> (aItem); 1461 1459
Note:
See TracChangeset
for help on using the changeset viewer.