- Timestamp:
- Jun 7, 2010 9:41:33 AM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.cpp
r30022 r30062 29 29 #include <QFileInfo> 30 30 #include <QLinearGradient> 31 #include <QPixmapCache> 31 32 32 33 #if defined (Q_WS_MAC) … … 581 582 break; 582 583 } 584 case OSTypeIdRole: 585 { 586 v = m_VMItemList.at(aIndex.row())->osTypeId(); 587 break; 588 } 583 589 case UIVMItemPtrRole: 584 590 { 585 591 v = qVariantFromValue(m_VMItemList.at(aIndex.row())); 592 break; 586 593 } 587 594 } … … 743 750 744 751 QSize UIVMItemPainter::sizeHint(const QStyleOptionViewItem &aOption, 745 752 const QModelIndex &aIndex) const 746 753 { 747 754 /* Get the size of every item */ … … 759 766 } 760 767 761 void UIVMItemPainter::paint(QPainter *aPainter, const QStyleOptionViewItem &aOption, 762 const QModelIndex &aIndex) const 763 { 764 QStyleOptionViewItem option(aOption); 765 /* Highlight background if an item is selected in any case. 766 * (Fix for selector in the windows style.) */ 767 option.showDecorationSelected = true; 768 769 /* Start drawing with the background */ 770 drawBackground(aPainter, option, aIndex); 771 772 /* Blend the content */ 773 blendContent(aPainter, option, aIndex); 774 775 /* Draw a focus rectangle when necessary */ 776 drawFocus(aPainter, option, option.rect); 768 void UIVMItemPainter::paint(QPainter *pPainter, const QStyleOptionViewItem &option, 769 const QModelIndex &index) const 770 { 771 /* Generate the key used in the pixmap cache. Needs to be composed with all 772 * values which might be changed. */ 773 QString key = QString("vbox:%1:%2:%3:%4:%5:%6") 774 .arg(index.data(Qt::DisplayRole).toString()) 775 .arg(index.data(UIVMItemModel::OSTypeIdRole).toString()) 776 .arg(index.data(UIVMItemModel::SnapShotDisplayRole).toString()) 777 .arg(index.data(UIVMItemModel::SessionStateDisplayRole).toString()) 778 .arg(option.state) 779 .arg(option.rect.width()); 780 781 /* Check if the pixmap already exists in the cache. */ 782 QPixmap pixmap; 783 if (!QPixmapCache::find(key, pixmap)) 784 { 785 /* If not, generate a new one */ 786 QStyleOptionViewItem tmpOption(option); 787 /* Highlight background if an item is selected in any case. 788 * (Fix for selector in the windows style.) */ 789 tmpOption.showDecorationSelected = true; 790 791 /* Create a temporary pixmap and painter to work on.*/ 792 QPixmap tmpPixmap(option.rect.size()); 793 tmpPixmap.fill(Qt::transparent); 794 QPainter tmpPainter(&tmpPixmap); 795 796 /* Normally we operate on a painter which is in the size of the list 797 * view widget. Here we process one item only, so shift all the stuff 798 * out of the view. It will be translated back in the following 799 * methods. */ 800 tmpPainter.translate(-option.rect.x(), -option.rect.y()); 801 802 /* Start drawing with the background */ 803 drawBackground(&tmpPainter, tmpOption, index); 804 805 /* Blend the content */ 806 blendContent(&tmpPainter, tmpOption, index); 807 808 /* Draw a focus rectangle when necessary */ 809 drawFocus(&tmpPainter, tmpOption, tmpOption.rect); 810 811 /* Finish drawing */ 812 tmpPainter.end(); 813 814 pixmap = tmpPixmap; 815 /* Fill the cache */ 816 QPixmapCache::insert(key, tmpPixmap); 817 } 818 pPainter->drawPixmap(option.rect, pixmap); 777 819 } 778 820 -
trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.h
r30022 r30062 40 40 QString name() const { return m_strName; } 41 41 QIcon osIcon() const { return m_fAccessible ? vboxGlobal().vmGuestOSTypeIcon(m_strOSTypeId) : QPixmap(":/os_other.png"); } 42 QString osTypeId() const { return m_strOSTypeId; } 42 43 QString id() const { return m_strId; } 43 44 … … 96 97 SessionStateDecorationRole, 97 98 SessionStateFontRole, 99 OSTypeIdRole, 98 100 UIVMItemPtrRole }; 99 101
Note:
See TracChangeset
for help on using the changeset viewer.