]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
don't trigger an item if the user does a selection by using the control- or shift...
[dolphin.git] / src / dolphinview.cpp
index 26259df872628824709fe092e9d871991d932a88..eddd220d38eff8d32174a89befac7bf3d9be53a9 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <assert.h>
 
+#include <QApplication>
 #include <QDropEvent>
 #include <QItemSelectionModel>
 #include <QMouseEvent>
@@ -116,7 +117,7 @@ DolphinView::DolphinView(DolphinMainWindow* mainWindow,
     m_filterBar->hide();
     connect(m_filterBar, SIGNAL(filterChanged(const QString&)),
            this, SLOT(changeNameFilter(const QString&)));
-    connect(m_filterBar, SIGNAL(closed()),
+    connect(m_filterBar, SIGNAL(closeRequest()),
             this, SLOT(closeFilterBar()));
 
     m_topLayout->addWidget(m_urlNavigator);
@@ -319,12 +320,12 @@ DolphinStatusBar* DolphinView::statusBar() const
 int DolphinView::contentsX() const
 {
 
-    return 0; //scrollView()->contentsX();
+    return itemView()->horizontalScrollBar()->value();
 }
 
 int DolphinView::contentsY() const
 {
-    return 0; //scrollView()->contentsY();
+    return itemView()->verticalScrollBar()->value();
 }
 
 void DolphinView::refreshSettings()
@@ -555,25 +556,9 @@ void DolphinView::reload()
     startDirLister(m_urlNavigator->url(), true);
 }
 
-void DolphinView::slotUrlListDropped(QDropEvent* /* event */,
-                                     const KUrl::List& urls,
-                                     const KUrl& url)
+void DolphinView::declareViewActive()
 {
-    KUrl destination(url);
-    if (destination.isEmpty()) {
-        destination = m_urlNavigator->url();
-    }
-    else {
-        // Check whether the destination Url is a directory. If this is not the
-        // case, use the navigator Url as destination (otherwise the destination,
-        // which represents a file, would be replaced by a copy- or move-operation).
-        KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, destination);
-        if (!fileItem.isDir()) {
-            destination = m_urlNavigator->url();
-        }
-    }
-
-    mainWindow()->dropUrls(urls, destination);
+    mainWindow()->setActiveView( this );
 }
 
 void DolphinView::mouseReleaseEvent(QMouseEvent* event)
@@ -620,19 +605,28 @@ void DolphinView::loadDirectory(const KUrl& url)
 
     startDirLister(url);
     emit urlChanged(url);
+
+    m_statusBar->clear();
 }
 
 void DolphinView::triggerItem(const QModelIndex& index)
 {
+    const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
+    if ((modifier & Qt::ShiftModifier) || (modifier & Qt::ControlModifier)) {
+        // items are selected by the user, hence don't trigger the
+        // item specified by 'index'
+        return;
+    }
+
     KFileItem* item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index));
     if (item == 0) {
         return;
     }
 
     if (item->isDir()) {
-        // Prefer the local path over the Url. This assures that the
-        // volume space information is correct. Assuming that the Url is media:/sda1,
-        // and the local path is /windows/C: For the Url the space info is related
+        // Prefer the local path over the URL. This assures that the
+        // volume space information is correct. Assuming that the URL is media:/sda1,
+        // and the local path is /windows/C: For the URL the space info is related
         // to the root partition (and hence wrong) and for the local path the space
         // info is related to the windows partition (-> correct).
         const QString localPath(item->localPath());
@@ -682,6 +676,23 @@ void DolphinView::updateItemCount()
     }
 
     updateStatusBar();
+
+    QTimer::singleShot(0, this, SLOT(restoreContentsPos()));
+}
+
+void DolphinView::restoreContentsPos()
+{
+    int index = 0;
+    const QLinkedList<UrlNavigator::HistoryElem> history = urlHistory(index);
+    if (!history.isEmpty()) {
+        QAbstractItemView* view = itemView();
+        // TODO: view->setCurrentItem(history[index].currentFileName());
+
+        QLinkedList<UrlNavigator::HistoryElem>::const_iterator it = history.begin();
+        it += index;
+        view->horizontalScrollBar()->setValue((*it).contentsX());
+        view->verticalScrollBar()->setValue((*it).contentsY());
+    }
 }
 
 void DolphinView::showInfoMessage(const QString& msg)
@@ -833,11 +844,6 @@ void DolphinView::showFilterBar(bool show)
     }
 }
 
-void DolphinView::declareViewActive()
-{
-    mainWindow()->setActiveView( this );
-}
-
 void DolphinView::updateStatusBar()
 {
     // As the item count information is less important
@@ -891,7 +897,7 @@ void DolphinView::createView()
     // delete current view
     QAbstractItemView* view = itemView();
     if (view != 0) {
-        m_topLayout->remove(view);
+        m_topLayout->removeWidget(view);
         view->close();
         view->deleteLater();
         m_iconsView = 0;