| 32 | enum { IconSize = 32 }; |
| 33 | |
| 34 | QIcon errorIcon(const QPainterPath& path) |
| 35 | { |
| 36 | |
| 37 | const QRectF rect = path.boundingRect(); |
| 38 | |
| 39 | qreal scale = static_cast<double>(IconSize) / qMax(rect.width(), rect.height()); |
| 40 | |
| 41 | double ky = rect.bottom() * scale; |
| 42 | double kx = rect.left() * scale; |
| 43 | if (rect.width() > rect.height()) |
| 44 | ky += (static_cast<double>(IconSize) - rect.height() * scale) / 2; |
| 45 | else |
| 46 | kx -= (static_cast<double>(IconSize) - rect.width() * scale) / 2; |
| 47 | |
| 48 | QPixmap pixmap(IconSize, IconSize); |
| 49 | pixmap.fill(Qt::transparent); |
| 50 | QPainter painter; |
| 51 | painter.begin(&pixmap); |
| 52 | painter.setRenderHint(QPainter::Antialiasing); |
| 53 | painter.setPen(Qt::NoPen); |
| 54 | painter.setBrush(Qt::black); |
| 55 | // painter.translate(tr); |
| 56 | painter.translate(-kx, ky); |
| 57 | painter.scale(scale, -scale); |
| 58 | painter.drawPath(path); |
| 59 | return QIcon(pixmap); |
| 60 | } |
| 61 | |
| 62 | class ErrorModel : public QAbstractTableModel { |
| 63 | mvector<ErrorItem*> items; |