m_layouter->markAsDirty();
doLayout(animate ? Animation : NoAnimation);
+ if (m_itemSize.isEmpty()) {
+ updatePreferredColumnWidths();
+ }
+
onStyleOptionChanged(option, previousOption);
}
this, SLOT(slotSortOrderChanged(Qt::SortOrder,Qt::SortOrder)));
connect(m_model, SIGNAL(sortRoleChanged(QByteArray,QByteArray)),
this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
+
+ const int itemCount = m_model->count();
+ if (itemCount > 0) {
+ slotItemsInserted(KItemRangeList() << KItemRange(0, itemCount));
+ }
}
onModelChanged(model, previous);
// Stretch the first column to use the whole remaining width
firstColumnWidth += availableWidth - requiredWidth;
m_headerWidget->setColumnWidth(firstRole, firstColumnWidth);
- } else if (requiredWidth > availableWidth) {
+ } else if (requiredWidth > availableWidth && m_visibleRoles.count() > 1) {
// Shrink the first column to be able to show as much other
// columns as possible
qreal shrinkedFirstColumnWidth = firstColumnWidth - requiredWidth + availableWidth;
#include <QTextLayout>
#include <QTextLine>
-// #define KFILEITEMLISTWIDGET_DEBUG
+// #define KSTANDARDITEMLISTWIDGET_DEBUG
KStandardItemListWidgetInformant::KStandardItemListWidgetInformant() :
KItemListWidgetInformant()
width += option.fontMetrics.width(text);
if (role == "text") {
- // Increase the width by the expansion-toggle and the current expansion level
- const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt();
- width += option.padding + (expandedParentsCount + 1) * view->itemSize().height() + KIconLoader::SizeSmall;
+ if (view->supportsItemExpanding()) {
+ // Increase the width by the expansion-toggle and the current expansion level
+ const int expandedParentsCount = values.value("expandedParentsCount", 0).toInt();
+ const qreal height = option.padding * 2 + qMax(option.iconSize, option.fontMetrics.height());
+ width += (expandedParentsCount + 1) * height;
+ }
// Increase the width by the required space for the icon
width += option.padding * 2 + option.iconSize;
painter->restore();
}
-#ifdef KFILEITEMLISTWIDGET_DEBUG
+#ifdef KSTANDARDITEMLISTWIDGET_DEBUG
painter->setBrush(Qt::NoBrush);
painter->setPen(Qt::green);
painter->drawRect(m_iconRect);
KPixmapModifier::scale(scaledPixmap, m_scaledPixmapSize);
painter->drawPixmap(m_pixmapPos, scaledPixmap);
-#ifdef KFILEITEMLISTWIDGET_DEBUG
+#ifdef KSTANDARDITEMLISTWIDGET_DEBUG
painter->setPen(Qt::blue);
painter->drawRect(QRectF(m_pixmapPos, QSizeF(m_scaledPixmapSize)));
#endif