| 792 | } |
| 793 | |
| 794 | QPixmap InstanceView::renderToPixmap(const QModelIndexList &indices, QRect *r) const |
| 795 | { |
| 796 | Q_ASSERT(r); |
| 797 | auto paintPairs = draggablePaintPairs(indices, r); |
| 798 | if (paintPairs.isEmpty()) |
| 799 | { |
| 800 | return QPixmap(); |
| 801 | } |
| 802 | QPixmap pixmap(r->size()); |
| 803 | pixmap.fill(Qt::transparent); |
| 804 | QPainter painter(&pixmap); |
| 805 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 806 | QStyleOptionViewItem option; |
| 807 | initViewItemOption(&option); |
| 808 | #else |
| 809 | QStyleOptionViewItem option = viewOptions(); |
| 810 | #endif |
| 811 | option.state |= QStyle::State_Selected; |
| 812 | for (int j = 0; j < paintPairs.count(); ++j) |
| 813 | { |
| 814 | option.rect = paintPairs.at(j).first.translated(-r->topLeft()); |
| 815 | const QModelIndex ¤t = paintPairs.at(j).second; |
| 816 | itemDelegate()->paint(&painter, option, current); |
| 817 | } |
| 818 | return pixmap; |
| 819 | } |
| 820 | |
| 821 | QList<std::pair<QRect, QModelIndex>> InstanceView::draggablePaintPairs(const QModelIndexList &indices, QRect *r) const |
| 822 | { |