break;
}
}
+ else if (role == Qt::DecorationRole && column == COL_NAME)
+ {
+ if (childCount () > 0)
+ value = QApplication::style ()->standardIcon (QStyle::SP_DirOpenIcon);
+ else
+ value = Utils::guessMimeIcon (name ());
+ }
return value;
}
switch(index.column())
{
- case COL_NAME:
- {
- const QFontMetrics fm(item.font);
- const int iconSize = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
- size.rwidth() = HIG::PAD_SMALL + iconSize;
- size.rheight() = std::max(iconSize, fm.height());
- break;
- }
-
case COL_PROGRESS:
case COL_WANTED:
size = QSize(20, 1);
break;
default:
- {
- const QFontMetrics fm(item.font);
- const QString text = index.data().toString();
- size = fm.size(0, text);
- break;
- }
+ size = QItemDelegate::sizeHint (item, index);
}
size.rheight() += 8; // make the spacing a little nicer
{
const int column(index.column());
- if ((column != COL_PROGRESS) && (column != COL_WANTED) && (column != COL_NAME))
+ if ((column != COL_PROGRESS) && (column != COL_WANTED))
{
QItemDelegate::paint(painter, option, index);
return;
}
QStyle * style (QApplication :: style());
- if (option.state & QStyle::State_Selected)
- painter->fillRect (option.rect, option.palette.highlight());
- painter->save();
- if (option.state & QStyle::State_Selected)
- painter->setBrush (option.palette.highlightedText());
- if (column == COL_NAME)
- {
- // draw the file icon
- static const int iconSize (style->pixelMetric(QStyle :: PM_SmallIconSize));
- const QRect iconArea (option.rect.x(),
- option.rect.y() + (option.rect.height()-iconSize)/2,
- iconSize, iconSize);
- QIcon icon;
- if (index.model()->hasChildren(index))
- {
- icon = style->standardIcon(QStyle::StandardPixmap(QStyle::SP_DirOpenIcon));
- }
- else
- {
- QString name = index.data().toString();
- icon = Utils :: guessMimeIcon (name);
- }
- icon.paint (painter, iconArea, Qt::AlignCenter, QIcon::Normal, QIcon::On);
+ painter->save();
+ QItemDelegate::drawBackground (painter, option, index);
- // draw the name
- QStyleOptionViewItem tmp (option);
- tmp.rect.setWidth (option.rect.width() - iconArea.width() - HIG::PAD_SMALL);
- tmp.rect.moveRight (option.rect.right());
- QItemDelegate::paint (painter, tmp, index);
- }
- else if(column == COL_PROGRESS)
+ if(column == COL_PROGRESS)
{
QStyleOptionProgressBar p;
p.state = option.state | QStyle::State_Small;
style->drawControl (QStyle::CE_CheckBox, &o, painter);
}
+ QItemDelegate::drawFocus (painter, option, option.rect);
painter->restore();
}