| 177 | } |
| 178 | |
| 179 | void ListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const |
| 180 | { |
| 181 | QStyleOptionViewItem opt = option; |
| 182 | initStyleOption(&opt, index); |
| 183 | painter->save(); |
| 184 | painter->setClipRect(opt.rect); |
| 185 | |
| 186 | opt.features |= QStyleOptionViewItem::WrapText; |
| 187 | opt.text = index.data().toString(); |
| 188 | opt.textElideMode = Qt::ElideRight; |
| 189 | opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter; |
| 190 | |
| 191 | QStyle* style = opt.widget ? opt.widget->style() : QApplication::style(); |
| 192 | |
| 193 | // const int iconSize = style->pixelMetric(QStyle::PM_IconViewIconSize); |
| 194 | const int iconSize = 48; |
| 195 | QRect iconbox = opt.rect; |
| 196 | const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, opt.widget) + 1; |
| 197 | QRect textRect = opt.rect; |
| 198 | QRect textHighlightRect = textRect; |
| 199 | // clip the decoration on top, remove width padding |
| 200 | textRect.adjust(textMargin, iconSize + textMargin + 5, -textMargin, 0); |
| 201 | |
| 202 | textHighlightRect.adjust(0, iconSize + 5, 0, 0); |
| 203 | |
| 204 | // draw background |
| 205 | { |
| 206 | // FIXME: unused |
| 207 | // QSize textSize = viewItemTextSize ( &opt ); |
| 208 | drawSelectionRect(painter, opt, textHighlightRect); |
| 209 | /* |
| 210 | QPalette::ColorGroup cg; |
| 211 | QStyleOptionViewItem opt2(opt); |
| 212 | |
| 213 | if ((opt.widget && opt.widget->isEnabled()) || (opt.state & QStyle::State_Enabled)) |
| 214 | { |
| 215 | if (!(opt.state & QStyle::State_Active)) |
| 216 | cg = QPalette::Inactive; |
| 217 | else |
| 218 | cg = QPalette::Normal; |
| 219 | } |
| 220 | else |
| 221 | { |
| 222 | cg = QPalette::Disabled; |
| 223 | } |
| 224 | */ |
| 225 | /* |
| 226 | opt2.palette.setCurrentColorGroup(cg); |
| 227 | |
| 228 | // fill in background, if any |
| 229 | |
| 230 | |
| 231 | if (opt.backgroundBrush.style() != Qt::NoBrush) |
| 232 | { |
| 233 | QPointF oldBO = painter->brushOrigin(); |
| 234 | painter->setBrushOrigin(opt.rect.topLeft()); |
| 235 | painter->fillRect(opt.rect, opt.backgroundBrush); |
| 236 | painter->setBrushOrigin(oldBO); |
no test coverage detected