| 775 | } |
| 776 | |
| 777 | QPixmap InstanceView::renderToPixmap(const QModelIndexList& indices, QRect* r) const |
| 778 | { |
| 779 | Q_ASSERT(r); |
| 780 | auto paintPairs = draggablePaintPairs(indices, r); |
| 781 | if (paintPairs.isEmpty()) { |
| 782 | return QPixmap(); |
| 783 | } |
| 784 | QPixmap pixmap(r->size()); |
| 785 | pixmap.fill(Qt::transparent); |
| 786 | QPainter painter(&pixmap); |
| 787 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 788 | QStyleOptionViewItem option; |
| 789 | initViewItemOption(&option); |
| 790 | #else |
| 791 | QStyleOptionViewItem option = viewOptions(); |
| 792 | #endif |
| 793 | option.state |= QStyle::State_Selected; |
| 794 | for (int j = 0; j < paintPairs.count(); ++j) { |
| 795 | option.rect = paintPairs.at(j).first.translated(-r->topLeft()); |
| 796 | const QModelIndex& current = paintPairs.at(j).second; |
| 797 | itemDelegate()->paint(&painter, option, current); |
| 798 | } |
| 799 | return pixmap; |
| 800 | } |
| 801 | |
| 802 | QList<std::pair<QRect, QModelIndex>> InstanceView::draggablePaintPairs(const QModelIndexList& indices, QRect* r) const |
| 803 | { |