]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Merge remote-tracking branch 'origin/KDE/4.11' into KDE/4.12
[dolphin.git] / src / dolphinmainwindow.cpp
index ccef356ea2a01ab9a72916918817af4cd2b84959..a4dbb6f341c02404baf3dc5d41e037689cae8446 100644 (file)
 #include "panels/information/informationpanel.h"
 #include "settings/dolphinsettingsdialog.h"
 #include "statusbar/dolphinstatusbar.h"
-#include "views/dolphinview.h"
 #include "views/dolphinviewactionhandler.h"
 #include "views/dolphinremoteencoding.h"
 #include "views/draganddrophelper.h"
 #include "views/viewproperties.h"
+#include "views/dolphinnewfilemenuobserver.h"
 
 #ifndef Q_OS_WIN
 #include "panels/terminal/terminalpanel.h"
@@ -127,6 +127,9 @@ DolphinMainWindow::DolphinMainWindow() :
     ViewTab& viewTab = m_viewTab[m_tabIndex];
     viewTab.wasActive = true; // The first opened tab is automatically active
 
+    connect(&DolphinNewFileMenuObserver::instance(), SIGNAL(errorMessage(QString)),
+            this, SLOT(showErrorMessage(QString)));
+
     KIO::FileUndoManager* undoManager = KIO::FileUndoManager::self();
     undoManager->setUiInterface(new UndoUiInterface());
 
@@ -244,20 +247,8 @@ void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
         return;
     }
 
-    // dirs could contain URLs that actually point to archives or other files.
-    // Replace them by URLs we can open where possible and filter the rest out.
-    QList<KUrl> urlsToOpen;
-    foreach (const KUrl& rawUrl, dirs) {
-        const KFileItem& item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, rawUrl);
-        item.determineMimeType();
-        const KUrl& url = DolphinView::openItemAsFolderUrl(item);
-        if (!url.isEmpty()) {
-            urlsToOpen.append(url);
-        }
-    }
-
-    if (urlsToOpen.count() == 1) {
-        m_activeViewContainer->setUrl(urlsToOpen.first());
+    if (dirs.count() == 1) {
+        m_activeViewContainer->setUrl(dirs.first());
         return;
     }
 
@@ -267,12 +258,12 @@ void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
 
     // Open each directory inside a new tab. If the "split view" option has been enabled,
     // always show two directories within one tab.
-    QList<KUrl>::const_iterator it = urlsToOpen.begin();
-    while (it != urlsToOpen.end()) {
+    QList<KUrl>::const_iterator it = dirs.constBegin();
+    while (it != dirs.constEnd()) {
         openNewTab(*it);
         ++it;
 
-        if (hasSplitView && (it != urlsToOpen.end())) {
+        if (hasSplitView && (it != dirs.constEnd())) {
             const int tabIndex = m_viewTab.count() - 1;
             m_viewTab[tabIndex].secondaryView->setUrl(*it);
             ++it;
@@ -1417,6 +1408,19 @@ void DolphinMainWindow::slotPanelErrorMessage(const QString& error)
     activeViewContainer()->showMessage(error, DolphinViewContainer::Error);
 }
 
+void DolphinMainWindow::slotPlaceActivated(const KUrl& url)
+{
+    DolphinViewContainer* view = activeViewContainer();
+
+    if (view->url() == url) {
+        // We can end up here if the user clicked a device in the Places Panel
+        // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385.
+        reloadView();
+    } else {
+        changeUrl(url);
+    }
+}
+
 void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
 {
     Q_ASSERT(viewContainer);
@@ -1468,7 +1472,7 @@ DolphinViewContainer* DolphinMainWindow::createViewContainer(const KUrl& url, QW
 void DolphinMainWindow::setupActions()
 {
     // setup 'File' menu
-    m_newFileMenu = new DolphinNewFileMenu(this);
+    m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
     KMenu* menu = m_newFileMenu->menu();
     menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
     menu->setIcon(KIcon("document-new"));
@@ -1749,7 +1753,7 @@ void DolphinMainWindow::setupDockWidgets()
 
     addDockWidget(Qt::LeftDockWidgetArea, placesDock);
     connect(placesPanel, SIGNAL(placeActivated(KUrl)),
-            this, SLOT(changeUrl(KUrl)));
+            this, SLOT(slotPlaceActivated(KUrl)));
     connect(placesPanel, SIGNAL(placeMiddleClicked(KUrl)),
             this, SLOT(openNewTab(KUrl)));
     connect(placesPanel, SIGNAL(errorMessage(QString)),