| 743 | static const int RichResourceTextMargin = 2; |
| 744 | |
| 745 | void RichResourceTextPaint(const QWidget *owner, QPainter *painter, QRect rect, QFont font, |
| 746 | QPalette palette, QStyle::State state, QPoint mousePos, |
| 747 | const QVariant &var) |
| 748 | { |
| 749 | QBrush foreBrush = palette.brush(state & QStyle::State_Selected ? QPalette::HighlightedText |
| 750 | : QPalette::WindowText); |
| 751 | |
| 752 | painter->save(); |
| 753 | |
| 754 | // special case handling for ResourceId/GPUAddress on its own |
| 755 | if(var.userType() == qMetaTypeId<ResourceId>() || var.userType() == qMetaTypeId<GPUAddressPtr>()) |
| 756 | { |
| 757 | QFont f = painter->font(); |
| 758 | f.setBold(true); |
| 759 | painter->setFont(f); |
| 760 | |
| 761 | static const int margin = RichResourceTextMargin; |
| 762 | |
| 763 | rect.adjust(margin, 0, -margin, 0); |
| 764 | |
| 765 | QString name; |
| 766 | |
| 767 | bool valid = false; |
| 768 | |
| 769 | if(var.userType() == qMetaTypeId<ResourceId>()) |
| 770 | { |
| 771 | ICaptureContext *ctxptr = getCaptureContext(owner); |
| 772 | |
| 773 | ResourceId id = var.value<ResourceId>(); |
| 774 | |
| 775 | valid = (id != ResourceId()); |
| 776 | |
| 777 | if(ctxptr) |
| 778 | name = GetTruncatedResourceName(*ctxptr, id); |
| 779 | else |
| 780 | name = ToQStr(id); |
| 781 | } |
| 782 | else |
| 783 | { |
| 784 | GPUAddressPtr ptr = var.value<GPUAddressPtr>(); |
| 785 | |
| 786 | ptr->cacheAddress(owner); |
| 787 | |
| 788 | valid = (ptr->val.pointer != 0); |
| 789 | |
| 790 | if(valid) |
| 791 | { |
| 792 | if(ptr->base != ResourceId()) |
| 793 | { |
| 794 | name = |
| 795 | QFormatStr("%1+%2").arg(GetTruncatedResourceName(*ptr->ctxptr, ptr->base)).arg(ptr->offset); |
| 796 | } |
| 797 | else |
| 798 | { |
| 799 | name = QFormatStr("Unknown 0x%1").arg(ptr->val.pointer, 16, 16, QLatin1Char('0')); |
| 800 | valid = false; |
| 801 | } |
| 802 | } |
no test coverage detected