| 1678 | } |
| 1679 | |
| 1680 | void BoxPlotPrivate::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget*) { |
| 1681 | if (!isVisible()) |
| 1682 | return; |
| 1683 | |
| 1684 | painter->setPen(Qt::NoPen); |
| 1685 | painter->setBrush(Qt::NoBrush); |
| 1686 | painter->setRenderHint(QPainter::SmoothPixmapTransform); |
| 1687 | |
| 1688 | if (!q->isPrinting() && Settings::group(QStringLiteral("Settings_Worksheet")).readEntry<bool>("DoubleBuffering", true)) |
| 1689 | painter->drawPixmap(m_boundingRectangle.topLeft(), m_pixmap); // draw the cached pixmap (fast) |
| 1690 | else |
| 1691 | draw(painter); // draw directly again (slow) |
| 1692 | |
| 1693 | // no need to handle the selection/hover effect if the cached pixmap is empty |
| 1694 | if (m_pixmap.isNull()) |
| 1695 | return; |
| 1696 | |
| 1697 | if (m_hovered && !isSelected() && !q->isPrinting()) { |
| 1698 | if (m_hoverEffectImageIsDirty) { |
| 1699 | QPixmap pix = m_pixmap; |
| 1700 | QPainter p(&pix); |
| 1701 | p.setCompositionMode(QPainter::CompositionMode_SourceIn); // source (shadow) pixels merged with the alpha channel of the destination (m_pixmap) |
| 1702 | p.fillRect(pix.rect(), QApplication::palette().color(QPalette::Shadow)); |
| 1703 | p.end(); |
| 1704 | |
| 1705 | m_hoverEffectImage = ImageTools::blurred(pix.toImage(), m_pixmap.rect(), 5); |
| 1706 | m_hoverEffectImageIsDirty = false; |
| 1707 | } |
| 1708 | |
| 1709 | painter->drawImage(m_boundingRectangle.topLeft(), m_hoverEffectImage, m_pixmap.rect()); |
| 1710 | return; |
| 1711 | } |
| 1712 | |
| 1713 | if (isSelected() && !q->isPrinting()) { |
| 1714 | if (m_selectionEffectImageIsDirty) { |
| 1715 | QPixmap pix = m_pixmap; |
| 1716 | QPainter p(&pix); |
| 1717 | p.setCompositionMode(QPainter::CompositionMode_SourceIn); |
| 1718 | p.fillRect(pix.rect(), QApplication::palette().color(QPalette::Highlight)); |
| 1719 | p.end(); |
| 1720 | |
| 1721 | m_selectionEffectImage = ImageTools::blurred(pix.toImage(), m_pixmap.rect(), 5); |
| 1722 | m_selectionEffectImageIsDirty = false; |
| 1723 | } |
| 1724 | |
| 1725 | painter->drawImage(m_boundingRectangle.topLeft(), m_selectionEffectImage, m_pixmap.rect()); |
| 1726 | return; |
| 1727 | } |
| 1728 | } |
| 1729 | |
| 1730 | // ############################################################################## |
| 1731 | // ################## Serialization/Deserialization ########################### |