Use case: categorized sorting is enabled, the current view mode is icons-view. When switching to the details-view (which does not support categorized sorting yet), the 'categorized sorting' action should get only disabled to indicate that it is not available, not get unchecked (currently it gets disabled AND unchecked). This patch assures that always the stored categorization state is returned for the menu actions, but internally the categorization is turned off for the proxy model for the details view and column view.

CCMAIL: ereslibre@gmail.com

svn path=/trunk/KDE/kdebase/apps/; revision=717548
This commit is contained in:
Peter Penz 2007-09-27 06:19:30 +00:00
parent 341c16eba6
commit c152767131
2 changed files with 15 additions and 3 deletions

View file

@ -61,6 +61,7 @@ DolphinView::DolphinView(QWidget* parent,
m_active(true),
m_loadingDirectory(false),
m_initializeColumnView(false),
m_storedCategorizedSorting(false),
m_mode(DolphinView::IconsView),
m_topLayout(0),
m_controller(0),
@ -172,7 +173,8 @@ void DolphinView::setMode(Mode mode)
// 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();
m_storedCategorizedSorting = props.categorizedSorting();
const bool categorized = m_storedCategorizedSorting && supportsCategorizedSorting();
if (categorized != categorizedSorting()) {
m_proxyModel->setCategorizedModel(categorized);
m_proxyModel->sort(m_proxyModel->sortColumn(), m_proxyModel->sortOrder());
@ -241,6 +243,7 @@ void DolphinView::setCategorizedSorting(bool categorized)
props.setCategorizedSorting(categorized);
props.save();
m_storedCategorizedSorting = categorized;
m_proxyModel->setCategorizedModel(categorized);
m_proxyModel->sort(m_proxyModel->sortColumn(), m_proxyModel->sortOrder());
@ -249,7 +252,14 @@ void DolphinView::setCategorizedSorting(bool categorized)
bool DolphinView::categorizedSorting() const
{
return m_proxyModel->isCategorizedModel();
// If all view modes would support categorized sorting, returning
// m_proxyModel->isCategorizedModel() would be the way to go. As
// currently only the icons view supports caterized sorting, we remember
// the stored view properties state in m_storedCategorizedSorting and
// return this state. The application takes care to disable the corresponding
// checkbox by checking DolphinView::supportsCategorizedSorting() to indicate
// that this setting is not applied to the current view mode.
return m_storedCategorizedSorting;
}
bool DolphinView::supportsCategorizedSorting() const
@ -618,7 +628,8 @@ void DolphinView::applyViewProperties(const KUrl& url)
emit showHiddenFilesChanged();
}
const bool categorized = props.categorizedSorting() && supportsCategorizedSorting();
m_storedCategorizedSorting = props.categorizedSorting();
const bool categorized = m_storedCategorizedSorting && supportsCategorizedSorting();
if (categorized != categorizedSorting()) {
m_proxyModel->setCategorizedModel(categorized);
m_proxyModel->sort(m_proxyModel->sortColumn(), m_proxyModel->sortOrder());

View file

@ -573,6 +573,7 @@ private:
bool m_active;
bool m_loadingDirectory;
bool m_initializeColumnView;
bool m_storedCategorizedSorting;
Mode m_mode;
DolphinMainWindow* m_mainWindow;