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)
return m_header;
}
-QPixmap KItemListView::createDragPixmap(const QSet<int>& indexes) const
+QPixmap KItemListView::createDragPixmap(const KItemSet& indexes) const
{
QPixmap pixmap;
if (indexes.count() == 1) {
- KItemListWidget* item = m_visibleItems.value(indexes.toList().first());
+ KItemListWidget* item = m_visibleItems.value(indexes.first());
QGraphicsView* graphicsView = scene()->views()[0];
if (item && graphicsView) {
pixmap = item->createDragPixmap(0, graphicsView);
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()) {
QAccessible::updateAccessibility(this, current+1, QAccessible::Focus);
}
-void KItemListView::slotSelectionChanged(const QSet<int>& current, const QSet<int>& previous)
+void KItemListView::slotSelectionChanged(const KItemSet& current, const KItemSet& previous)
{
Q_UNUSED(previous);
if (previous) {
KItemListSelectionManager* selectionManager = previous->selectionManager();
disconnect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int)));
- disconnect(selectionManager, SIGNAL(selectionChanged(QSet<int>,QSet<int>)), this, SLOT(slotSelectionChanged(QSet<int>,QSet<int>)));
+ disconnect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
}
m_controller = controller;
if (controller) {
KItemListSelectionManager* selectionManager = controller->selectionManager();
connect(selectionManager, SIGNAL(currentChanged(int,int)), this, SLOT(slotCurrentChanged(int,int)));
- connect(selectionManager, SIGNAL(selectionChanged(QSet<int>,QSet<int>)), this, SLOT(slotSelectionChanged(QSet<int>,QSet<int>)));
+ connect(selectionManager, SIGNAL(selectionChanged(KItemSet,KItemSet)), this, SLOT(slotSelectionChanged(KItemSet,KItemSet)));
}
onControllerChanged(controller, previous);