]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
When pasting a folder and expanding it, do not select its children
[dolphin.git] / src / views / dolphinview.cpp
index 16b92801be73f6a299dff96c0a6c7506f03f6b42..20bc9f522534feaa5faab871e63180617a5b8ef2 100644 (file)
@@ -178,7 +178,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
     connect(m_view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
             this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>)));
     connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
-            this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
+            this, SLOT(slotRoleEditingCanceled()));
     connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
             this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
 
@@ -248,9 +248,12 @@ void DolphinView::setMode(Mode mode)
     if (mode != m_mode) {
         ViewProperties props(viewPropertiesUrl());
         props.setViewMode(mode);
-        props.save();
 
-        applyViewProperties();
+        // We pass the new ViewProperties to applyViewProperties, rather than
+        // storing them on disk and letting applyViewProperties() read them
+        // from there, to prevent that changing the view mode fails if the
+        // .directory file is not writable (see bug 318534).
+        applyViewProperties(props);
     }
 }
 
@@ -847,6 +850,12 @@ void DolphinView::slotItemMiddleClicked(int index)
 
 void DolphinView::slotItemContextMenuRequested(int index, const QPointF& pos)
 {
+    // Force emit of a selection changed signal before we request the
+    // context menu, to update the edit-actions first. (See Bug 294013)
+    if (m_selectionChangedTimer->isActive()) {
+        emitSelectionChangedSignal();
+    }
+
     const KFileItem item = m_model->fileItem(index);
     emit requestContextMenu(pos.toPoint(), item, url(), QList<QAction*>());
 }
@@ -1045,7 +1054,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
     if (op && destUrl == url()) {
         // Mark the dropped urls as selected.
         m_clearSelectionBeforeSelectingNewItems = true;
-        connect(op, SIGNAL(urlPasted(KUrl)), this, SLOT(slotUrlPasted(KUrl)));
+        connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
     }
 
     setActive(true);
@@ -1090,7 +1099,7 @@ void DolphinView::slotAboutToCreate(const KUrl::List& urls)
             markUrlAsCurrent(urls.first());
             m_markFirstNewlySelectedItemAsCurrent = false;
         }
-        m_selectedUrls << urls;
+        m_selectedUrls << KDirModel::simplifiedUrlList(urls);
     }
 }
 
@@ -1245,10 +1254,13 @@ KUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh
         }
 
         if (mimetype == QLatin1String("application/x-desktop")) {
-            // Redirect to the URL in Type=Link desktop files
+            // Redirect to the URL in Type=Link desktop files, unless it is a http(s) URL.
             KDesktopFile desktopFile(url.toLocalFile());
             if (desktopFile.hasLinkType()) {
-                return desktopFile.readUrl();
+                const QString linkUrl = desktopFile.readUrl();
+                if (!linkUrl.startsWith(QLatin1String("http"))) {
+                    return linkUrl;
+                }
             }
         }
     }
@@ -1445,7 +1457,7 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray>& curre
     emit visibleRolesChanged(m_visibleRoles, previousVisibleRoles);
 }
 
-void DolphinView::slotRoleEditingCanceled(int index, const QByteArray& role, const QVariant& value)
+void DolphinView::slotRoleEditingCanceled()
 {
     disconnect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
                this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
@@ -1508,9 +1520,13 @@ void DolphinView::loadDirectory(const KUrl& url, bool reload)
 
 void DolphinView::applyViewProperties()
 {
-    m_view->beginTransaction();
-
     const ViewProperties props(viewPropertiesUrl());
+    applyViewProperties(props);
+}
+
+void DolphinView::applyViewProperties(const ViewProperties& props)
+{
+    m_view->beginTransaction();
 
     const Mode mode = props.viewMode();
     if (m_mode != mode) {