-KItemListContainer::KItemListContainer(QWidget* parent) :
- QAbstractScrollArea(parent),
- m_controller(0),
- m_horizontalSmoothScroller(0),
- m_verticalSmoothScroller(0)
-{
- initialize();
+ 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);