254
254
QFont titleFont(option.font);
257
QIcon decorationIcon = index.data(Qt::DecorationRole).value<QIcon>();
259
if (index.data(d->roles[ColumnTypeRole]).toInt() == SecondaryActionColumn) {
261
// Only draw on hover
262
const int delta = floor((qreal)(option.decorationSize.width() - DelegatePrivate::ACTION_ICON_SIZE) / 2.0);
263
decorationRect.adjust(delta, delta-1, -delta-1, -delta);
264
decorationIcon.paint(painter, decorationRect, option.decorationAlignment);
267
// as default always draw as main column
268
decorationIcon.paint(painter, decorationRect, option.decorationAlignment);
274
painter->setFont(titleFont);
275
painter->drawText(titleRect, Qt::AlignLeft|Qt::AlignVCenter, titleText);
277
if (hover || !uniqueTitle) {
278
// draw sub-title, BUT only if:
279
// * it isn't a unique title, this allows two items to have the same title and be
280
// disambiguated by their subtitle
281
// * we are directed by the model that this item should never be treated as unique
282
// e.g. the documents list in the recently used tab
283
// * the mouse is hovered over the item, causing the additional information to be
286
// the rational for this is that subtitle text should in most cases not be
287
// required to understand the item itself and that showing all the subtexts in a
288
// listing makes the information density very high, impacting both the speed at
289
// which one can scan the list visually and the aesthetic qualities of the listing.
290
painter->setPen(QPen(KColorScheme(QPalette::Active).foreground(KColorScheme::InactiveText), 1));
291
painter->setFont(subTitleFont);
292
painter->drawText(subTitleRect, Qt::AlignLeft|Qt::AlignVCenter, " " + subTitleText);
299
painter->setPen(Qt::NoPen);
300
const QColor gradientColor =
301
KColorScheme(QPalette::Active).background(KColorScheme::NormalBackground).color();
302
if (option.direction == Qt::LeftToRight) {
303
if (((titleRect.width() + 40) > option.rect.width() ||
304
(subTitleRect.width() + 40) > option.rect.width()) &&
305
(titleRect.width() > 120 || subTitleRect.width() > 120)) {
307
QRect gradientRect(option.rect.width() - 30, titleRect.y(),
308
80, titleRect.height() + subTitleRect.height());
309
// draw it on the right side
310
gr.setStart(gradientRect.topLeft());
311
gr.setFinalStop(gradientRect.topRight());
312
gr.setColorAt(0.0, Qt::transparent);
313
gr.setColorAt(0.7, gradientColor);
314
painter->setBrush(QBrush(gr));
315
painter->drawRect(gradientRect);
319
if ((titleRect.width() + 40 > option.rect.width() ||
320
subTitleRect.width() + 40 > option.rect.width()) &&
321
(titleRect.width() > 120 || subTitleRect.width() > 120)) {
323
QRect gradientRect(option.rect.x() - 25, titleRect.y(),
324
60, titleRect.height() + subTitleRect.height());
325
gr.setStart(gradientRect.topRight());
326
gr.setFinalStop(gradientRect.topLeft());
327
gr.setColorAt(0.0, Qt::transparent);
328
gr.setColorAt(0.6, gradientColor);
329
painter->setBrush(QBrush(gr));
330
painter->drawRect(gradientRect);
258
338
painter->setRenderHint(QPainter::Antialiasing);
323
403
painter->restore();
327
QIcon decorationIcon = index.data(Qt::DecorationRole).value<QIcon>();
329
if (index.data(d->roles[ColumnTypeRole]).toInt() == SecondaryActionColumn) {
331
// Only draw on hover
332
const int delta = floor((qreal)(option.decorationSize.width() - DelegatePrivate::ACTION_ICON_SIZE) / 2.0);
333
decorationRect.adjust(delta, delta-1, -delta-1, -delta);
334
decorationIcon.paint(painter, decorationRect, option.decorationAlignment);
337
// as default always draw as main column
338
decorationIcon.paint(painter, decorationRect, option.decorationAlignment);
344
painter->setFont(titleFont);
345
painter->drawText(titleRect, Qt::AlignLeft|Qt::AlignVCenter, titleText);
347
if (hover || !uniqueTitle) {
348
// draw sub-title, BUT only if:
349
// * it isn't a unique title, this allows two items to have the same title and be
350
// disambiguated by their subtitle
351
// * we are directed by the model that this item should never be treated as unique
352
// e.g. the documents list in the recently used tab
353
// * the mouse is hovered over the item, causing the additional information to be
356
// the rational for this is that subtitle text should in most cases not be
357
// required to understand the item itself and that showing all the subtexts in a
358
// listing makes the information density very high, impacting both the speed at
359
// which one can scan the list visually and the aesthetic qualities of the listing.
360
painter->setPen(QPen(KColorScheme(QPalette::Active).foreground(KColorScheme::InactiveText), 1));
361
painter->setFont(subTitleFont);
362
painter->drawText(subTitleRect, Qt::AlignLeft|Qt::AlignVCenter, " " + subTitleText);