+ // Assure that the wheel-event gets forwarded to the parent
+ // and not handled at all by QGraphicsView.
+ event->ignore();
+}
+
+KItemListContainer::KItemListContainer(KItemListController *controller, QWidget *parent)
+ : QAbstractScrollArea(parent)
+ , m_controller(controller)
+ , m_horizontalSmoothScroller(nullptr)
+ , m_verticalSmoothScroller(nullptr)
+ , m_scroller(nullptr)
+{
+ Q_ASSERT(controller);
+ controller->setParent(this);
+
+ QGraphicsView *graphicsView = new KItemListContainerViewport(new QGraphicsScene(this), this);
+ setViewport(graphicsView);
+
+ m_horizontalSmoothScroller = new KItemListSmoothScroller(horizontalScrollBar(), this);
+ m_verticalSmoothScroller = new KItemListSmoothScroller(verticalScrollBar(), this);
+
+ if (controller->model()) {
+ slotModelChanged(controller->model(), nullptr);
+ }
+ if (controller->view()) {
+ slotViewChanged(controller->view(), nullptr);
+ }
+
+ connect(controller, &KItemListController::modelChanged, this, &KItemListContainer::slotModelChanged);
+ connect(controller, &KItemListController::viewChanged, this, &KItemListContainer::slotViewChanged);
+
+ m_scroller = QScroller::scroller(viewport());
+ m_scroller->grabGesture(viewport());
+ connect(controller, &KItemListController::scrollerStop, this, &KItemListContainer::stopScroller);
+ connect(m_scroller, &QScroller::stateChanged, controller, &KItemListController::slotStateChanged);