1 /***************************************************************************
2 * Copyright (C) 2011 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 "kfileitemlistwidget.h"
22 #include "kfileitemmodel.h"
23 #include "kitemlistview.h"
24 #include "kpixmapmodifier_p.h"
27 #include <KIconEffect>
28 #include <KIconLoader>
30 #include <KStringHandler>
33 #include <QFontMetricsF>
34 #include <QGraphicsSceneResizeEvent>
36 #include <QStyleOption>
37 #include <QTextLayout>
40 //#define KFILEITEMLISTWIDGET_DEBUG
42 KFileItemListWidget::KFileItemListWidget(QGraphicsItem
* parent
) :
43 KItemListWidget(parent
),
47 m_dirtyContentRoles(),
48 m_layout(IconsLayout
),
57 m_sortedVisibleRoles(),
59 m_additionalInfoTextColor()
61 for (int i
= 0; i
< TextIdCount
; ++i
) {
62 m_text
[i
].setTextFormat(Qt::PlainText
);
63 m_text
[i
].setPerformanceHint(QStaticText::AggressiveCaching
);
67 KFileItemListWidget::~KFileItemListWidget()
71 void KFileItemListWidget::setLayout(Layout layout
)
73 if (m_layout
!= layout
) {
80 KFileItemListWidget::Layout
KFileItemListWidget::layout() const
85 void KFileItemListWidget::paint(QPainter
* painter
, const QStyleOptionGraphicsItem
* option
, QWidget
* widget
)
87 KItemListWidget::paint(painter
, option
, widget
);
89 if (m_dirtyContent
|| m_dirtyLayout
) {
90 const_cast<KFileItemListWidget
*>(this)->updateCache();
93 // Draw expansion toggle '>' or 'V'
94 if (m_isDir
&& !m_expansionArea
.isEmpty()) {
95 QStyleOption arrowOption
;
96 arrowOption
.rect
= m_expansionArea
.toRect();
97 const QStyle::PrimitiveElement arrow
= data()["isExpanded"].toBool()
98 ? QStyle::PE_IndicatorArrowDown
: QStyle::PE_IndicatorArrowRight
;
99 style()->drawPrimitive(arrow
, &arrowOption
, painter
);
102 const KItemListStyleOption
& itemListStyleOption
= styleOption();
104 // Blend the unhovered and hovered pixmap if the hovering
105 // animation is ongoing
106 if (hoverOpacity() < 1.0) {
107 drawPixmap(painter
, m_pixmap
);
110 const qreal opacity
= painter
->opacity();
111 painter
->setOpacity(hoverOpacity() * opacity
);
112 drawPixmap(painter
, m_hoverPixmap
);
113 painter
->setOpacity(opacity
);
115 drawPixmap(painter
, m_pixmap
);
118 painter
->setFont(itemListStyleOption
.font
);
119 painter
->setPen(itemListStyleOption
.palette
.text().color());
120 painter
->drawStaticText(m_textPos
[Name
], m_text
[Name
]);
122 painter
->setPen(m_additionalInfoTextColor
);
123 painter
->setFont(itemListStyleOption
.font
);
124 for (int i
= Name
+ 1; i
< TextIdCount
; ++i
) {
125 painter
->drawStaticText(m_textPos
[i
], m_text
[i
]);
128 #ifdef KFILEITEMLISTWIDGET_DEBUG
129 painter
->setPen(Qt::red
);
130 painter
->setBrush(Qt::NoBrush
);
131 painter
->drawText(QPointF(0, itemListStyleOption
.fontMetrics
.height()), QString::number(index()));
132 painter
->drawRect(rect());
136 QRectF
KFileItemListWidget::iconBoundingRect() const
138 QRectF bounds
= m_hoverPixmapRect
;
139 const qreal margin
= styleOption().margin
;
140 bounds
.adjust(-margin
, -margin
, margin
, margin
);
144 QRectF
KFileItemListWidget::textBoundingRect() const
146 return m_textBoundingRect
;
149 QRectF
KFileItemListWidget::expansionToggleRect() const
151 return m_isDir
? m_expansionArea
: QRectF();
154 void KFileItemListWidget::dataChanged(const QHash
<QByteArray
, QVariant
>& current
,
155 const QSet
<QByteArray
>& roles
)
157 KItemListWidget::dataChanged(current
, roles
);
158 m_dirtyContent
= true;
160 QSet
<QByteArray
> dirtyRoles
;
161 if (roles
.isEmpty()) {
162 dirtyRoles
= visibleRoles().keys().toSet();
163 dirtyRoles
.insert("iconPixmap");
164 dirtyRoles
.insert("iconName");
169 QSetIterator
<QByteArray
> it(dirtyRoles
);
170 while (it
.hasNext()) {
171 const QByteArray
& role
= it
.next();
172 m_dirtyContentRoles
.insert(role
);
176 void KFileItemListWidget::visibleRolesChanged(const QHash
<QByteArray
, int>& current
,
177 const QHash
<QByteArray
, int>& previous
)
179 KItemListWidget::visibleRolesChanged(current
, previous
);
180 m_dirtyLayout
= true;
182 // Cache the roles sorted into m_sortedVisibleRoles:
183 const int visibleRolesCount
= current
.count();
184 m_sortedVisibleRoles
.clear();
185 m_sortedVisibleRoles
.reserve(visibleRolesCount
);
186 for (int i
= 0; i
< visibleRolesCount
; ++i
) {
187 m_sortedVisibleRoles
.append(QByteArray());
190 QHashIterator
<QByteArray
, int> it(current
);
191 while (it
.hasNext()) {
194 const int index
= it
.value();
195 if (index
< 0 || index
>= visibleRolesCount
|| !m_sortedVisibleRoles
.at(index
).isEmpty()) {
196 kWarning() << "The visible roles have an invalid sort order.";
200 const QByteArray
& role
= it
.key();
201 m_sortedVisibleRoles
[index
] = role
;
205 void KFileItemListWidget::visibleRolesSizesChanged(const QHash
<QByteArray
, QSizeF
>& current
,
206 const QHash
<QByteArray
, QSizeF
>& previous
)
208 KItemListWidget::visibleRolesSizesChanged(current
, previous
);
209 m_dirtyLayout
= true;
212 void KFileItemListWidget::styleOptionChanged(const KItemListStyleOption
& current
,
213 const KItemListStyleOption
& previous
)
215 KItemListWidget::styleOptionChanged(current
, previous
);
217 // For the color of the additional info the inactive text color
218 // is not used as this might lead to unreadable text for some color schemes. Instead
219 // the text color is slightly mixed with the background color.
220 const QColor c1
= current
.palette
.text().color();
221 const QColor c2
= current
.palette
.background().color();
223 const int p2
= 100 - p1
;
224 m_additionalInfoTextColor
= QColor((c1
.red() * p1
+ c2
.red() * p2
) / 100,
225 (c1
.green() * p1
+ c2
.green() * p2
) / 100,
226 (c1
.blue() * p1
+ c2
.blue() * p2
) / 100);
228 m_dirtyLayout
= true;
231 void KFileItemListWidget::hoveredChanged(bool hovered
)
234 m_dirtyLayout
= true;
237 void KFileItemListWidget::resizeEvent(QGraphicsSceneResizeEvent
* event
)
239 KItemListWidget::resizeEvent(event
);
240 m_dirtyLayout
= true;
243 void KFileItemListWidget::updateCache()
249 m_isDir
= data()["isDir"].toBool();
251 updateExpansionArea();
255 m_dirtyLayout
= false;
256 m_dirtyContent
= false;
257 m_dirtyContentRoles
.clear();
260 void KFileItemListWidget::updateExpansionArea()
262 if (m_layout
== DetailsLayout
) {
263 const QHash
<QByteArray
, QVariant
> values
= data();
264 Q_ASSERT(values
.contains("expansionLevel"));
265 const KItemListStyleOption
& option
= styleOption();
266 const int expansionLevel
= values
.value("expansionLevel", 0).toInt();
268 const qreal widgetHeight
= size().height();
269 const qreal expansionLevelSize
= KIconLoader::SizeSmall
;
270 const qreal x
= option
.margin
+ expansionLevel
* widgetHeight
;
271 const qreal y
= (widgetHeight
- expansionLevelSize
) / 2;
272 m_expansionArea
= QRectF(x
, y
, expansionLevelSize
, expansionLevelSize
);
274 m_expansionArea
= QRectF();
278 void KFileItemListWidget::updatePixmapCache()
280 // Precondition: Requires already updated m_textPos values to calculate
281 // the remaining height when the alignment is vertical.
283 const bool iconOnTop
= (m_layout
== IconsLayout
);
284 const KItemListStyleOption
& option
= styleOption();
285 const int iconHeight
= option
.iconSize
;
287 const QHash
<QByteArray
, QVariant
> values
= data();
288 const QSizeF widgetSize
= size();
290 int scaledIconHeight
= 0;
292 scaledIconHeight
= static_cast<int>(m_textPos
[Name
].y() - 3 * option
.margin
);
294 const int textRowsCount
= (m_layout
== CompactLayout
) ? visibleRoles().count() : 1;
295 const qreal requiredTextHeight
= textRowsCount
* option
.fontMetrics
.height();
296 scaledIconHeight
= (requiredTextHeight
< iconHeight
) ? widgetSize
.height() - 2 * option
.margin
: iconHeight
;
299 bool updatePixmap
= (iconHeight
!= m_pixmap
.height());
300 if (!updatePixmap
&& m_dirtyContent
) {
301 updatePixmap
= m_dirtyContentRoles
.isEmpty()
302 || m_dirtyContentRoles
.contains("iconPixmap")
303 || m_dirtyContentRoles
.contains("iconName");
307 m_pixmap
= values
["iconPixmap"].value
<QPixmap
>();
308 if (m_pixmap
.isNull()) {
309 // Use the icon that fits to the MIME-type
310 QString iconName
= values
["iconName"].toString();
311 if (iconName
.isEmpty()) {
312 // The icon-name has not been not resolved by KFileItemModelRolesUpdater,
313 // use a generic icon as fallback
314 iconName
= QLatin1String("unknown");
316 m_pixmap
= pixmapForIcon(iconName
, iconHeight
);
317 m_hoverPixmapRect
.setSize(m_pixmap
.size());
318 } else if (m_pixmap
.size() != QSize(iconHeight
, iconHeight
)) {
319 // A custom pixmap has been applied. Assure that the pixmap
320 // is scaled to the available size.
321 const bool scale
= m_pixmap
.width() > iconHeight
|| m_pixmap
.height() > iconHeight
||
322 (m_pixmap
.width() < iconHeight
&& m_pixmap
.height() < iconHeight
);
324 KPixmapModifier::scale(m_pixmap
, QSize(iconHeight
, iconHeight
));
326 m_hoverPixmapRect
.setSize(m_pixmap
.size());
328 // To simplify the handling of scaling the original pixmap
329 // will be embedded into a square pixmap.
330 QPixmap
squarePixmap(iconHeight
, iconHeight
);
331 squarePixmap
.fill(Qt::transparent
);
333 QPainter
painter(&squarePixmap
);
335 const int x
= (iconHeight
- m_pixmap
.width()) / 2; // Center horizontally
336 const int y
= iconHeight
- m_pixmap
.height(); // Align on bottom
337 painter
.drawPixmap(x
, y
, m_pixmap
);
339 const int x
= iconHeight
- m_pixmap
.width(); // Align right
340 const int y
= (iconHeight
- m_pixmap
.height()) / 2; // Center vertically
341 painter
.drawPixmap(x
, y
, m_pixmap
);
344 m_pixmap
= squarePixmap
;
346 m_hoverPixmapRect
.setSize(m_pixmap
.size());
349 Q_ASSERT(m_pixmap
.height() == iconHeight
);
352 m_scaledPixmapSize
= QSize(scaledIconHeight
, scaledIconHeight
);
355 m_pixmapPos
.setX((widgetSize
.width() - m_scaledPixmapSize
.width()) / 2);
357 m_pixmapPos
.setX(m_textPos
[Name
].x() - 2 * option
.margin
- scaledIconHeight
);
359 m_pixmapPos
.setY(option
.margin
);
361 // Center the hover rectangle horizontally and align it on bottom
362 const qreal x
= m_pixmapPos
.x() + (m_scaledPixmapSize
.width() - m_hoverPixmapRect
.width()) / 2.0;
363 const qreal y
= m_pixmapPos
.y() + m_scaledPixmapSize
.height() - m_hoverPixmapRect
.height();
364 m_hoverPixmapRect
.moveTopLeft(QPointF(x
, y
));
366 // Prepare the pixmap that is used when the item gets hovered
368 m_hoverPixmap
= m_pixmap
;
369 KIconEffect
* effect
= KIconLoader::global()->iconEffect();
370 // In the KIconLoader terminology, active = hover.
371 if (effect
->hasEffect(KIconLoader::Desktop
, KIconLoader::ActiveState
)) {
372 m_hoverPixmap
= effect
->apply(m_pixmap
, KIconLoader::Desktop
, KIconLoader::ActiveState
);
374 m_hoverPixmap
= m_pixmap
;
376 } else if (hoverOpacity() <= 0.0) {
377 // No hover animation is ongoing. Clear m_hoverPixmap to save memory.
378 m_hoverPixmap
= QPixmap();
382 void KFileItemListWidget::updateTextsCache()
384 QTextOption textOption
;
387 textOption
.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere
);
388 textOption
.setAlignment(Qt::AlignHCenter
);
392 textOption
.setAlignment(Qt::AlignLeft
);
393 textOption
.setWrapMode(QTextOption::NoWrap
);
400 for (int i
= 0; i
< TextIdCount
; ++i
) {
401 m_text
[i
].setText(QString());
402 m_text
[i
].setTextOption(textOption
);
406 case IconsLayout
: updateIconsLayoutTextCache(); break;
407 case CompactLayout
: updateCompactLayoutTextCache(); break;
408 case DetailsLayout
: updateDetailsLayoutTextCache(); break;
409 default: Q_ASSERT(false); break;
413 void KFileItemListWidget::updateIconsLayoutTextCache()
420 // might get wrapped above
425 const QHash
<QByteArray
, QVariant
> values
= data();
427 const KItemListStyleOption
& option
= styleOption();
428 const qreal maxWidth
= size().width() - 2 * option
.margin
;
429 const qreal widgetHeight
= size().height();
430 const qreal fontHeight
= option
.fontMetrics
.height();
432 // Initialize properties for the "name" role. It will be used as anchor
433 // for initializing the position of the other roles.
434 m_text
[Name
].setText(KStringHandler::preProcessWrap(values
["name"].toString()));
436 // Calculate the number of lines required for the name and the required width
437 int textLinesCountForName
= 0;
438 qreal requiredWidthForName
= 0;
441 QTextLayout
layout(m_text
[Name
].text(), option
.font
);
442 layout
.setTextOption(m_text
[Name
].textOption());
443 layout
.beginLayout();
444 while ((line
= layout
.createLine()).isValid()) {
445 line
.setLineWidth(maxWidth
);
446 requiredWidthForName
= qMax(requiredWidthForName
, line
.naturalTextWidth());
447 ++textLinesCountForName
;
451 // Use one line for each additional information
452 int textLinesCount
= textLinesCountForName
;
453 const int additionalRolesCount
= qMax(visibleRoles().count() - 1, 0);
454 textLinesCount
+= additionalRolesCount
;
456 m_text
[Name
].setTextWidth(maxWidth
);
457 m_textPos
[Name
] = QPointF(option
.margin
, widgetHeight
- textLinesCount
* fontHeight
- option
.margin
);
458 m_textBoundingRect
= QRectF(option
.margin
+ (maxWidth
- requiredWidthForName
) / 2,
460 requiredWidthForName
,
461 m_text
[Name
].size().height());
463 // Calculate the position for each additional information
464 qreal y
= m_textPos
[Name
].y() + textLinesCountForName
* fontHeight
;
465 foreach (const QByteArray
& role
, m_sortedVisibleRoles
) {
466 const TextId textId
= roleTextId(role
);
467 if (textId
== Name
) {
471 const QString text
= roleText(textId
, values
[role
]);
472 m_text
[textId
].setText(text
);
474 qreal requiredWidth
= 0;
476 QTextLayout
layout(text
, option
.font
);
477 layout
.setTextOption(m_text
[textId
].textOption());
478 layout
.beginLayout();
479 QTextLine textLine
= layout
.createLine();
480 if (textLine
.isValid()) {
481 textLine
.setLineWidth(maxWidth
);
482 requiredWidth
= textLine
.naturalTextWidth();
483 if (textLine
.textLength() < text
.length()) {
484 // TODO: QFontMetrics::elidedText() works different regarding the given width
485 // in comparison to QTextLine::setLineWidth(). It might happen that the text does
486 // not get elided although it does not fit into the given width. As workaround
487 // the margin is substracted.
488 const QString elidedText
= option
.fontMetrics
.elidedText(text
, Qt::ElideRight
, maxWidth
- option
.margin
);
489 m_text
[textId
].setText(elidedText
);
494 m_textPos
[textId
] = QPointF(option
.margin
, y
);
495 m_text
[textId
].setTextWidth(maxWidth
);
497 const QRectF
textBoundingRect(option
.margin
+ (maxWidth
- requiredWidth
) / 2, y
, requiredWidth
, fontHeight
);
498 m_textBoundingRect
|= textBoundingRect
;
503 // Add a margin to the text bounding rectangle
504 const qreal margin
= option
.margin
;
505 m_textBoundingRect
.adjust(-margin
, -margin
, margin
, margin
);
508 void KFileItemListWidget::updateCompactLayoutTextCache()
510 // +------+ Name role
511 // | Icon | Additional role 1
512 // +------+ Additional role 2
514 const QHash
<QByteArray
, QVariant
> values
= data();
516 const KItemListStyleOption
& option
= styleOption();
517 const qreal widgetHeight
= size().height();
518 const qreal fontHeight
= option
.fontMetrics
.height();
519 const qreal textLinesHeight
= qMax(visibleRoles().count(), 1) * fontHeight
;
520 const int scaledIconSize
= (textLinesHeight
< option
.iconSize
) ? widgetHeight
- 2 * option
.margin
: option
.iconSize
;
522 qreal maximumRequiredTextWidth
= 0;
523 const qreal x
= option
.margin
* 3 + scaledIconSize
;
524 qreal y
= (widgetHeight
- textLinesHeight
) / 2;
525 const qreal maxWidth
= size().width() - x
- option
.margin
;
526 foreach (const QByteArray
& role
, m_sortedVisibleRoles
) {
527 const TextId textId
= roleTextId(role
);
529 const QString text
= roleText(textId
, values
[role
]);
530 m_text
[textId
].setText(text
);
532 qreal requiredWidth
= option
.fontMetrics
.width(text
);
533 if (requiredWidth
> maxWidth
) {
534 requiredWidth
= maxWidth
;
535 const QString elidedText
= option
.fontMetrics
.elidedText(text
, Qt::ElideRight
, maxWidth
);
536 m_text
[textId
].setText(elidedText
);
539 m_textPos
[textId
] = QPointF(x
, y
);
540 m_text
[textId
].setTextWidth(maxWidth
);
542 maximumRequiredTextWidth
= qMax(maximumRequiredTextWidth
, requiredWidth
);
547 m_textBoundingRect
= QRectF(x
- option
.margin
, 0, maximumRequiredTextWidth
+ 2 * option
.margin
, widgetHeight
);
550 void KFileItemListWidget::updateDetailsLayoutTextCache()
552 // Precondition: Requires already updated m_expansionArea
553 // to determine the left position.
556 // | Icon | Name role Additional role 1 Additional role 2
558 m_textBoundingRect
= QRectF();
560 const KItemListStyleOption
& option
= styleOption();
561 const QHash
<QByteArray
, QVariant
> values
= data();
563 const qreal widgetHeight
= size().height();
564 const int scaledIconSize
= widgetHeight
- 2 * option
.margin
;
565 const int fontHeight
= option
.fontMetrics
.height();
567 qreal x
= m_expansionArea
.right() + option
.margin
* 3 + scaledIconSize
;
568 const qreal y
= qMax(qreal(option
.margin
), (widgetHeight
- fontHeight
) / 2);
570 foreach (const QByteArray
& role
, m_sortedVisibleRoles
) {
571 const TextId textId
= roleTextId(role
);
573 const QString text
= roleText(textId
, values
[role
]);
574 m_text
[textId
].setText(text
);
576 const qreal requiredWidth
= option
.fontMetrics
.width(text
);
577 m_textPos
[textId
] = QPointF(x
, y
);
579 const qreal columnWidth
= visibleRolesSizes().value(role
, QSizeF(0, 0)).width();
584 m_textBoundingRect
= QRectF(m_textPos
[textId
].x() - option
.margin
, 0,
585 requiredWidth
+ 2 * option
.margin
, size().height());
587 // The column after the name should always be aligned on the same x-position independent
588 // from the expansion-level shown in the name column
589 x
-= m_expansionArea
.right();
593 // The values for the size should be right aligned
594 m_textPos
[textId
].rx() += columnWidth
- requiredWidth
- 2 * option
.margin
;
603 QString
KFileItemListWidget::roleText(TextId textId
, const QVariant
& roleValue
) const
615 text
= roleValue
.toString();
619 if (data().value("isDir").toBool()) {
620 // The item represents a directory. Show the number of sub directories
621 // instead of the file size of the directory.
622 if (!roleValue
.isNull()) {
623 const KIO::filesize_t size
= roleValue
.value
<KIO::filesize_t
>();
624 text
= i18ncp("@item:intable", "%1 item", "%1 items", size
);
627 const KIO::filesize_t size
= roleValue
.value
<KIO::filesize_t
>();
628 text
= KIO::convertSize(size
);
634 const QDateTime dateTime
= roleValue
.toDateTime();
635 text
= KGlobal::locale()->formatDateTime(dateTime
);
647 void KFileItemListWidget::drawPixmap(QPainter
* painter
, const QPixmap
& pixmap
)
649 const bool isHiddenItem
= m_text
[Name
].text().startsWith(QLatin1Char('.'));
652 opacity
= painter
->opacity();
653 painter
->setOpacity(opacity
* 0.3);
656 if (m_scaledPixmapSize
!= pixmap
.size()) {
657 QPixmap scaledPixmap
= pixmap
;
658 KPixmapModifier::scale(scaledPixmap
, m_scaledPixmapSize
);
659 painter
->drawPixmap(m_pixmapPos
, scaledPixmap
);
661 #ifdef KFILEITEMLISTWIDGET_DEBUG
662 painter
->setPen(Qt::green
);
663 painter
->drawRect(QRectF(m_pixmapPos
, QSizeF(scaledPixmap
.size())));
666 painter
->drawPixmap(m_pixmapPos
, pixmap
);
670 painter
->setOpacity(opacity
);
674 QPixmap
KFileItemListWidget::pixmapForIcon(const QString
& name
, int size
)
676 const KIcon
icon(name
);
679 if (size
<= KIconLoader::SizeSmall
) {
680 requestedSize
= KIconLoader::SizeSmall
;
681 } else if (size
<= KIconLoader::SizeSmallMedium
) {
682 requestedSize
= KIconLoader::SizeSmallMedium
;
683 } else if (size
<= KIconLoader::SizeMedium
) {
684 requestedSize
= KIconLoader::SizeMedium
;
685 } else if (size
<= KIconLoader::SizeLarge
) {
686 requestedSize
= KIconLoader::SizeLarge
;
687 } else if (size
<= KIconLoader::SizeHuge
) {
688 requestedSize
= KIconLoader::SizeHuge
;
689 } else if (size
<= KIconLoader::SizeEnormous
) {
690 requestedSize
= KIconLoader::SizeEnormous
;
691 } else if (size
<= KIconLoader::SizeEnormous
* 2) {
692 requestedSize
= KIconLoader::SizeEnormous
* 2;
694 requestedSize
= size
;
697 QPixmap pixmap
= icon
.pixmap(requestedSize
, requestedSize
);
698 if (requestedSize
!= size
) {
699 KPixmapModifier::scale(pixmap
, QSize(size
, size
));
705 KFileItemListWidget::TextId
KFileItemListWidget::roleTextId(const QByteArray
& role
)
707 static QHash
<QByteArray
, TextId
> rolesHash
;
708 if (rolesHash
.isEmpty()) {
709 rolesHash
.insert("name", Name
);
710 rolesHash
.insert("size", Size
);
711 rolesHash
.insert("date", Date
);
712 rolesHash
.insert("permissions", Permissions
);
713 rolesHash
.insert("owner", Owner
);
714 rolesHash
.insert("group", Group
);
715 rolesHash
.insert("type", Type
);
716 rolesHash
.insert("destination", Destination
);
717 rolesHash
.insert("path", Path
);
720 return rolesHash
.value(role
);
723 #include "kfileitemlistwidget.moc"