X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ccea74a99aefcb2c69db4d8307a4bb8b398ed90d..093efca22dfd247f06e2a669ad968300e71ef08d:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index e790a0518..8b36e4ec3 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -51,7 +51,6 @@ #include "viewproperties.h" #include "dolphinsettings.h" #include "dolphin_generalsettings.h" -#include "dolphincategorydrawer.h" DolphinView::DolphinView(QWidget* parent, const KUrl& url, @@ -169,6 +168,17 @@ void DolphinView::setMode(Mode mode) props.setViewMode(m_mode); createView(); + + // Not all view modes support categorized sorting. Adjust the sorting model + // if changing the view mode results in a change of the categorized sorting + // capabilities. + const bool categorized = props.categorizedSorting() && supportsCategorizedSorting(); + if (categorized != categorizedSorting()) { + m_proxyModel->setCategorizedModel(categorized); + m_proxyModel->sort(m_proxyModel->sortColumn(), m_proxyModel->sortOrder()); + emit categorizedSortingChanged(); + } + startDirLister(viewPropsUrl); emit modeChanged(); @@ -223,17 +233,9 @@ void DolphinView::setCategorizedSorting(bool categorized) return; } - if (!categorized && !supportsCategorizedSorting()) - { - m_proxyModel->setCategorizedModel(categorized); - m_proxyModel->sort(m_proxyModel->sortColumn(), m_proxyModel->sortOrder()); - - emit categorizedSortingChanged(); - - return; - } - - Q_ASSERT(m_iconsView != 0); + // setCategorizedSorting(true) may only get invoked + // if the view supports categorized sorting + Q_ASSERT(!categorized || supportsCategorizedSorting()); ViewProperties props(viewPropertiesUrl()); props.setCategorizedSorting(categorized); @@ -616,9 +618,10 @@ void DolphinView::applyViewProperties(const KUrl& url) emit showHiddenFilesChanged(); } - const bool categorized = props.categorizedSorting(); + const bool categorized = props.categorizedSorting() && supportsCategorizedSorting(); if (categorized != categorizedSorting()) { m_proxyModel->setCategorizedModel(categorized); + m_proxyModel->sort(m_proxyModel->sortColumn(), m_proxyModel->sortOrder()); emit categorizedSortingChanged(); } @@ -804,22 +807,20 @@ void DolphinView::createView() // ... and recreate it representing the current mode switch (m_mode) { - case IconsView: + case IconsView: { m_iconsView = new DolphinIconsView(this, m_controller); - m_iconsView->setCategoryDrawer(new DolphinCategoryDrawer()); view = m_iconsView; break; + } case DetailsView: m_detailsView = new DolphinDetailsView(this, m_controller); view = m_detailsView; - setCategorizedSorting(false); break; case ColumnView: m_columnView = new DolphinColumnView(this, m_controller); view = m_columnView; - setCategorizedSorting(false); break; }