m_sizeHintResolver = new KItemListSizeHintResolver(this);
- m_layouter = new KItemListViewLayouter(this);
- m_layouter->setSizeHintResolver(m_sizeHintResolver);
+ m_layouter = new KItemListViewLayouter(m_sizeHintResolver, this);
m_animation = new KItemListViewAnimation(this);
connect(m_animation, SIGNAL(finished(QGraphicsWidget*,KItemListViewAnimation::AnimationType)),
return m_layouter->lastVisibleIndex();
}
-QSizeF KItemListView::itemSizeHint(int index) const
+void KItemListView::calculateItemSizeHints(QVector<QSizeF>& sizeHints) const
{
- return widgetCreator()->itemSizeHint(index, this);
+ widgetCreator()->calculateItemSizeHints(sizeHints, this);
}
void KItemListView::setSupportsItemExpanding(bool supportsExpanding)
bool KItemListView::event(QEvent* event)
{
- // Forward all events to the controller and handle them there
- if (!m_editingRole && m_controller && m_controller->processEvent(event, transform())) {
- event->accept();
- return true;
+ switch (event->type()) {
+ case QEvent::PaletteChange:
+ updatePalette();
+ break;
+
+ case QEvent::FontChange:
+ updateFont();
+ break;
+
+ default:
+ // Forward all other events to the controller and handle them there
+ if (!m_editingRole && m_controller && m_controller->processEvent(event, transform())) {
+ event->accept();
+ return true;
+ }
}
+
return QGraphicsWidget::event(event);
}
return m_visibleItems.values();
}
+void KItemListView::updateFont()
+{
+ if (scene() && !scene()->views().isEmpty()) {
+ KItemListStyleOption option = styleOption();
+ option.font = scene()->views().first()->font();
+ option.fontMetrics = QFontMetrics(option.font);
+
+ setStyleOption(option);
+ }
+}
+
+void KItemListView::updatePalette()
+{
+ if (scene() && !scene()->views().isEmpty()) {
+ KItemListStyleOption option = styleOption();
+ option.palette = scene()->views().first()->palette();
+
+ setStyleOption(option);
+ }
+}
+
void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges)
{
if (m_itemSize.isEmpty()) {