]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/ktreeview.cpp
Assure that the items within the "Others" group are sorted too, when sorting by name...
[dolphin.git] / src / ktreeview.cpp
index 687bfe1e385e5a089489d2cafb19bb489476fda0..7c30fad337bbb24c008eb467220b69c017c19910 100644 (file)
@@ -36,7 +36,7 @@ KTreeView::KTreeViewPrivate::KTreeViewPrivate(KTreeView *parent) :
 {
     startScrollTimer = new QTimer(this);
     startScrollTimer->setSingleShot(true);
-    startScrollTimer->setInterval(50);
+    startScrollTimer->setInterval(300);
     connect(startScrollTimer, SIGNAL(timeout()),
             this, SLOT(startScrolling()));
 
@@ -54,10 +54,6 @@ KTreeView::KTreeViewPrivate::KTreeViewPrivate(KTreeView *parent) :
             startScrollTimer, SLOT(start()));
 }
 
-KTreeView::~KTreeView()
-{
-}
-
 void KTreeView::KTreeViewPrivate::startScrolling()
 {
     QModelIndex index;
@@ -130,14 +126,18 @@ void KTreeView::KTreeViewPrivate::updateVerticalScrollBar(int value)
 // ************************************************
 
 KTreeView::KTreeView(QWidget *parent) :
-       QTreeView(parent),
-       d(new KTreeViewPrivate(this))
+    QTreeView(parent),
+    d(new KTreeViewPrivate(this))
 {
     if (KGlobalSettings::graphicEffectsLevel() >= KGlobalSettings::SimpleAnimationEffects) {
         setAutoHorizontalScroll(true);
     }
 }
 
+KTreeView::~KTreeView()
+{
+}
+
 void KTreeView::setAutoHorizontalScroll(bool value)
 {
        d->autoHorizontalScroll = value;
@@ -156,5 +156,25 @@ void KTreeView::setSelectionModel(QItemSelectionModel *selectionModel)
             d->startScrollTimer, SLOT(start()));
 }
 
+void KTreeView::scrollTo(const QModelIndex& index, ScrollHint hint)
+{
+    if (d->autoHorizontalScroll) {
+        // assure that the value of the horizontal scrollbar stays on its current value,
+        // KTreeView will adjust the value manually
+        const int value = horizontalScrollBar()->value();
+        QTreeView::scrollTo(index, hint);
+        horizontalScrollBar()->setValue(value);
+    } else {
+        QTreeView::scrollTo(index, hint);
+    }
+}
+
+void KTreeView::hideEvent(QHideEvent *event)
+{
+    d->startScrollTimer->stop();
+    d->timeLine->stop();
+    QTreeView::hideEvent(event);
+}
+
 #include "ktreeview.moc"
 #include "ktreeview_p.moc"