]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/folderexpander.cpp
SVN_SILENT: removed trailing spaces
[dolphin.git] / src / folderexpander.cpp
index f7b73c1f5d3eb3c45ed875f5b797524e49556ad5..574f0a3045090e03b2e57a50423e4dd2e474cdfb 100644 (file)
@@ -34,7 +34,6 @@
 #include <QtGui/QSortFilterProxyModel>
 
 #include <kdirmodel.h>
-#include <kdebug.h>
 
 FolderExpander::FolderExpander(QAbstractItemView *view, QSortFilterProxyModel *proxyModel) :
     QObject(view),
@@ -54,7 +53,7 @@ FolderExpander::FolderExpander(QAbstractItemView *view, QSortFilterProxyModel *p
         kWarning() << "Need a proxyModel!";
         return; // Not valid.
     }
-    KDirModel *m_dirModel = qobject_cast< KDirModel* >( m_proxyModel->sourceModel() );  
+    KDirModel *m_dirModel = qobject_cast< KDirModel* >( m_proxyModel->sourceModel() );
     if (m_dirModel == 0) {
         kWarning() << "Expected m_proxyModel's sourceModel() to be a KDirModel!";
         return; // Not valid.
@@ -63,7 +62,7 @@ FolderExpander::FolderExpander(QAbstractItemView *view, QSortFilterProxyModel *p
     // Initialise auto-expand timer.
     m_autoExpandTriggerTimer = new QTimer(this);
     m_autoExpandTriggerTimer->setSingleShot(true);
-    connect(m_autoExpandTriggerTimer, SIGNAL(timeout()), 
+    connect(m_autoExpandTriggerTimer, SIGNAL(timeout()),
             this, SLOT(autoExpandTimeout()));
 
     // The view scrolling complicates matters, so we want to
@@ -94,13 +93,6 @@ FolderExpander::~FolderExpander()
 void FolderExpander::viewScrolled()
 {
     if (m_autoExpandTriggerTimer->isActive())  {
-        kDebug() << "Resetting time due to scrolling!"; 
-        // (Re-)set the timer while we're scrolling the view
-        // (or it's being scrolled by some external mechanism).
-        // TODO - experiment with this.  Cancelling the timer,
-        // or adding a "penalty" on top of AUTO_EXPAND_DELAY
-        // might work more nicely when drilling down through the sidebar
-        // tree.
         m_autoExpandTriggerTimer->start(AUTO_EXPAND_DELAY);
     }
 }
@@ -116,11 +108,13 @@ void FolderExpander::autoExpandTimeout()
     // needing to pass in m_proxyModel that has a KDirModel as its sourceModel() ... ?
     QModelIndex proxyIndexToExpand = m_view->indexAt(m_autoExpandPos);
     QModelIndex indexToExpand = m_proxyModel->mapToSource(proxyIndexToExpand);
-    KDirModel* m_dirModel = qobject_cast< KDirModel* >(m_proxyModel->sourceModel()); 
+    KDirModel* m_dirModel = qobject_cast< KDirModel* >(m_proxyModel->sourceModel());
     Q_ASSERT(m_dirModel != 0);
     KFileItem itemToExpand = m_dirModel->itemForIndex(indexToExpand );
 
-    kDebug() << "Need to expand: " << itemToExpand.targetUrl() << " isDir? = " << itemToExpand.isDir();
+    if (itemToExpand.isNull()) {
+        return;
+    }
 
     if (itemToExpand.isDir()) {
         QTreeView *viewAsTreeView = qobject_cast<QTreeView*>(m_view);
@@ -129,8 +123,7 @@ void FolderExpander::autoExpandTimeout()
             viewAsTreeView->setExpanded(proxyIndexToExpand, !viewAsTreeView->isExpanded(proxyIndexToExpand));
         }
         else {
-            // Enter this directory.
-            emit enterDir(proxyIndexToExpand);
+            emit enterDir(proxyIndexToExpand, m_view);
         }
     }
 }