]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Assure that a newly created item gets selected/focused and visible
authorPeter Penz <peter.penz19@gmail.com>
Sat, 5 May 2012 20:02:21 +0000 (22:02 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 5 May 2012 20:03:21 +0000 (22:03 +0200)
Thanks to Franz Fellner for the patch!

CCBUG: 291064
CCMAIL: alpine.art.de@googlemail.com

src/views/dolphinview.cpp

index 2f744386f90316d03a5949adc14c3570830b3c0e..f738dc078a63c65fa249392635a0a2cdf3655433 100644 (file)
@@ -1124,23 +1124,23 @@ KFileItem DolphinView::rootItem() const
 void DolphinView::observeCreatedItem(const KUrl& url)
 {
     m_createdItemUrl = url;
-    //connect(m_dirModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
-    //        this, SLOT(selectAndScrollToCreatedItem()));
+    connect(m_model, SIGNAL(directoryLoadingCompleted()),
+            this, SLOT(selectAndScrollToCreatedItem()));
 }
 
 void DolphinView::selectAndScrollToCreatedItem()
 {
-    /*const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForUrl(m_createdItemUrl);
-    if (dirIndex.isValid()) {
-        const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
-        QAbstractItemView* view = m_viewAccessor.itemView();
-        if (view) {
-            view->setCurrentIndex(proxyIndex);
-        }
+    KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
+    const int index = m_model->index(m_createdItemUrl);
+    if (index != -1) {
+        selectionManager->setCurrentItem(index);
+        selectionManager->clearSelection();
+        selectionManager->setSelected(index);
+        m_view->scrollToItem(index);
     }
 
-    disconnect(m_viewAccessor.dirModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
-               this, SLOT(selectAndScrollToCreatedItem()));*/
+    disconnect(m_model, SIGNAL(directoryLoadingCompleted()),
+               this, SLOT(selectAndScrollToCreatedItem()));
     m_createdItemUrl = KUrl();
 }