]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Merge remote-tracking branch 'origin/KDE/4.14'
[dolphin.git] / src / views / dolphinview.cpp
index 63b53f2e263b68324e0de4c73370bb5b682c8c59..1de973bd5489704dd5cfcad1681f3c732502e8c5 100644 (file)
@@ -1046,6 +1046,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
     if (op && destUrl == url()) {
         // Mark the dropped urls as selected.
         m_clearSelectionBeforeSelectingNewItems = true;
+        m_markFirstNewlySelectedItemAsCurrent = true;
         connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
     }
 
@@ -1070,17 +1071,15 @@ void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* prev
 
 void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons)
 {
+    Q_UNUSED(itemIndex);
+
     hideToolTip();
 
-    if (itemIndex < 0) {
-        // Trigger the history navigation only when clicking on the viewport:
-        // Above an item the XButtons provide a simple way to select items in
-        // the singleClick mode.
-        if (buttons & Qt::XButton1) {
-            emit goBackRequested();
-        } else if (buttons & Qt::XButton2) {
-            emit goForwardRequested();
-        }
+    // TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
+    if (buttons & Qt::XButton1) {
+        emit goBackRequested();
+    } else if (buttons & Qt::XButton2) {
+        emit goForwardRequested();
     }
 }
 
@@ -1168,6 +1167,14 @@ bool DolphinView::itemsExpandable() const
 
 void DolphinView::restoreState(QDataStream& stream)
 {
+    // Read the version number of the view state and check if the version is supported.
+    quint32 version = 0;
+    stream >> version;
+    if (version != 1) {
+        // The version of the view state isn't supported, we can't restore it.
+        return;
+    }
+
     // Restore the current item that had the keyboard focus
     stream >> m_currentItemUrl;
 
@@ -1182,6 +1189,8 @@ void DolphinView::restoreState(QDataStream& stream)
 
 void DolphinView::saveState(QDataStream& stream)
 {
+    stream << quint32(1); // View state version
+
     // Save the current item that has the keyboard focus
     const int currentIndex = m_container->controller()->selectionManager()->currentItem();
     if (currentIndex != -1) {
@@ -1290,11 +1299,11 @@ void DolphinView::updateViewState()
                 m_view->scrollToItem(currentIndex);
                 m_scrollToCurrentItem = false;
             }
-
-            m_currentItemUrl = KUrl();
         } else {
             selectionManager->setCurrentItem(0);
         }
+
+        m_currentItemUrl = KUrl();
     }
 
     if (!m_restoredContentsPosition.isNull()) {
@@ -1354,16 +1363,6 @@ void DolphinView::calculateItemCount(int& fileCount,
     }
 }
 
-void DolphinView::showHoverInformation(const KFileItem& item)
-{
-    emit requestItemInfo(item);
-}
-
-void DolphinView::clearHoverInformation()
-{
-    emit requestItemInfo(KFileItem());
-}
-
 void DolphinView::slotDeleteFileFinished(KJob* job)
 {
     if (job->error() == 0) {
@@ -1662,11 +1661,16 @@ void DolphinView::updateWritableState()
     const bool wasFolderWritable = m_isFolderWritable;
     m_isFolderWritable = false;
 
-    const KFileItem item = m_model->rootItem();
-    if (!item.isNull()) {
-        KFileItemListProperties capabilities(KFileItemList() << item);
-        m_isFolderWritable = capabilities.supportsWriting();
+    KFileItem item = m_model->rootItem();
+    if (item.isNull()) {
+        // Try to find out if the URL is writable even if the "root item" is
+        // null, see https://bugs.kde.org/show_bug.cgi?id=330001
+        item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url(), true);
     }
+
+    KFileItemListProperties capabilities(KFileItemList() << item);
+    m_isFolderWritable = capabilities.supportsWriting();
+
     if (m_isFolderWritable != wasFolderWritable) {
         emit writeStateChanged(m_isFolderWritable);
     }