30 if (!index.isValid())
return;
41 qreal devicePixelRatioF = painter->device()->devicePixelRatioF();
43 if (thumbnail.isNull()) {
45 thumbnail =
koIcon(
"warning").pixmap(option.decorationSize).toImage();
46 if (storageType ==
"Folder") {
47 thumbnail =
koIcon(
"document-open").pixmap(option.decorationSize).toImage();
49 else if (storageType ==
"Adobe Style Library") {
50 thumbnail =
koIcon(
"layer-style-enabled").pixmap(option.decorationSize).toImage();
51 if (!thumbnail.isNull()) {
52 thumbnail = thumbnail.scaled(option.decorationSize, Qt::KeepAspectRatio, Qt::FastTransformation);
55 else if (storageType ==
"Adobe Brush Library") {
56 thumbnail =
koIcon(
"select-all").pixmap(option.decorationSize).toImage();
58 else if (storageType ==
"Memory") {
59 if (location !=
"memory") {
60 thumbnail =
koIcon(
"document-new").pixmap(option.decorationSize).toImage();
62 thumbnail =
koIcon(
"drive-harddisk").pixmap(option.decorationSize).toImage();
66 else if (storageType ==
"Bundle") {
67 thumbnail =
koIcon(
"bundle_archive").pixmap(option.decorationSize).toImage();
71 if (!thumbnail.isNull()) {
72 thumbnail = thumbnail.scaled(option.decorationSize*devicePixelRatioF, Qt::KeepAspectRatio, Qt::SmoothTransformation);
74 thumbnail.setDevicePixelRatio(devicePixelRatioF);
77 QColor penColor(option.palette.text().color());
79 QStyleOptionViewItem opt = option;
82 opt.state = QStyle::State_Sunken;
85 QApplication::style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, painter);
87 painter->setPen(penColor);
88 painter->drawImage(option.rect.topLeft()+QPoint(4, 4), thumbnail, thumbnail.rect());
92 QStyleOptionButton checkboxOption;
93 checkboxOption.rect = QRect(option.rect.x() + option.decorationSize.width() + 8,
94 option.rect.y() + option.rect.height() - 30,
96 checkboxOption.state = active ? QStyle::State_On : QStyle::State_Off;
97 QApplication::style()->drawControl(QStyle::CE_CheckBox, &checkboxOption, painter);
101 QRect text = option.rect;
102 text.setLeft(text.left()+option.decorationSize.width()+8);
103 text.setTop(text.top()+4);
104 painter->drawText(text, Qt::TextWordWrap, name.split(
"_").join(
" "));