| 296 | } |
| 297 | |
| 298 | void ImagePrivate::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget*) { |
| 299 | painter->save(); |
| 300 | |
| 301 | // draw the image |
| 302 | painter->setOpacity(opacity); |
| 303 | painter->drawImage(m_boundingRectangle.topLeft(), imageScaled, imageScaled.rect()); |
| 304 | painter->restore(); |
| 305 | |
| 306 | // draw the border |
| 307 | if (borderLine->style() != Qt::NoPen) { |
| 308 | painter->save(); |
| 309 | painter->setPen(borderLine->pen()); |
| 310 | painter->setBrush(Qt::NoBrush); |
| 311 | painter->setOpacity(borderLine->opacity()); |
| 312 | painter->drawPath(borderShapePath); |
| 313 | painter->restore(); |
| 314 | } |
| 315 | |
| 316 | const bool selected = isSelected(); |
| 317 | const bool hovered = (m_hovered && !selected); |
| 318 | if ((hovered || selected) && !q->isPrinting()) { |
| 319 | static double penWidth = 2.; |
| 320 | const QRectF& br = boundingRect(); |
| 321 | const qreal width = br.width(); |
| 322 | const qreal height = br.height(); |
| 323 | const QRectF rect = QRectF(-width / 2 + penWidth / 2, -height / 2 + penWidth / 2, width - penWidth, height - penWidth); |
| 324 | |
| 325 | if (hovered) |
| 326 | painter->setPen(QPen(QApplication::palette().color(QPalette::Shadow), penWidth)); |
| 327 | else |
| 328 | painter->setPen(QPen(QApplication::palette().color(QPalette::Highlight), penWidth)); |
| 329 | |
| 330 | painter->drawRect(rect); |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | // ############################################################################## |
| 335 | // ################## Serialization/Deserialization ########################### |