1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "kstandarditemlistwidget.h"
22 #include "kfileitemlistview.h"
23 #include "kfileitemmodel.h"
26 #include <KIconEffect>
27 #include <KIconLoader>
29 #include <kratingpainter.h>
30 #include <KStringHandler>
33 #include "private/kfileitemclipboard.h"
34 #include "private/kitemlistroleeditor.h"
35 #include "private/kpixmapmodifier.h"
37 #include <QFontMetricsF>
38 #include <QGraphicsScene>
39 #include <QGraphicsSceneResizeEvent>
40 #include <QGraphicsView>
42 #include <QStyleOption>
43 #include <QTextLayout>
45 #include <QPixmapCache>
47 // #define KSTANDARDITEMLISTWIDGET_DEBUG
49 KStandardItemListWidgetInformant::KStandardItemListWidgetInformant() :
50 KItemListWidgetInformant()
54 KStandardItemListWidgetInformant::~KStandardItemListWidgetInformant()
58 QSizeF
KStandardItemListWidgetInformant::itemSizeHint(int index
, const KItemListView
* view
) const
60 const KItemListStyleOption
& option
= view
->styleOption();
61 const int additionalRolesCount
= qMax(view
->visibleRoles().count() - 1, 0);
63 switch (static_cast<const KStandardItemListView
*>(view
)->itemLayout()) {
64 case KStandardItemListWidget::IconsLayout
: {
65 const QString text
= KStringHandler::preProcessWrap(itemText(index
, view
));
67 const qreal itemWidth
= view
->itemSize().width();
68 const qreal maxWidth
= itemWidth
- 2 * option
.padding
;
71 // Calculate the number of lines required for wrapping the name
72 QTextOption
textOption(Qt::AlignHCenter
);
73 textOption
.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere
);
76 QTextLayout
layout(text
, option
.font
);
77 layout
.setTextOption(textOption
);
79 while ((line
= layout
.createLine()).isValid()) {
80 line
.setLineWidth(maxWidth
);
81 line
.naturalTextWidth();
82 textHeight
+= line
.height();
86 // Add one line for each additional information
87 textHeight
+= additionalRolesCount
* option
.fontMetrics
.lineSpacing();
89 const qreal maxTextHeight
= option
.maxTextSize
.height();
90 if (maxTextHeight
> 0 && textHeight
> maxTextHeight
) {
91 textHeight
= maxTextHeight
;
94 return QSizeF(itemWidth
, textHeight
+ option
.iconSize
+ option
.padding
* 3);
97 case KStandardItemListWidget::CompactLayout
: {
98 // For each row exactly one role is shown. Calculate the maximum required width that is necessary
99 // to show all roles without horizontal clipping.
100 qreal maximumRequiredWidth
= 0.0;
102 const QList
<QByteArray
>& visibleRoles
= view
->visibleRoles();
103 const bool showOnlyTextRole
= (visibleRoles
.count() == 1) && (visibleRoles
.first() == "text");
105 if (showOnlyTextRole
) {
106 maximumRequiredWidth
= option
.fontMetrics
.width(itemText(index
, view
));
108 const QHash
<QByteArray
, QVariant
> values
= view
->model()->data(index
);
109 foreach (const QByteArray
& role
, view
->visibleRoles()) {
110 const QString text
= roleText(role
, values
);
111 const qreal requiredWidth
= option
.fontMetrics
.width(text
);
112 maximumRequiredWidth
= qMax(maximumRequiredWidth
, requiredWidth
);
116 qreal width
= option
.padding
* 4 + option
.iconSize
+ maximumRequiredWidth
;
117 const qreal maxWidth
= option
.maxTextSize
.width();
118 if (maxWidth
> 0 && width
> maxWidth
) {
121 const qreal height
= option
.padding
* 2 + qMax(option
.iconSize
, (1 + additionalRolesCount
) * option
.fontMetrics
.lineSpacing());
122 return QSizeF(width
, height
);
125 case KStandardItemListWidget::DetailsLayout
: {
126 const qreal height
= option
.padding
* 2 + qMax(option
.iconSize
, option
.fontMetrics
.height());
127 return QSizeF(-1, height
);
138 qreal
KStandardItemListWidgetInformant::preferredRoleColumnWidth(const QByteArray
& role
,
140 const KItemListView
* view
) const
142 const QHash
<QByteArray
, QVariant
> values
= view
->model()->data(index
);
143 const KItemListStyleOption
& option
= view
->styleOption();
145 const QString text
= roleText(role
, values
);
146 qreal width
= KStandardItemListWidget::columnPadding(option
);
148 if (role
== "rating") {
149 width
+= KStandardItemListWidget::preferredRatingSize(option
).width();
151 width
+= option
.fontMetrics
.width(text
);
153 if (role
== "text") {
154 if (view
->supportsItemExpanding()) {
155 // Increase the width by the expansion-toggle and the current expansion level
156 const int expandedParentsCount
= values
.value("expandedParentsCount", 0).toInt();
157 const qreal height
= option
.padding
* 2 + qMax(option
.iconSize
, option
.fontMetrics
.height());
158 width
+= (expandedParentsCount
+ 1) * height
;
161 // Increase the width by the required space for the icon
162 width
+= option
.padding
* 2 + option
.iconSize
;
169 QString
KStandardItemListWidgetInformant::itemText(int index
, const KItemListView
* view
) const
171 return view
->model()->data(index
).value("text").toString();
174 QString
KStandardItemListWidgetInformant::roleText(const QByteArray
& role
,
175 const QHash
<QByteArray
, QVariant
>& values
) const
177 if (role
== "rating") {
178 // Always use an empty text, as the rating is shown by the image m_rating.
181 return values
.value(role
).toString();
184 KStandardItemListWidget::KStandardItemListWidget(KItemListWidgetInformant
* informant
, QGraphicsItem
* parent
) :
185 KItemListWidget(informant
, parent
),
189 m_customizedFontMetrics(m_customizedFont
),
190 m_isExpandable(false),
191 m_supportsItemExpanding(false),
193 m_dirtyContent(true),
194 m_dirtyContentRoles(),
195 m_layout(IconsLayout
),
198 m_scaledPixmapSize(),
203 m_sortedVisibleRoles(),
206 m_additionalInfoTextColor(),
214 KStandardItemListWidget::~KStandardItemListWidget()
216 qDeleteAll(m_textInfo
);
220 m_roleEditor
->deleteLater();
223 if (m_oldRoleEditor
) {
224 m_oldRoleEditor
->deleteLater();
228 void KStandardItemListWidget::setLayout(Layout layout
)
230 if (m_layout
!= layout
) {
232 m_dirtyLayout
= true;
233 updateAdditionalInfoTextColor();
238 KStandardItemListWidget::Layout
KStandardItemListWidget::layout() const
243 void KStandardItemListWidget::setSupportsItemExpanding(bool supportsItemExpanding
)
245 if (m_supportsItemExpanding
!= supportsItemExpanding
) {
246 m_supportsItemExpanding
= supportsItemExpanding
;
247 m_dirtyLayout
= true;
252 bool KStandardItemListWidget::supportsItemExpanding() const
254 return m_supportsItemExpanding
;
257 void KStandardItemListWidget::paint(QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
)
259 const_cast<KStandardItemListWidget
*>(this)->triggerCacheRefreshing();
261 KItemListWidget::paint(painter
, option
, widget
);
263 if (!m_expansionArea
.isEmpty()) {
264 drawSiblingsInformation(painter
);
267 const KItemListStyleOption
& itemListStyleOption
= styleOption();
269 if (hoverOpacity() < 1.0) {
271 * Linear interpolation between m_pixmap and m_hoverPixmap.
273 * Note that this cannot be achieved by painting m_hoverPixmap over
274 * m_pixmap, even if the opacities are adjusted. For details see
275 * https://git.reviewboard.kde.org/r/109614/
277 // Paint pixmap1 so that pixmap1 = m_pixmap * (1.0 - hoverOpacity())
278 QPixmap
pixmap1(m_pixmap
.size());
279 pixmap1
.fill(Qt::transparent
);
281 QPainter
p(&pixmap1
);
282 p
.setOpacity(1.0 - hoverOpacity());
283 p
.drawPixmap(0, 0, m_pixmap
);
286 // Paint pixmap2 so that pixmap2 = m_hoverPixmap * hoverOpacity()
287 QPixmap
pixmap2(pixmap1
.size());
288 pixmap2
.fill(Qt::transparent
);
290 QPainter
p(&pixmap2
);
291 p
.setOpacity(hoverOpacity());
292 p
.drawPixmap(0, 0, m_hoverPixmap
);
295 // Paint pixmap2 on pixmap1 using CompositionMode_Plus
296 // Now pixmap1 = pixmap2 + m_pixmap * (1.0 - hoverOpacity())
297 // = m_hoverPixmap * hoverOpacity() + m_pixmap * (1.0 - hoverOpacity())
299 QPainter
p(&pixmap1
);
300 p
.setCompositionMode(QPainter::CompositionMode_Plus
);
301 p
.drawPixmap(0, 0, pixmap2
);
304 // Finally paint pixmap1 on the widget
305 drawPixmap(painter
, pixmap1
);
307 drawPixmap(painter
, m_hoverPixmap
);
310 drawPixmap(painter
, m_pixmap
);
313 painter
->setFont(m_customizedFont
);
314 painter
->setPen(textColor());
315 const TextInfo
* textInfo
= m_textInfo
.value("text");
318 // It seems that we can end up here even if m_textInfo does not contain
319 // the key "text", see bug 306167. According to triggerCacheRefreshing(),
320 // this can only happen if the index is negative. This can happen when
321 // the item is about to be removed, see KItemListView::slotItemsRemoved().
322 // TODO: try to reproduce the crash and find a better fix.
326 painter
->drawStaticText(textInfo
->pos
, textInfo
->staticText
);
328 bool clipAdditionalInfoBounds
= false;
329 if (m_supportsItemExpanding
) {
330 // Prevent a possible overlapping of the additional-information texts
331 // with the icon. This can happen if the user has minimized the width
332 // of the name-column to a very small value.
333 const qreal minX
= m_pixmapPos
.x() + m_pixmap
.width() + 4 * itemListStyleOption
.padding
;
334 if (textInfo
->pos
.x() + columnWidth("text") > minX
) {
335 clipAdditionalInfoBounds
= true;
337 painter
->setClipRect(minX
, 0, size().width() - minX
, size().height(), Qt::IntersectClip
);
341 painter
->setPen(m_additionalInfoTextColor
);
342 painter
->setFont(m_customizedFont
);
344 for (int i
= 1; i
< m_sortedVisibleRoles
.count(); ++i
) {
345 const TextInfo
* textInfo
= m_textInfo
.value(m_sortedVisibleRoles
[i
]);
346 painter
->drawStaticText(textInfo
->pos
, textInfo
->staticText
);
349 if (!m_rating
.isNull()) {
350 const TextInfo
* ratingTextInfo
= m_textInfo
.value("rating");
351 QPointF pos
= ratingTextInfo
->pos
;
352 const Qt::Alignment align
= ratingTextInfo
->staticText
.textOption().alignment();
353 if (align
& Qt::AlignHCenter
) {
354 pos
.rx() += (size().width() - m_rating
.width()) / 2 - 2;
356 painter
->drawPixmap(pos
, m_rating
);
359 if (clipAdditionalInfoBounds
) {
363 #ifdef KSTANDARDITEMLISTWIDGET_DEBUG
364 painter
->setBrush(Qt::NoBrush
);
365 painter
->setPen(Qt::green
);
366 painter
->drawRect(m_iconRect
);
368 painter
->setPen(Qt::blue
);
369 painter
->drawRect(m_textRect
);
371 painter
->setPen(Qt::red
);
372 painter
->drawText(QPointF(0, m_customizedFontMetrics
.height()), QString::number(index()));
373 painter
->drawRect(rect());
377 QRectF
KStandardItemListWidget::iconRect() const
379 const_cast<KStandardItemListWidget
*>(this)->triggerCacheRefreshing();
383 QRectF
KStandardItemListWidget::textRect() const
385 const_cast<KStandardItemListWidget
*>(this)->triggerCacheRefreshing();
389 QRectF
KStandardItemListWidget::textFocusRect() const
391 // In the compact- and details-layout a larger textRect() is returned to be aligned
392 // with the iconRect(). This is useful to have a larger selection/hover-area
393 // when having a quite large icon size but only one line of text. Still the
394 // focus rectangle should be shown as narrow as possible around the text.
396 const_cast<KStandardItemListWidget
*>(this)->triggerCacheRefreshing();
399 case CompactLayout
: {
400 QRectF rect
= m_textRect
;
401 const TextInfo
* topText
= m_textInfo
.value(m_sortedVisibleRoles
.first());
402 const TextInfo
* bottomText
= m_textInfo
.value(m_sortedVisibleRoles
.last());
403 rect
.setTop(topText
->pos
.y());
404 rect
.setBottom(bottomText
->pos
.y() + bottomText
->staticText
.size().height());
408 case DetailsLayout
: {
409 QRectF rect
= m_textRect
;
410 const TextInfo
* textInfo
= m_textInfo
.value(m_sortedVisibleRoles
.first());
411 rect
.setTop(textInfo
->pos
.y());
412 rect
.setBottom(textInfo
->pos
.y() + textInfo
->staticText
.size().height());
414 const KItemListStyleOption
& option
= styleOption();
415 if (option
.extendedSelectionRegion
) {
416 const QString text
= textInfo
->staticText
.text();
417 rect
.setWidth(m_customizedFontMetrics
.width(text
) + 2 * option
.padding
);
430 QRectF
KStandardItemListWidget::expansionToggleRect() const
432 const_cast<KStandardItemListWidget
*>(this)->triggerCacheRefreshing();
433 return m_isExpandable
? m_expansionArea
: QRectF();
436 QRectF
KStandardItemListWidget::selectionToggleRect() const
438 const_cast<KStandardItemListWidget
*>(this)->triggerCacheRefreshing();
440 const int iconHeight
= styleOption().iconSize
;
442 int toggleSize
= KIconLoader::SizeSmall
;
443 if (iconHeight
>= KIconLoader::SizeEnormous
) {
444 toggleSize
= KIconLoader::SizeMedium
;
445 } else if (iconHeight
>= KIconLoader::SizeLarge
) {
446 toggleSize
= KIconLoader::SizeSmallMedium
;
449 QPointF pos
= iconRect().topLeft();
451 // If the selection toggle has a very small distance to the
452 // widget borders, the size of the selection toggle will get
453 // increased to prevent an accidental clicking of the item
454 // when trying to hit the toggle.
455 const int widgetHeight
= size().height();
456 const int widgetWidth
= size().width();
457 const int minMargin
= 2;
459 if (toggleSize
+ minMargin
* 2 >= widgetHeight
) {
460 pos
.rx() -= (widgetHeight
- toggleSize
) / 2;
461 toggleSize
= widgetHeight
;
464 if (toggleSize
+ minMargin
* 2 >= widgetWidth
) {
465 pos
.ry() -= (widgetWidth
- toggleSize
) / 2;
466 toggleSize
= widgetWidth
;
470 return QRectF(pos
, QSizeF(toggleSize
, toggleSize
));
473 QPixmap
KStandardItemListWidget::createDragPixmap(const QStyleOptionGraphicsItem
* option
,
476 QPixmap pixmap
= KItemListWidget::createDragPixmap(option
, widget
);
477 if (m_layout
!= DetailsLayout
) {
481 // Only return the content of the text-column as pixmap
482 const int leftClip
= m_pixmapPos
.x();
484 const TextInfo
* textInfo
= m_textInfo
.value("text");
485 const int rightClip
= textInfo
->pos
.x() +
486 textInfo
->staticText
.size().width() +
487 2 * styleOption().padding
;
489 QPixmap
clippedPixmap(rightClip
- leftClip
+ 1, pixmap
.height());
490 clippedPixmap
.fill(Qt::transparent
);
492 QPainter
painter(&clippedPixmap
);
493 painter
.drawPixmap(-leftClip
, 0, pixmap
);
495 return clippedPixmap
;
499 KItemListWidgetInformant
* KStandardItemListWidget::createInformant()
501 return new KStandardItemListWidgetInformant();
504 void KStandardItemListWidget::invalidateCache()
506 m_dirtyLayout
= true;
507 m_dirtyContent
= true;
510 void KStandardItemListWidget::refreshCache()
514 bool KStandardItemListWidget::isRoleRightAligned(const QByteArray
& role
) const
520 bool KStandardItemListWidget::isHidden() const
525 QFont
KStandardItemListWidget::customizedFont(const QFont
& baseFont
) const
530 QPalette::ColorRole
KStandardItemListWidget::normalTextColorRole() const
532 return QPalette::Text
;
535 void KStandardItemListWidget::setTextColor(const QColor
& color
)
537 if (color
!= m_customTextColor
) {
538 m_customTextColor
= color
;
539 updateAdditionalInfoTextColor();
544 QColor
KStandardItemListWidget::textColor() const
548 return m_additionalInfoTextColor
;
549 } else if (m_customTextColor
.isValid()) {
550 return m_customTextColor
;
554 const QPalette::ColorGroup group
= isActiveWindow() ? QPalette::Active
: QPalette::Inactive
;
555 const QPalette::ColorRole role
= isSelected() ? QPalette::HighlightedText
: normalTextColorRole();
556 return styleOption().palette
.color(group
, role
);
559 void KStandardItemListWidget::setOverlay(const QPixmap
& overlay
)
562 m_dirtyContent
= true;
566 QPixmap
KStandardItemListWidget::overlay() const
572 QString
KStandardItemListWidget::roleText(const QByteArray
& role
,
573 const QHash
<QByteArray
, QVariant
>& values
) const
575 return static_cast<const KStandardItemListWidgetInformant
*>(informant())->roleText(role
, values
);
578 void KStandardItemListWidget::dataChanged(const QHash
<QByteArray
, QVariant
>& current
,
579 const QSet
<QByteArray
>& roles
)
583 m_dirtyContent
= true;
585 QSet
<QByteArray
> dirtyRoles
;
586 if (roles
.isEmpty()) {
587 dirtyRoles
= visibleRoles().toSet();
592 // The icon-state might depend from other roles and hence is
593 // marked as dirty whenever a role has been changed
594 dirtyRoles
.insert("iconPixmap");
595 dirtyRoles
.insert("iconName");
597 QSetIterator
<QByteArray
> it(dirtyRoles
);
598 while (it
.hasNext()) {
599 const QByteArray
& role
= it
.next();
600 m_dirtyContentRoles
.insert(role
);
604 void KStandardItemListWidget::visibleRolesChanged(const QList
<QByteArray
>& current
,
605 const QList
<QByteArray
>& previous
)
608 m_sortedVisibleRoles
= current
;
609 m_dirtyLayout
= true;
612 void KStandardItemListWidget::columnWidthChanged(const QByteArray
& role
,
619 m_dirtyLayout
= true;
622 void KStandardItemListWidget::styleOptionChanged(const KItemListStyleOption
& current
,
623 const KItemListStyleOption
& previous
)
627 updateAdditionalInfoTextColor();
628 m_dirtyLayout
= true;
631 void KStandardItemListWidget::hoveredChanged(bool hovered
)
634 m_dirtyLayout
= true;
637 void KStandardItemListWidget::selectedChanged(bool selected
)
640 updateAdditionalInfoTextColor();
641 m_dirtyContent
= true;
644 void KStandardItemListWidget::siblingsInformationChanged(const QBitArray
& current
, const QBitArray
& previous
)
648 m_dirtyLayout
= true;
651 int KStandardItemListWidget::selectionLength(const QString
& text
) const
653 return text
.length();
656 void KStandardItemListWidget::editedRoleChanged(const QByteArray
& current
, const QByteArray
& previous
)
660 QGraphicsView
* parent
= scene()->views()[0];
661 if (current
.isEmpty() || !parent
|| current
!= "text") {
663 emit
roleEditingCanceled(index(), current
, data().value(current
));
665 disconnect(m_roleEditor
, SIGNAL(roleEditingCanceled(QByteArray
,QVariant
)),
666 this, SLOT(slotRoleEditingCanceled(QByteArray
,QVariant
)));
667 disconnect(m_roleEditor
, SIGNAL(roleEditingFinished(QByteArray
,QVariant
)),
668 this, SLOT(slotRoleEditingFinished(QByteArray
,QVariant
)));
670 if (m_oldRoleEditor
) {
671 m_oldRoleEditor
->deleteLater();
673 m_oldRoleEditor
= m_roleEditor
;
674 m_roleEditor
->hide();
680 Q_ASSERT(!m_roleEditor
);
682 const TextInfo
* textInfo
= m_textInfo
.value("text");
684 m_roleEditor
= new KItemListRoleEditor(parent
);
685 m_roleEditor
->setRole(current
);
686 m_roleEditor
->setFont(styleOption().font
);
688 const QString text
= data().value(current
).toString();
689 m_roleEditor
->setPlainText(text
);
691 QTextOption textOption
= textInfo
->staticText
.textOption();
692 m_roleEditor
->document()->setDefaultTextOption(textOption
);
694 const int textSelectionLength
= selectionLength(text
);
696 if (textSelectionLength
> 0) {
697 QTextCursor cursor
= m_roleEditor
->textCursor();
698 cursor
.movePosition(QTextCursor::StartOfBlock
);
699 cursor
.movePosition(QTextCursor::NextCharacter
, QTextCursor::KeepAnchor
, textSelectionLength
);
700 m_roleEditor
->setTextCursor(cursor
);
703 connect(m_roleEditor
, SIGNAL(roleEditingCanceled(QByteArray
,QVariant
)),
704 this, SLOT(slotRoleEditingCanceled(QByteArray
,QVariant
)));
705 connect(m_roleEditor
, SIGNAL(roleEditingFinished(QByteArray
,QVariant
)),
706 this, SLOT(slotRoleEditingFinished(QByteArray
,QVariant
)));
708 // Adjust the geometry of the editor
709 QRectF rect
= roleEditingRect(current
);
710 const int frameWidth
= m_roleEditor
->frameWidth();
711 rect
.adjust(-frameWidth
, -frameWidth
, frameWidth
, frameWidth
);
712 rect
.translate(pos());
713 if (rect
.right() > parent
->width()) {
714 rect
.setWidth(parent
->width() - rect
.left());
716 m_roleEditor
->setGeometry(rect
.toRect());
717 m_roleEditor
->show();
718 m_roleEditor
->setFocus();
721 void KStandardItemListWidget::resizeEvent(QGraphicsSceneResizeEvent
* event
)
724 setEditedRole(QByteArray());
725 Q_ASSERT(!m_roleEditor
);
728 KItemListWidget::resizeEvent(event
);
730 m_dirtyLayout
= true;
733 void KStandardItemListWidget::showEvent(QShowEvent
* event
)
735 KItemListWidget::showEvent(event
);
737 // Listen to changes of the clipboard to mark the item as cut/uncut
738 KFileItemClipboard
* clipboard
= KFileItemClipboard::instance();
740 const KUrl itemUrl
= data().value("url").value
<KUrl
>();
741 m_isCut
= clipboard
->isCut(itemUrl
);
743 connect(clipboard
, SIGNAL(cutItemsChanged()),
744 this, SLOT(slotCutItemsChanged()));
747 void KStandardItemListWidget::hideEvent(QHideEvent
* event
)
749 disconnect(KFileItemClipboard::instance(), SIGNAL(cutItemsChanged()),
750 this, SLOT(slotCutItemsChanged()));
752 KItemListWidget::hideEvent(event
);
755 void KStandardItemListWidget::slotCutItemsChanged()
757 const KUrl itemUrl
= data().value("url").value
<KUrl
>();
758 const bool isCut
= KFileItemClipboard::instance()->isCut(itemUrl
);
759 if (m_isCut
!= isCut
) {
761 m_pixmap
= QPixmap();
762 m_dirtyContent
= true;
767 void KStandardItemListWidget::slotRoleEditingCanceled(const QByteArray
& role
,
768 const QVariant
& value
)
771 emit
roleEditingCanceled(index(), role
, value
);
772 setEditedRole(QByteArray());
775 void KStandardItemListWidget::slotRoleEditingFinished(const QByteArray
& role
,
776 const QVariant
& value
)
779 emit
roleEditingFinished(index(), role
, value
);
780 setEditedRole(QByteArray());
783 void KStandardItemListWidget::triggerCacheRefreshing()
785 if ((!m_dirtyContent
&& !m_dirtyLayout
) || index() < 0) {
791 const QHash
<QByteArray
, QVariant
> values
= data();
792 m_isExpandable
= m_supportsItemExpanding
&& values
["isExpandable"].toBool();
793 m_isHidden
= isHidden();
794 m_customizedFont
= customizedFont(styleOption().font
);
795 m_customizedFontMetrics
= QFontMetrics(m_customizedFont
);
797 updateExpansionArea();
801 m_dirtyLayout
= false;
802 m_dirtyContent
= false;
803 m_dirtyContentRoles
.clear();
806 void KStandardItemListWidget::updateExpansionArea()
808 if (m_supportsItemExpanding
) {
809 const QHash
<QByteArray
, QVariant
> values
= data();
810 const int expandedParentsCount
= values
.value("expandedParentsCount", 0).toInt();
811 if (expandedParentsCount
>= 0) {
812 const KItemListStyleOption
& option
= styleOption();
813 const qreal widgetHeight
= size().height();
814 const qreal inc
= (widgetHeight
- option
.iconSize
) / 2;
815 const qreal x
= expandedParentsCount
* widgetHeight
+ inc
;
817 m_expansionArea
= QRectF(x
, y
, option
.iconSize
, option
.iconSize
);
822 m_expansionArea
= QRectF();
825 void KStandardItemListWidget::updatePixmapCache()
827 // Precondition: Requires already updated m_textPos values to calculate
828 // the remaining height when the alignment is vertical.
830 const QSizeF widgetSize
= size();
831 const bool iconOnTop
= (m_layout
== IconsLayout
);
832 const KItemListStyleOption
& option
= styleOption();
833 const qreal padding
= option
.padding
;
835 const int maxIconWidth
= iconOnTop
? widgetSize
.width() - 2 * padding
: option
.iconSize
;
836 const int maxIconHeight
= option
.iconSize
;
838 const QHash
<QByteArray
, QVariant
> values
= data();
840 bool updatePixmap
= (m_pixmap
.width() != maxIconWidth
|| m_pixmap
.height() != maxIconHeight
);
841 if (!updatePixmap
&& m_dirtyContent
) {
842 updatePixmap
= m_dirtyContentRoles
.isEmpty()
843 || m_dirtyContentRoles
.contains("iconPixmap")
844 || m_dirtyContentRoles
.contains("iconName")
845 || m_dirtyContentRoles
.contains("iconOverlays");
849 m_pixmap
= values
["iconPixmap"].value
<QPixmap
>();
850 if (m_pixmap
.isNull()) {
851 // Use the icon that fits to the MIME-type
852 QString iconName
= values
["iconName"].toString();
853 if (iconName
.isEmpty()) {
854 // The icon-name has not been not resolved by KFileItemModelRolesUpdater,
855 // use a generic icon as fallback
856 iconName
= QLatin1String("unknown");
858 const QStringList overlays
= values
["iconOverlays"].toStringList();
859 m_pixmap
= pixmapForIcon(iconName
, overlays
, maxIconHeight
);
860 } else if (m_pixmap
.width() != maxIconWidth
|| m_pixmap
.height() != maxIconHeight
) {
861 // A custom pixmap has been applied. Assure that the pixmap
862 // is scaled to the maximum available size.
863 KPixmapModifier::scale(m_pixmap
, QSize(maxIconWidth
, maxIconHeight
));
867 KIconEffect
* effect
= KIconLoader::global()->iconEffect();
868 m_pixmap
= effect
->apply(m_pixmap
, KIconLoader::Desktop
, KIconLoader::DisabledState
);
872 KIconEffect::semiTransparent(m_pixmap
);
876 const QColor color
= palette().brush(QPalette::Normal
, QPalette::Highlight
).color();
877 QImage image
= m_pixmap
.toImage();
878 KIconEffect::colorize(image
, color
, 0.8f
);
879 m_pixmap
= QPixmap::fromImage(image
);
883 if (!m_overlay
.isNull()) {
884 QPainter
painter(&m_pixmap
);
885 painter
.drawPixmap(0, m_pixmap
.height() - m_overlay
.height(), m_overlay
);
888 int scaledIconSize
= 0;
890 const TextInfo
* textInfo
= m_textInfo
.value("text");
891 scaledIconSize
= static_cast<int>(textInfo
->pos
.y() - 2 * padding
);
893 const int textRowsCount
= (m_layout
== CompactLayout
) ? visibleRoles().count() : 1;
894 const qreal requiredTextHeight
= textRowsCount
* m_customizedFontMetrics
.height();
895 scaledIconSize
= (requiredTextHeight
< maxIconHeight
) ?
896 widgetSize
.height() - 2 * padding
: maxIconHeight
;
899 const int maxScaledIconWidth
= iconOnTop
? widgetSize
.width() - 2 * padding
: scaledIconSize
;
900 const int maxScaledIconHeight
= scaledIconSize
;
902 m_scaledPixmapSize
= m_pixmap
.size();
903 m_scaledPixmapSize
.scale(maxScaledIconWidth
, maxScaledIconHeight
, Qt::KeepAspectRatio
);
906 // Center horizontally and align on bottom within the icon-area
907 m_pixmapPos
.setX((widgetSize
.width() - m_scaledPixmapSize
.width()) / 2);
908 m_pixmapPos
.setY(padding
+ scaledIconSize
- m_scaledPixmapSize
.height());
910 // Center horizontally and vertically within the icon-area
911 const TextInfo
* textInfo
= m_textInfo
.value("text");
912 m_pixmapPos
.setX(textInfo
->pos
.x() - 2 * padding
913 - (scaledIconSize
+ m_scaledPixmapSize
.width()) / 2);
914 m_pixmapPos
.setY(padding
915 + (scaledIconSize
- m_scaledPixmapSize
.height()) / 2);
918 m_iconRect
= QRectF(m_pixmapPos
, QSizeF(m_scaledPixmapSize
));
920 // Prepare the pixmap that is used when the item gets hovered
922 m_hoverPixmap
= m_pixmap
;
923 KIconEffect
* effect
= KIconLoader::global()->iconEffect();
924 // In the KIconLoader terminology, active = hover.
925 if (effect
->hasEffect(KIconLoader::Desktop
, KIconLoader::ActiveState
)) {
926 m_hoverPixmap
= effect
->apply(m_pixmap
, KIconLoader::Desktop
, KIconLoader::ActiveState
);
928 m_hoverPixmap
= m_pixmap
;
930 } else if (hoverOpacity() <= 0.0) {
931 // No hover animation is ongoing. Clear m_hoverPixmap to save memory.
932 m_hoverPixmap
= QPixmap();
936 void KStandardItemListWidget::updateTextsCache()
938 QTextOption textOption
;
941 textOption
.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere
);
942 textOption
.setAlignment(Qt::AlignHCenter
);
946 textOption
.setAlignment(Qt::AlignLeft
);
947 textOption
.setWrapMode(QTextOption::NoWrap
);
954 qDeleteAll(m_textInfo
);
956 for (int i
= 0; i
< m_sortedVisibleRoles
.count(); ++i
) {
957 TextInfo
* textInfo
= new TextInfo();
958 textInfo
->staticText
.setTextFormat(Qt::PlainText
);
959 textInfo
->staticText
.setPerformanceHint(QStaticText::AggressiveCaching
);
960 textInfo
->staticText
.setTextOption(textOption
);
961 m_textInfo
.insert(m_sortedVisibleRoles
[i
], textInfo
);
965 case IconsLayout
: updateIconsLayoutTextCache(); break;
966 case CompactLayout
: updateCompactLayoutTextCache(); break;
967 case DetailsLayout
: updateDetailsLayoutTextCache(); break;
968 default: Q_ASSERT(false); break;
971 const TextInfo
* ratingTextInfo
= m_textInfo
.value("rating");
972 if (ratingTextInfo
) {
973 // The text of the rating-role has been set to empty to get
974 // replaced by a rating-image showing the rating as stars.
975 const KItemListStyleOption
& option
= styleOption();
976 QSizeF ratingSize
= preferredRatingSize(option
);
978 const qreal availableWidth
= (m_layout
== DetailsLayout
)
979 ? columnWidth("rating") - columnPadding(option
)
981 if (ratingSize
.width() > availableWidth
) {
982 ratingSize
.rwidth() = availableWidth
;
984 m_rating
= QPixmap(ratingSize
.toSize());
985 m_rating
.fill(Qt::transparent
);
987 QPainter
painter(&m_rating
);
988 const QRect
rect(0, 0, m_rating
.width(), m_rating
.height());
989 const int rating
= data().value("rating").toInt();
990 KRatingPainter::paintRating(&painter
, rect
, Qt::AlignJustify
| Qt::AlignVCenter
, rating
);
991 } else if (!m_rating
.isNull()) {
992 m_rating
= QPixmap();
996 void KStandardItemListWidget::updateIconsLayoutTextCache()
1003 // might get wrapped above
1005 // Additional role 1
1006 // Additional role 2
1008 const QHash
<QByteArray
, QVariant
> values
= data();
1010 const KItemListStyleOption
& option
= styleOption();
1011 const qreal padding
= option
.padding
;
1012 const qreal maxWidth
= size().width() - 2 * padding
;
1013 const qreal widgetHeight
= size().height();
1014 const qreal lineSpacing
= m_customizedFontMetrics
.lineSpacing();
1016 // Initialize properties for the "text" role. It will be used as anchor
1017 // for initializing the position of the other roles.
1018 TextInfo
* nameTextInfo
= m_textInfo
.value("text");
1019 const QString nameText
= KStringHandler::preProcessWrap(values
["text"].toString());
1020 nameTextInfo
->staticText
.setText(nameText
);
1022 // Calculate the number of lines required for the name and the required width
1023 qreal nameWidth
= 0;
1024 qreal nameHeight
= 0;
1027 const int additionalRolesCount
= qMax(visibleRoles().count() - 1, 0);
1028 const int maxNameLines
= (option
.maxTextSize
.height() / int(lineSpacing
)) - additionalRolesCount
;
1030 QTextLayout
layout(nameTextInfo
->staticText
.text(), m_customizedFont
);
1031 layout
.setTextOption(nameTextInfo
->staticText
.textOption());
1032 layout
.beginLayout();
1033 int nameLineIndex
= 0;
1034 while ((line
= layout
.createLine()).isValid()) {
1035 line
.setLineWidth(maxWidth
);
1036 nameWidth
= qMax(nameWidth
, line
.naturalTextWidth());
1037 nameHeight
+= line
.height();
1040 if (nameLineIndex
== maxNameLines
) {
1041 // The maximum number of textlines has been reached. If this is
1042 // the case provide an elided text if necessary.
1043 const int textLength
= line
.textStart() + line
.textLength();
1044 if (textLength
< nameText
.length()) {
1045 // Elide the last line of the text
1046 QString lastTextLine
= nameText
.mid(line
.textStart());
1047 lastTextLine
= m_customizedFontMetrics
.elidedText(lastTextLine
,
1050 const QString elidedText
= nameText
.left(line
.textStart()) + lastTextLine
;
1051 nameTextInfo
->staticText
.setText(elidedText
);
1053 const qreal lastLineWidth
= m_customizedFontMetrics
.boundingRect(lastTextLine
).width();
1054 nameWidth
= qMax(nameWidth
, lastLineWidth
);
1061 // Use one line for each additional information
1062 nameTextInfo
->staticText
.setTextWidth(maxWidth
);
1063 nameTextInfo
->pos
= QPointF(padding
, widgetHeight
-
1065 additionalRolesCount
* lineSpacing
-
1067 m_textRect
= QRectF(padding
+ (maxWidth
- nameWidth
) / 2,
1068 nameTextInfo
->pos
.y(),
1072 // Calculate the position for each additional information
1073 qreal y
= nameTextInfo
->pos
.y() + nameHeight
;
1074 foreach (const QByteArray
& role
, m_sortedVisibleRoles
) {
1075 if (role
== "text") {
1079 const QString text
= roleText(role
, values
);
1080 TextInfo
* textInfo
= m_textInfo
.value(role
);
1081 textInfo
->staticText
.setText(text
);
1083 qreal requiredWidth
= 0;
1085 QTextLayout
layout(text
, m_customizedFont
);
1086 QTextOption textOption
;
1087 textOption
.setWrapMode(QTextOption::NoWrap
);
1088 layout
.setTextOption(textOption
);
1090 layout
.beginLayout();
1091 QTextLine textLine
= layout
.createLine();
1092 if (textLine
.isValid()) {
1093 textLine
.setLineWidth(maxWidth
);
1094 requiredWidth
= textLine
.naturalTextWidth();
1095 if (requiredWidth
> maxWidth
) {
1096 const QString elidedText
= m_customizedFontMetrics
.elidedText(text
, Qt::ElideRight
, maxWidth
);
1097 textInfo
->staticText
.setText(elidedText
);
1098 requiredWidth
= m_customizedFontMetrics
.width(elidedText
);
1099 } else if (role
== "rating") {
1100 // Use the width of the rating pixmap, because the rating text is empty.
1101 requiredWidth
= m_rating
.width();
1106 textInfo
->pos
= QPointF(padding
, y
);
1107 textInfo
->staticText
.setTextWidth(maxWidth
);
1109 const QRectF
textRect(padding
+ (maxWidth
- requiredWidth
) / 2, y
, requiredWidth
, lineSpacing
);
1110 m_textRect
|= textRect
;
1115 // Add a padding to the text rectangle
1116 m_textRect
.adjust(-padding
, -padding
, padding
, padding
);
1119 void KStandardItemListWidget::updateCompactLayoutTextCache()
1121 // +------+ Name role
1122 // | Icon | Additional role 1
1123 // +------+ Additional role 2
1125 const QHash
<QByteArray
, QVariant
> values
= data();
1127 const KItemListStyleOption
& option
= styleOption();
1128 const qreal widgetHeight
= size().height();
1129 const qreal lineSpacing
= m_customizedFontMetrics
.lineSpacing();
1130 const qreal textLinesHeight
= qMax(visibleRoles().count(), 1) * lineSpacing
;
1131 const int scaledIconSize
= (textLinesHeight
< option
.iconSize
) ? widgetHeight
- 2 * option
.padding
: option
.iconSize
;
1133 qreal maximumRequiredTextWidth
= 0;
1134 const qreal x
= option
.padding
* 3 + scaledIconSize
;
1135 qreal y
= qRound((widgetHeight
- textLinesHeight
) / 2);
1136 const qreal maxWidth
= size().width() - x
- option
.padding
;
1137 foreach (const QByteArray
& role
, m_sortedVisibleRoles
) {
1138 const QString text
= roleText(role
, values
);
1139 TextInfo
* textInfo
= m_textInfo
.value(role
);
1140 textInfo
->staticText
.setText(text
);
1142 qreal requiredWidth
= m_customizedFontMetrics
.width(text
);
1143 if (requiredWidth
> maxWidth
) {
1144 requiredWidth
= maxWidth
;
1145 const QString elidedText
= m_customizedFontMetrics
.elidedText(text
, Qt::ElideRight
, maxWidth
);
1146 textInfo
->staticText
.setText(elidedText
);
1149 textInfo
->pos
= QPointF(x
, y
);
1150 textInfo
->staticText
.setTextWidth(maxWidth
);
1152 maximumRequiredTextWidth
= qMax(maximumRequiredTextWidth
, requiredWidth
);
1157 m_textRect
= QRectF(x
- 2 * option
.padding
, 0, maximumRequiredTextWidth
+ 3 * option
.padding
, widgetHeight
);
1160 void KStandardItemListWidget::updateDetailsLayoutTextCache()
1162 // Precondition: Requires already updated m_expansionArea
1163 // to determine the left position.
1166 // | Icon | Name role Additional role 1 Additional role 2
1168 m_textRect
= QRectF();
1170 const KItemListStyleOption
& option
= styleOption();
1171 const QHash
<QByteArray
, QVariant
> values
= data();
1173 const qreal widgetHeight
= size().height();
1174 const int scaledIconSize
= widgetHeight
- 2 * option
.padding
;
1175 const int fontHeight
= m_customizedFontMetrics
.height();
1177 const qreal columnWidthInc
= columnPadding(option
);
1178 qreal firstColumnInc
= scaledIconSize
;
1179 if (m_supportsItemExpanding
) {
1180 firstColumnInc
+= (m_expansionArea
.left() + m_expansionArea
.right() + widgetHeight
) / 2;
1182 firstColumnInc
+= option
.padding
;
1185 qreal x
= firstColumnInc
;
1186 const qreal y
= qMax(qreal(option
.padding
), (widgetHeight
- fontHeight
) / 2);
1188 foreach (const QByteArray
& role
, m_sortedVisibleRoles
) {
1189 QString text
= roleText(role
, values
);
1191 // Elide the text in case it does not fit into the available column-width
1192 qreal requiredWidth
= m_customizedFontMetrics
.width(text
);
1193 const qreal roleWidth
= columnWidth(role
);
1194 qreal availableTextWidth
= roleWidth
- columnWidthInc
;
1196 const bool isTextRole
= (role
== "text");
1198 availableTextWidth
-= firstColumnInc
;
1201 if (requiredWidth
> availableTextWidth
) {
1202 text
= m_customizedFontMetrics
.elidedText(text
, Qt::ElideRight
, availableTextWidth
);
1203 requiredWidth
= m_customizedFontMetrics
.width(text
);
1206 TextInfo
* textInfo
= m_textInfo
.value(role
);
1207 textInfo
->staticText
.setText(text
);
1208 textInfo
->pos
= QPointF(x
+ columnWidthInc
/ 2, y
);
1212 const qreal textWidth
= option
.extendedSelectionRegion
1213 ? size().width() - textInfo
->pos
.x()
1214 : requiredWidth
+ 2 * option
.padding
;
1215 m_textRect
= QRectF(textInfo
->pos
.x() - 2 * option
.padding
, 0,
1216 textWidth
+ option
.padding
, size().height());
1218 // The column after the name should always be aligned on the same x-position independent
1219 // from the expansion-level shown in the name column
1220 x
-= firstColumnInc
;
1221 } else if (isRoleRightAligned(role
)) {
1222 textInfo
->pos
.rx() += roleWidth
- requiredWidth
- columnWidthInc
;
1227 void KStandardItemListWidget::updateAdditionalInfoTextColor()
1230 if (m_customTextColor
.isValid()) {
1231 c1
= m_customTextColor
;
1232 } else if (isSelected() && m_layout
!= DetailsLayout
) {
1233 c1
= styleOption().palette
.highlightedText().color();
1235 c1
= styleOption().palette
.text().color();
1238 // For the color of the additional info the inactive text color
1239 // is not used as this might lead to unreadable text for some color schemes. Instead
1240 // the text color c1 is slightly mixed with the background color.
1241 const QColor c2
= styleOption().palette
.base().color();
1243 const int p2
= 100 - p1
;
1244 m_additionalInfoTextColor
= QColor((c1
.red() * p1
+ c2
.red() * p2
) / 100,
1245 (c1
.green() * p1
+ c2
.green() * p2
) / 100,
1246 (c1
.blue() * p1
+ c2
.blue() * p2
) / 100);
1249 void KStandardItemListWidget::drawPixmap(QPainter
* painter
, const QPixmap
& pixmap
)
1251 if (m_scaledPixmapSize
!= pixmap
.size()) {
1252 QPixmap scaledPixmap
= pixmap
;
1253 KPixmapModifier::scale(scaledPixmap
, m_scaledPixmapSize
);
1254 painter
->drawPixmap(m_pixmapPos
, scaledPixmap
);
1256 #ifdef KSTANDARDITEMLISTWIDGET_DEBUG
1257 painter
->setPen(Qt::blue
);
1258 painter
->drawRect(QRectF(m_pixmapPos
, QSizeF(m_scaledPixmapSize
)));
1261 painter
->drawPixmap(m_pixmapPos
, pixmap
);
1265 void KStandardItemListWidget::drawSiblingsInformation(QPainter
* painter
)
1267 const int siblingSize
= size().height();
1268 const int x
= (m_expansionArea
.left() + m_expansionArea
.right() - siblingSize
) / 2;
1269 QRect
siblingRect(x
, 0, siblingSize
, siblingSize
);
1271 QStyleOption option
;
1272 option
.palette
.setColor(QPalette::Text
, option
.palette
.color(normalTextColorRole()));
1273 bool isItemSibling
= true;
1275 const QBitArray siblings
= siblingsInformation();
1276 for (int i
= siblings
.count() - 1; i
>= 0; --i
) {
1277 option
.rect
= siblingRect
;
1278 option
.state
= siblings
.at(i
) ? QStyle::State_Sibling
: QStyle::State_None
;
1280 if (isItemSibling
) {
1281 option
.state
|= QStyle::State_Item
;
1282 if (m_isExpandable
) {
1283 option
.state
|= QStyle::State_Children
;
1285 if (data()["isExpanded"].toBool()) {
1286 option
.state
|= QStyle::State_Open
;
1288 isItemSibling
= false;
1291 style()->drawPrimitive(QStyle::PE_IndicatorBranch
, &option
, painter
);
1293 siblingRect
.translate(-siblingRect
.width(), 0);
1297 QRectF
KStandardItemListWidget::roleEditingRect(const QByteArray
& role
) const
1299 const TextInfo
* textInfo
= m_textInfo
.value(role
);
1304 QRectF
rect(textInfo
->pos
, textInfo
->staticText
.size());
1305 if (m_layout
== DetailsLayout
) {
1306 rect
.setWidth(columnWidth(role
) - rect
.x());
1312 void KStandardItemListWidget::closeRoleEditor()
1314 disconnect(m_roleEditor
, SIGNAL(roleEditingCanceled(QByteArray
,QVariant
)),
1315 this, SLOT(slotRoleEditingCanceled(QByteArray
,QVariant
)));
1316 disconnect(m_roleEditor
, SIGNAL(roleEditingFinished(QByteArray
,QVariant
)),
1317 this, SLOT(slotRoleEditingFinished(QByteArray
,QVariant
)));
1319 if (m_roleEditor
->hasFocus()) {
1320 // If the editing was not ended by a FocusOut event, we have
1321 // to transfer the keyboard focus back to the KItemListContainer.
1322 scene()->views()[0]->parentWidget()->setFocus();
1325 if (m_oldRoleEditor
) {
1326 m_oldRoleEditor
->deleteLater();
1328 m_oldRoleEditor
= m_roleEditor
;
1329 m_roleEditor
->hide();
1333 QPixmap
KStandardItemListWidget::pixmapForIcon(const QString
& name
, const QStringList
& overlays
, int size
)
1335 const QString key
= "KStandardItemListWidget:" % name
% ":" % overlays
.join(":") % ":" % QString::number(size
);
1338 if (!QPixmapCache::find(key
, pixmap
)) {
1339 const KIcon
icon(name
);
1342 if (size
<= KIconLoader::SizeSmall
) {
1343 requestedSize
= KIconLoader::SizeSmall
;
1344 } else if (size
<= KIconLoader::SizeSmallMedium
) {
1345 requestedSize
= KIconLoader::SizeSmallMedium
;
1346 } else if (size
<= KIconLoader::SizeMedium
) {
1347 requestedSize
= KIconLoader::SizeMedium
;
1348 } else if (size
<= KIconLoader::SizeLarge
) {
1349 requestedSize
= KIconLoader::SizeLarge
;
1350 } else if (size
<= KIconLoader::SizeHuge
) {
1351 requestedSize
= KIconLoader::SizeHuge
;
1352 } else if (size
<= KIconLoader::SizeEnormous
) {
1353 requestedSize
= KIconLoader::SizeEnormous
;
1354 } else if (size
<= KIconLoader::SizeEnormous
* 2) {
1355 requestedSize
= KIconLoader::SizeEnormous
* 2;
1357 requestedSize
= size
;
1360 pixmap
= icon
.pixmap(requestedSize
, requestedSize
);
1361 if (requestedSize
!= size
) {
1362 KPixmapModifier::scale(pixmap
, QSize(size
, size
));
1365 // Strangely KFileItem::overlays() returns empty string-values, so
1366 // we need to check first whether an overlay must be drawn at all.
1367 // It is more efficient to do it here, as KIconLoader::drawOverlays()
1368 // assumes that an overlay will be drawn and has some additional
1370 foreach (const QString
& overlay
, overlays
) {
1371 if (!overlay
.isEmpty()) {
1372 // There is at least one overlay, draw all overlays above m_pixmap
1373 // and cancel the check
1374 KIconLoader::global()->drawOverlays(overlays
, pixmap
, KIconLoader::Desktop
);
1379 QPixmapCache::insert(key
, pixmap
);
1385 QSizeF
KStandardItemListWidget::preferredRatingSize(const KItemListStyleOption
& option
)
1387 const qreal height
= option
.fontMetrics
.ascent();
1388 return QSizeF(height
* 5, height
);
1391 qreal
KStandardItemListWidget::columnPadding(const KItemListStyleOption
& option
)
1393 return option
.padding
* 6;
1396 #include "kstandarditemlistwidget.moc"