- const KItemListStyleOption& option = styleOption();
- const QHash<QByteArray, QVariant> values = data();
-
- const qreal widgetHeight = size().height();
- const int scaledIconSize = widgetHeight - 2 * option.margin;
- const int fontHeight = option.fontMetrics.height();
-
- qreal x = m_expansionArea.right() + option.margin * 3 + scaledIconSize;
- const qreal y = qMax(qreal(option.margin), (widgetHeight - fontHeight) / 2);
-
- foreach (const QByteArray& role, m_sortedVisibleRoles) {
- const TextId textId = roleTextId(role);
-
- const QString text = roleText(textId, values[role]);
- m_text[textId].setText(text);
-
- const qreal requiredWidth = option.fontMetrics.width(text);
- m_textPos[textId] = QPointF(x, y);
-
- const qreal columnWidth = visibleRolesSizes().value(role, QSizeF(0, 0)).width();
- x += columnWidth;
-
- switch (textId) {
- case Name: {
- m_textBoundingRect = QRectF(m_textPos[textId].x() - option.margin, 0,
- requiredWidth + 2 * option.margin, size().height());
-
- // The column after the name should always be aligned on the same x-position independent
- // from the expansion-level shown in the name column
- x -= m_expansionArea.right();
- break;
- }
- case Size:
- // The values for the size should be right aligned
- m_textPos[textId].rx() += columnWidth - requiredWidth - 2 * option.margin;
- break;
-
- default:
- break;
- }
- }
-}
-
-void KFileItemListWidget::updateAdditionalInfoTextColor()
-{
- // For the color of the additional info the inactive text color
- // is not used as this might lead to unreadable text for some color schemes. Instead
- // the text color is slightly mixed with the background color.
- const QColor c1 = m_customTextColor ? *m_customTextColor : styleOption().palette.text().color();
- const QColor c2 = styleOption().palette.background().color();
- const int p1 = 70;
- const int p2 = 100 - p1;
- m_additionalInfoTextColor = QColor((c1.red() * p1 + c2.red() * p2) / 100,
- (c1.green() * p1 + c2.green() * p2) / 100,
- (c1.blue() * p1 + c2.blue() * p2) / 100);
-}
-
-QString KFileItemListWidget::roleText(TextId textId, const QVariant& roleValue) const
-{
- QString text;
-
- switch (textId) {
- case Name:
- case Permissions:
- case Owner:
- case Group:
- case Type:
- case Destination:
- case Path:
- text = roleValue.toString();
- break;
-
- case Size: {
- if (data().value("isDir").toBool()) {
- // The item represents a directory. Show the number of sub directories
- // instead of the file size of the directory.
- if (!roleValue.isNull()) {
- const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
- text = i18ncp("@item:intable", "%1 item", "%1 items", size);
- }
- } else {
- const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
- text = KIO::convertSize(size);
- }
- break;
- }
-
- case Date: {
- const QDateTime dateTime = roleValue.toDateTime();
- text = KGlobal::locale()->formatDateTime(dateTime);
- break;