return m_visibleRolesWidths;
}
+qreal KItemListHeader::minimumRoleWidth() const
+{
+ QFontMetricsF fontMetrics(font());
+ return fontMetrics.height() * 4;
+}
+
void KItemListHeader::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
return pos.x() >= (x - grip) && pos.x() <= x;
}
-qreal KItemListHeader::minimumRoleWidth() const
-{
- QFontMetricsF fontMetrics(font());
- return fontMetrics.height() * 4;
-}
-
#include "kitemlistheader_p.moc"
void setVisibleRolesWidths(const QHash<QByteArray, qreal> rolesWidths);
QHash<QByteArray, qreal> visibleRolesWidths() const;
+ qreal minimumRoleWidth() const;
+
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
signals:
void updateHoveredRoleIndex(const QPointF& pos);
int roleIndexAt(const QPointF& pos) const;
bool isAboveRoleGrip(const QPointF& pos, int roleIndex) const;
- qreal minimumRoleWidth() const;
private:
enum RoleOperation
}
if (itemCount == rangesItemCount) {
- // The sizes of all roles need to be determined
m_visibleRolesSizes = visibleRolesSizes(itemRanges);
+
+ // Assure the the sizes are not smaller than the minimum defined by the header
+ // TODO: Currently only implemented for a top-aligned header
+ const qreal minHeaderRoleWidth = m_header->minimumRoleWidth();
+ QMutableHashIterator<QByteArray, QSizeF> it (m_visibleRolesSizes);
+ while (it.hasNext()) {
+ it.next();
+ const QSizeF& size = it.value();
+ if (size.width() < minHeaderRoleWidth) {
+ const QSizeF newSize(minHeaderRoleWidth, size.height());
+ m_visibleRolesSizes.insert(it.key(), newSize);
+ }
+ }
} else {
// Only a sub range of the roles need to be determined.
// The chances are good that the sizes of the sub ranges
if (!updateRequired) {
// All the updated sizes are smaller than the current sizes and no change
- // of the roles-widths is required
+ // of the stretched roles-widths is required
return;
}
}