41 const int lineWidth = rc.width() > 20 ? 4 : 2;
43 const int x0 = rc.x();
44 const int y0 = rc.y();
45 const int x1 = rc.right();
46 const int y1 = rc.bottom();
49 linesDark << QLine(x0 + lineWidth / 2, y0, x0 + lineWidth / 2, y1);
50 linesDark << QLine(x1 - lineWidth / 2 + 1, y0, x1 - lineWidth / 2 + 1, y1);
52 QPen oldPen = painter->pen();
53 painter->setPen(QPen(lineColor, lineWidth));
54 painter->drawLines(linesDark);
55 painter->setPen(oldPen);
58 QPen oldPen = painter->pen();
59 QBrush oldBrush(painter->brush());
61 painter->setPen(QPen(lineColor, 0));
62 painter->setBrush(lineColor);
64 painter->drawEllipse(rc.center(), 2,2);
66 painter->setBrush(oldBrush);
67 painter->setPen(oldPen);
81 QColor color = qApp->palette().color(QPalette::Highlight);
82 QColor baseColor = qApp->palette().color(QPalette::Base);
83 QColor noLabelSetColor = qApp->palette().color(QPalette::Highlight);
87 if (colorLabel.isValid()) {
90 color = noLabelSetColor;
97 if (doesFrameExist && hasContent) {
101 QPen oldPen = painter->pen();
102 QBrush oldBrush(painter->brush());
104 painter->setPen(QPen(color, 0));
105 painter->setBrush(color);
107 QPointF center = rc.center();
108 QPointF points[4] = {
109 QPointF(center.x() + 4, center.y() ),
110 QPointF(center.x() , center.y() - 4),
111 QPointF(center.x() - 4, center.y() ),
112 QPointF(center.x() , center.y() + 4)
114 painter->drawConvexPolygon(points, 4);
116 painter->setBrush(oldBrush);
117 painter->setPen(oldPen);
133 QColor noLabelSetColor = qApp->palette().color(QPalette::Highlight);
134 QColor highlightColor = qApp->palette().color(QPalette::Highlight);
135 QColor baseColor = qApp->palette().color(QPalette::Base);
139 if (hasActiveLayerRole) {
141 painter->fillRect(rc, color);
144 painter->fillRect(rc, color);
149 if (colorLabel.isValid()) {
152 color = noLabelSetColor;
165 if (hasContent && doesFrameExist) {
166 painter->fillRect(rc, color);
170 if (doesFrameExist && !hasContent) {
172 QPen oldPen = painter->pen();
173 QBrush oldBrush(painter->brush());
175 painter->setPen(QPen(color, 2));
176 painter->setBrush(Qt::NoBrush);
177 painter->drawRect(rc);
179 painter->setBrush(oldBrush);
180 painter->setPen(oldPen);
184 if (!doesFrameExist && hasContent) {
187 if (colorLabel.toInt() == 0) {
188 color = noLabelSetColor;
196 QPoint lineStart(rc.x(), (rc.y() + rc.height()/2));
197 QPoint lineEnd(rc.x() + rc.width(), (rc.y() + rc.height()/2));
199 QPen holdFramePen(color);
200 holdFramePen.setWidth(1);
202 painter->setPen(holdFramePen);
203 painter->drawLine(QLine(lineStart, lineEnd));
210 const QStyleOptionViewItem &option,
211 const QRect &
rect)
const
214 if ((option.state & QStyle::State_HasFocus) == 0 || !
rect.isValid())
220 QStyleOptionFocusRect o;
221 o.QStyleOption::operator=(option);
223 o.state |= QStyle::State_KeyboardFocusChange;
224 o.state |= QStyle::State_Item;
225 QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled)
226 ? QPalette::Normal : QPalette::Disabled;
227 o.backgroundColor = option.palette.color(cg, (option.state & QStyle::State_Selected)
228 ? QPalette::Highlight : QPalette::Window);
229 const QWidget *widget = qobject_cast<QWidget*>(parent());
230 QStyle *style = widget ? widget->style() : QApplication::style();
231 style->drawPrimitive(QStyle::PE_FrameFocusRect, &o, painter, widget);
252 const QStyleOptionViewItem &option,
253 const QModelIndex &index)
const
264 if (option.showDecorationSelected &&
265 (option.state & QStyle::State_Selected)) {
269 bool isEditable = data.isValid() ? data.toBool() :
true;
272 highlightColor.setAlpha(isEditable ? 128 : 64);
273 QBrush brush = highlightColor;
274 painter->fillRect(option.rect, brush);
299 painter->setOpacity(0.50f);
300 painter->fillRect(option.rect, qApp->palette().color(QPalette::Base).darker(110));