X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/78cffd2979a6ed87e044fcb024cf4fdfc5c7cb3d..a509bd76291d330c69cb89284b2d99a3512a199e:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 0566dbf84..590fe336b 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -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(); 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 @@ -1365,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()) { @@ -1488,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.