From: Peter Penz Date: Wed, 26 Sep 2007 15:26:30 +0000 (+0000) Subject: Assure that the categorized sorting is applied correctly to the proxy model if the... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/34a19e156e2e38b0c26824918277cc047b88a449?ds=sidebyside Assure that the categorized sorting is applied correctly to the proxy model if the view does not support the categorization feature (currently only the icons view supports this). Take care that switching between e. g. the icons-view and the details-view does not change the stored categorized sorting. Thanks to Rafael for the initial patch! CCMAIL: ereslibre@gmail.com svn path=/trunk/KDE/kdebase/apps/; revision=717300 --- diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 73b44e6fb..8b36e4ec3 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -168,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(); @@ -222,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); @@ -615,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(); } @@ -812,19 +816,11 @@ void DolphinView::createView() case DetailsView: m_detailsView = new DolphinDetailsView(this, m_controller); view = m_detailsView; - - // categorized sorting is not supported yet for the details - // view, even if the view properties indicate this - setCategorizedSorting(false); break; case ColumnView: m_columnView = new DolphinColumnView(this, m_controller); view = m_columnView; - - // categorized sorting is not supported yet for the column - // view, even if the view properties indicate this - setCategorizedSorting(false); break; }