]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Fix item highlighting through DBus
[dolphin.git] / src / views / dolphinview.cpp
index f235efffe2cdd391b20ccb794778d246f1c39a2a..590fe336b76e23d1cacd9161903bce871a777e0c 100644 (file)
@@ -40,7 +40,6 @@
 #include <KIO/JobUiDelegate>
 #include <KIO/Paste>
 #include <KIO/PasteJob>
-#include <KIO/PreviewJob>
 #include <KIO/RenameFileDialog>
 #include <KJobWidgets>
 #include <KLocalizedString>
@@ -111,7 +110,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
 
     m_model = new KFileItemModel(this);
     m_view = new DolphinItemListView();
-    m_view->setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
+    m_view->setEnabledSelectionToggles(DolphinItemListView::SelectionTogglesEnabled::FollowSetting);
     m_view->setVisibleRoles({"text"});
     applyModeToView();
 
@@ -173,7 +172,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
     connect(controller, &KItemListController::increaseZoom, this, &DolphinView::slotIncreaseZoom);
     connect(controller, &KItemListController::decreaseZoom, this, &DolphinView::slotDecreaseZoom);
     connect(controller, &KItemListController::swipeUp, this, &DolphinView::slotSwipeUp);
-    connect(controller, &KItemListController::selectionModeRequested, this, &DolphinView::selectionModeRequested);
+    connect(controller, &KItemListController::selectionModeChangeRequested, this, &DolphinView::selectionModeChangeRequested);
 
     connect(m_model, &KFileItemModel::directoryLoadingStarted,       this, &DolphinView::slotDirectoryLoadingStarted);
     connect(m_model, &KFileItemModel::directoryLoadingCompleted,     this, &DolphinView::slotDirectoryLoadingCompleted);
@@ -235,6 +234,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
 
 DolphinView::~DolphinView()
 {
+    disconnect(m_container->controller(), &KItemListController::modelChanged, this, &DolphinView::slotModelChanged);
 }
 
 QUrl DolphinView::url() const
@@ -283,17 +283,19 @@ DolphinView::Mode DolphinView::viewMode() const
     return m_mode;
 }
 
-void DolphinView::setSelectionMode(const bool enabled)
+void DolphinView::setSelectionModeEnabled(const bool enabled)
 {
     if (enabled) {
         m_proxyStyle = std::make_unique<SelectionMode::SingleClickSelectionProxyStyle>();
         setStyle(m_proxyStyle.get());
         m_view->setStyle(m_proxyStyle.get());
+        m_view->setEnabledSelectionToggles(DolphinItemListView::SelectionTogglesEnabled::False);
     } else {
         setStyle(QApplication::style());
         m_view->setStyle(QApplication::style());
+        m_view->setEnabledSelectionToggles(DolphinItemListView::SelectionTogglesEnabled::FollowSetting);
     }
-    m_container->controller()->setSelectionMode(enabled);
+    m_container->controller()->setSelectionModeEnabled(enabled);
 }
 
 bool DolphinView::selectionMode() const
@@ -301,7 +303,6 @@ bool DolphinView::selectionMode() const
     return m_container->controller()->selectionMode();
 }
 
-
 void DolphinView::setPreviewsShown(bool show)
 {
     if (previewsShown() == show) {
@@ -1366,7 +1367,7 @@ void DolphinView::slotItemCreated(const QUrl& url)
 
 void DolphinView::slotJobResult(KJob *job)
 {
-    if (job->error()) {
+    if (job->error() && job->error() != KIO::ERR_USER_CANCELED) {
         Q_EMIT errorMessage(job->errorString());
     }
     if (!m_selectedUrls.isEmpty()) {
@@ -1489,6 +1490,16 @@ bool DolphinView::itemsExpandable() const
     return m_mode == DetailsView;
 }
 
+bool DolphinView::isExpanded(const KFileItem& item) const
+{
+    Q_ASSERT(item.isDir());
+    Q_ASSERT(items().contains(item));
+    if (!itemsExpandable()) {
+        return false;
+    }
+    return m_model->isExpanded(m_model->index(item));
+}
+
 void DolphinView::restoreState(QDataStream& stream)
 {
     // Read the version number of the view state and check if the version is supported.