- Timestamp:
- Jan 17, 2024 1:17:09 PM (16 months ago)
- svn:sync-xref-src-repo-rev:
- 161150
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIStorageSettingsEditor.cpp
r102541 r102922 596 596 { 597 597 R_ItemId = Qt::UserRole + 1, 598 R_ItemPixmap, 598 R_ItemPixmapDefault, 599 R_ItemPixmapCollapsed, 600 R_ItemPixmapExpanded, 599 601 R_ItemPixmapRect, 600 602 R_ItemName, … … 791 793 StorageDelegate(QObject *pParent); 792 794 793 pr ivate:795 protected: 794 796 795 797 /** Paints @a index item with specified @a option using specified @a pPainter. */ 796 v oid paint(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const;798 virtual void paint(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const RT_OVERRIDE; 797 799 }; 798 800 … … 1851 1853 return QUuid(); 1852 1854 } 1853 case R_ItemPixmap :1855 case R_ItemPixmapDefault: 1854 1856 { 1855 1857 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1856 { 1857 ItemState enmState = ItemState_Default; 1858 if (hasChildren(specifiedIndex)) 1859 if (QTreeView *view = qobject_cast<QTreeView*>(QObject::parent())) 1860 enmState = view->isExpanded(specifiedIndex) ? ItemState_Expanded : ItemState_Collapsed; 1861 return pItem->pixmap(enmState); 1862 } 1858 return pItem->pixmap(ItemState_Default); 1859 return QPixmap(); 1860 } 1861 case R_ItemPixmapCollapsed: 1862 { 1863 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1864 return pItem->pixmap(ItemState_Collapsed); 1865 return QPixmap(); 1866 } 1867 case R_ItemPixmapExpanded: 1868 { 1869 if (AbstractItem *pItem = static_cast<AbstractItem*>(specifiedIndex.internalPointer())) 1870 return pItem->pixmap(ItemState_Expanded); 1863 1871 return QPixmap(); 1864 1872 } … … 2772 2780 void StorageDelegate::paint(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const 2773 2781 { 2774 if (!index.isValid()) return; 2775 2776 /* Initialize variables: */ 2782 /* Sanity check: */ 2783 if (!index.isValid()) 2784 return; 2785 2786 /* Acquire model: */ 2787 const StorageModel *pModel = qobject_cast<const StorageModel*>(index.model()); 2788 AssertPtrReturnVoid(pModel); 2789 2790 /* Fetch options: */ 2777 2791 QStyle::State enmState = option.state; 2778 2792 QRect rect = option.rect; 2779 const StorageModel *pModel = qobject_cast<const StorageModel*>(index.model());2780 Assert(pModel);2781 2793 2782 2794 pPainter->save(); … … 2796 2808 2797 2809 /* Draw Item Pixmap: */ 2810 const bool fHasChildren = enmState & QStyle::State_Children; 2811 const bool fOpened = enmState & QStyle::State_Open; 2812 QPixmap pixmap = !fHasChildren 2813 ? pModel->data(index, StorageModel::R_ItemPixmapDefault).value<QPixmap>() 2814 : !fOpened 2815 ? pModel->data(index, StorageModel::R_ItemPixmapCollapsed).value<QPixmap>() 2816 : pModel->data(index, StorageModel::R_ItemPixmapExpanded).value<QPixmap>(); 2798 2817 pPainter->drawPixmap(pModel->data(index, StorageModel::R_ItemPixmapRect).toRect().topLeft(), 2799 p Model->data(index, StorageModel::R_ItemPixmap).value<QPixmap>());2818 pixmap); 2800 2819 2801 2820 /* Draw compressed item name: */
Note:
See TracChangeset
for help on using the changeset viewer.