]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphintabwidget.cpp
Simplify startup split view handling
[dolphin.git] / src / dolphintabwidget.cpp
index b38cd5146140e51eec3ca9847a8662cd24b6b42d..ca626d47a3b9b83a91267017cea2e29a621312a7 100644 (file)
@@ -22,8 +22,6 @@
 #include "dolphintabbar.h"
 #include "dolphintabpage.h"
 #include "dolphinviewcontainer.h"
-#include "dolphin_generalsettings.h"
-#include "views/draganddrophelper.h"
 
 #include <QApplication>
 #include <KConfigGroup>
@@ -155,16 +153,14 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
     }
 }
 
-void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs)
+void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs, bool splitView)
 {
-    const bool hasSplitView = GeneralSettings::splitView();
+    Q_ASSERT(dirs.size() > 0);
 
-    // Open each directory inside a new tab. If the "split view" option has been enabled,
-    // always show two directories within one tab.
     QList<QUrl>::const_iterator it = dirs.constBegin();
     while (it != dirs.constEnd()) {
         const QUrl& primaryUrl = *(it++);
-        if (hasSplitView && (it != dirs.constEnd())) {
+        if (splitView && (it != dirs.constEnd())) {
             const QUrl& secondaryUrl = *(it++);
             openNewTab(primaryUrl, secondaryUrl);
         } else {
@@ -173,11 +169,9 @@ void DolphinTabWidget::openDirectories(const QList<QUrl>& dirs)
     }
 }
 
-void DolphinTabWidget::openFiles(const QList<QUrl>& files)
+void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView)
 {
-    if (files.isEmpty()) {
-        return;
-    }
+    Q_ASSERT(files.size() > 0);
 
     // Get all distinct directories from 'files' and open a tab
     // for each directory. If the "split view" option is enabled, two
@@ -191,7 +185,7 @@ void DolphinTabWidget::openFiles(const QList<QUrl>& files)
     }
 
     const int oldTabCount = count();
-    openDirectories(dirs);
+    openDirectories(dirs, splitView);
     const int tabCount = count();
 
     // Select the files. Although the files can be split between several
@@ -286,13 +280,8 @@ void DolphinTabWidget::openNewActivatedTab(int index)
 void DolphinTabWidget::tabDropEvent(int index, QDropEvent* event)
 {
     if (index >= 0) {
-        const DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
-
-        QString error;
-        DragAndDropHelper::dropUrls(view->rootItem(), view->url(), event, error);
-        if (!error.isEmpty()) {
-            currentTabPage()->activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
-        }
+        DolphinView* view = tabPageAt(index)->activeViewContainer()->view();
+        view->dropUrls(view->url(), event);
     }
 }
 
@@ -348,7 +337,7 @@ QString DolphinTabWidget::tabName(const QUrl& url) const
     if (url == QUrl("file:///")) {
         name = '/';
     } else {
-        name = url.fileName();
+        name = url.adjusted(QUrl::StripTrailingSlash).fileName();
         if (name.isEmpty()) {
             name = url.scheme();
         } else {