┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistcontainer.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-08-18 23:11:16 +0200
committerPeter Penz <[email protected]>2011-08-18 23:14:30 +0200
commitdbe2152912cc58f1d2bfba187175ec0e4b3e4761 (patch)
tree91d622cc65b72e56082fa5d533dab5b9437403d3 /src/kitemviews/kitemlistcontainer.cpp
parent63e82a2b3bba25fbfaa3d283264cc0c61d11cfe8 (diff)
Provide basic rubberband functionality
This is just a rough draft: The rubberband gets visible and an automatic scrolling is done if the autoscroll-margins have been reached. However currently no items get selected yet. Currently the autoscrolling has a severe bug if the scrollbars are manually changed before or after a rubberband selection.
Diffstat (limited to 'src/kitemviews/kitemlistcontainer.cpp')
-rw-r--r--src/kitemviews/kitemlistcontainer.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp
index b8d05dc34..b01751e46 100644
--- a/src/kitemviews/kitemlistcontainer.cpp
+++ b/src/kitemviews/kitemlistcontainer.cpp
@@ -210,18 +210,32 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
QGraphicsScene* scene = static_cast<QGraphicsView*>(viewport())->scene();
if (previous) {
scene->removeItem(previous);
- disconnect(previous, SIGNAL(offsetChanged(int,int)), this, SLOT(updateScrollBars()));
- disconnect(previous, SIGNAL(maximumOffsetChanged(int,int)), this, SLOT(updateScrollBars()));
+ disconnect(previous, SIGNAL(offsetChanged(qreal,qreal)), this, SLOT(updateScrollBars()));
+ disconnect(previous, SIGNAL(maximumOffsetChanged(qreal,qreal)), this, SLOT(updateScrollBars()));
+ disconnect(previous, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
m_viewOffsetAnimation->setTargetObject(0);
}
if (current) {
scene->addItem(current);
- connect(current, SIGNAL(offsetChanged(int,int)), this, SLOT(updateScrollBars()));
- connect(current, SIGNAL(maximumOffsetChanged(int,int)), this, SLOT(updateScrollBars()));
+ connect(current, SIGNAL(offsetChanged(qreal,qreal)), this, SLOT(updateScrollBars()));
+ connect(current, SIGNAL(maximumOffsetChanged(qreal,qreal)), this, SLOT(updateScrollBars()));
+ connect(current, SIGNAL(scrollTo(qreal)), this, SLOT(scrollTo(qreal)));
m_viewOffsetAnimation->setTargetObject(current);
}
}
+void KItemListContainer::scrollTo(qreal offset)
+{
+ const KItemListView* view = m_controller->view();
+ if (!view) {
+ return;
+ }
+
+ QScrollBar* scrollBar = (view->scrollOrientation() == Qt::Vertical)
+ ? verticalScrollBar() : horizontalScrollBar();
+ scrollBar->setValue(offset);
+}
+
void KItemListContainer::updateScrollBars()
{
const KItemListView* view = m_controller->view();
@@ -267,11 +281,6 @@ void KItemListContainer::updateScrollBars()
scrollBar->setMaximum(maximum);
scrollBar->setValue(value);
- disconnect(view, SIGNAL(scrollTo(int)),
- otherScrollBar, SLOT(setValue(int)));
- connect(view, SIGNAL(scrollTo(int)),
- scrollBar, SLOT(setValue(int)));
-
// Make sure that the other scroll bar is hidden
otherScrollBar->setMaximum(0);
otherScrollBar->setValue(0);
@@ -316,7 +325,7 @@ void KItemListContainer::initialize()
setViewport(graphicsView);
m_viewOffsetAnimation = new QPropertyAnimation(this, "offset");
- m_viewOffsetAnimation->setDuration(500);
+ m_viewOffsetAnimation->setDuration(300);
horizontalScrollBar()->installEventFilter(this);
verticalScrollBar()->installEventFilter(this);