]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinviewcontainer.cpp
Fix issue that shift + drag does not move files
[dolphin.git] / src / dolphinviewcontainer.cpp
index dcfeca0fdc1f148142de491d5eec935e89c7ed98..df5fe6b15f06c0a0c139afefa06bab4ea1947b91 100644 (file)
 #include <KDesktopFile>
 #include <KFileItemDelegate>
 #include <KFilePlacesModel>
-#include <KGlobalSettings>
 #include <KLocale>
 #include <KIconEffect>
 #include <KIO/NetAccess>
 #include <KIO/PreviewJob>
-#include <KMenu>
 #include <KNewFileMenu>
 #include <konqmimedata.h>
 #include <konq_operations.h>
@@ -49,8 +47,9 @@
 #include "dolphinmainwindow.h"
 #include "filterbar/filterbar.h"
 #include "search/dolphinsearchbox.h"
-#include "settings/dolphinsettings.h"
 #include "statusbar/dolphinstatusbar.h"
+#include "views/dolphinplacesmodel.h"
+#include "views/draganddrophelper.h"
 #include "views/viewmodecontroller.h"
 #include "views/viewproperties.h"
 
@@ -71,7 +70,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     m_topLayout->setSpacing(0);
     m_topLayout->setMargin(0);
 
-    m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this);
+    m_urlNavigator = new KUrlNavigator(DolphinPlacesModel::instance(), url, this);
     connect(m_urlNavigator, SIGNAL(urlsDropped(KUrl,QDropEvent*)),
             this, SLOT(dropUrls(KUrl,QDropEvent*)));
     connect(m_urlNavigator, SIGNAL(activated()),
@@ -79,7 +78,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
             this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
 
-    const GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+    const GeneralSettings* settings = GeneralSettings::self();
     m_urlNavigator->setUrlEditable(settings->editableUrl());
     m_urlNavigator->setShowFullPath(settings->showFullPath());
     m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl()));
@@ -93,20 +92,20 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
 
     m_view = new DolphinView(url, this);
-    connect(m_view, SIGNAL(urlChanged(KUrl)),      m_urlNavigator, SLOT(setUrl(KUrl)));
+    connect(m_view, SIGNAL(urlChanged(KUrl)),             m_urlNavigator, SLOT(setUrl(KUrl)));
     connect(m_view, SIGNAL(writeStateChanged(bool)),      this, SIGNAL(writeStateChanged(bool)));
     connect(m_view, SIGNAL(requestItemInfo(KFileItem)),   this, SLOT(showItemInfo(KFileItem)));
-    connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString)));
-    connect(m_view, SIGNAL(infoMessage(QString)),  this, SLOT(showInfoMessage(QString)));
-    connect(m_view, SIGNAL(itemTriggered(KFileItem)),     this, SLOT(slotItemTriggered(KFileItem)));
-    connect(m_view, SIGNAL(redirection(KUrl,KUrl)),      this, SLOT(redirect(KUrl,KUrl)));
+    connect(m_view, SIGNAL(errorMessage(QString)),        this, SLOT(showErrorMessage(QString)));
+    connect(m_view, SIGNAL(infoMessage(QString)),         this, SLOT(showInfoMessage(QString)));
+    connect(m_view, SIGNAL(itemActivated(KFileItem)),     this, SLOT(slotItemActivated(KFileItem)));
+    connect(m_view, SIGNAL(redirection(KUrl,KUrl)),       this, SLOT(redirect(KUrl,KUrl)));
     connect(m_view, SIGNAL(startedPathLoading(KUrl)),     this, SLOT(slotStartedPathLoading()));
     connect(m_view, SIGNAL(finishedPathLoading(KUrl)),    this, SLOT(slotFinishedPathLoading()));
     connect(m_view, SIGNAL(itemCountChanged()),           this, SLOT(delayedStatusBarUpdate()));
     connect(m_view, SIGNAL(pathLoadingProgress(int)),     this, SLOT(updateProgress(int)));
-    connect(m_view, SIGNAL(infoMessage(QString)),  this, SLOT(showInfoMessage(QString)));
-    connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(showErrorMessage(QString)));
-    connect(m_view, SIGNAL(urlIsFileError(KUrl)),  this, SLOT(openFile(KUrl)));
+    connect(m_view, SIGNAL(infoMessage(QString)),         this, SLOT(showInfoMessage(QString)));
+    connect(m_view, SIGNAL(errorMessage(QString)),        this, SLOT(showErrorMessage(QString)));
+    connect(m_view, SIGNAL(urlIsFileError(KUrl)),         this, SLOT(openFile(KUrl)));
     connect(m_view, SIGNAL(selectionChanged(KFileItemList)),    this, SLOT(delayedStatusBarUpdate()));
     connect(m_view, SIGNAL(operationCompletedMessage(QString)), this, SLOT(showOperationCompletedMessage(QString)));
     connect(m_view, SIGNAL(urlAboutToBeChanged(KUrl)),          this, SLOT(slotViewUrlAboutToBeChanged(KUrl)));
@@ -214,14 +213,13 @@ DolphinSearchBox* DolphinViewContainer::searchBox()
 
 void DolphinViewContainer::refresh()
 {
-    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
-    if (settings->modifiedStartupSettings()) {
+    if (GeneralSettings::modifiedStartupSettings()) {
         // The startup settings should only get applied if they have been
         // modified by the user. Otherwise keep the (possibly) different current
         // settings of the URL navigator and the filterbar.
-        m_urlNavigator->setUrlEditable(settings->editableUrl());
-        m_urlNavigator->setShowFullPath(settings->showFullPath());
-        setFilterBarVisible(settings->filterBar());
+        m_urlNavigator->setUrlEditable(GeneralSettings::editableUrl());
+        m_urlNavigator->setShowFullPath(GeneralSettings::showFullPath());
+        setFilterBarVisible(GeneralSettings::filterBar());
     }
 
     m_view->refresh();
@@ -373,7 +371,7 @@ void DolphinViewContainer::slotFinishedPathLoading()
     }
 }
 
-void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
+void DolphinViewContainer::slotItemActivated(const KFileItem& item)
 {
     KUrl url = item.targetUrl();
 
@@ -382,9 +380,7 @@ void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
         return;
     }
 
-    const GeneralSettings* settings = DolphinSettings::instance().generalSettings();
-    const bool browseThroughArchives = settings->browseThroughArchives();
-    if (browseThroughArchives && item.isFile() && url.isLocalFile()) {
+    if (GeneralSettings::browseThroughArchives() && item.isFile() && url.isLocalFile()) {
         // Generic mechanism for redirecting to tar:/<path>/ when clicking on a tar file,
         // zip:/<path>/ when clicking on a zip file, etc.
         // The .protocol file specifies the mimetype that the kioslave handles.
@@ -414,7 +410,7 @@ void DolphinViewContainer::slotItemTriggered(const KFileItem& item)
 void DolphinViewContainer::openFile(const KUrl& url)
 {
     const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
-    slotItemTriggered(item);
+    slotItemActivated(item);
 }
 
 void DolphinViewContainer::showItemInfo(const KFileItem& item)
@@ -428,7 +424,13 @@ void DolphinViewContainer::showItemInfo(const KFileItem& item)
             m_statusBar->clear();
         }
     } else {
-        m_statusBar->setMessage(item.getStatusBarInfo(), DolphinStatusBar::Default);
+        QString message;
+        if (item.isDir()) {
+            message = item.text();
+        } else {
+            message = i18nc("@info:status filename (type)", "%1 (%2)", item.text(), item.mimeComment());
+        }
+        m_statusBar->setMessage(message, DolphinStatusBar::Default);
     }
 }
 
@@ -531,9 +533,8 @@ void DolphinViewContainer::slotUrlNavigatorLocationChanged(const KUrl& url)
 
 void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event)
 {
-    Q_UNUSED(destination);
-    Q_UNUSED(event);
-    //DragAndDropHelper::instance().dropUrls(KFileItem(), destination, event, this);
+    const KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, destination);
+    DragAndDropHelper::dropUrls(destItem, event);
 }
 
 void DolphinViewContainer::redirect(const KUrl& oldUrl, const KUrl& newUrl)
@@ -559,9 +560,7 @@ void DolphinViewContainer::requestFocus()
 
 void DolphinViewContainer::saveUrlCompletionMode(KGlobalSettings::Completion completion)
 {
-    DolphinSettings& settings = DolphinSettings::instance();
-    settings.generalSettings()->setUrlCompletionMode(completion);
-    settings.save();
+    GeneralSettings::setUrlCompletionMode(completion);
 }
 
 void DolphinViewContainer::slotHistoryChanged()