┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-10-15 22:55:01 +0200
committerPeter Penz <[email protected]>2011-10-15 22:55:01 +0200
commit283f97ac27c3cfe5c72682b0843503e31643a612 (patch)
tree35325115a5e5c001e1e307acc580af572bad0ac1 /src/views
parenta49109b09a191b73f3fda8b65c29e9c6c9bd33d8 (diff)
Interface cleanups to prepare the return of "grouped sorting"
- Rename setCategorizedSorting() to setGroupedSorting() - Change the model interface to allow enabling/disabling grouping without the need to declare a role (the sort role will be taken). - Add dummy group role implementation in KFileItemModel The grouping code itself requires some cleanups and might crash at the moment or lead to weird layouts.
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp110
-rw-r--r--src/views/dolphinview.h56
-rw-r--r--src/views/dolphinviewactionhandler.cpp15
-rw-r--r--src/views/dolphinviewactionhandler.h6
-rw-r--r--src/views/viewproperties.cpp12
-rw-r--r--src/views/viewproperties.h4
6 files changed, 96 insertions, 107 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 2bd95767a..871de946b 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -267,19 +267,65 @@ DolphinView::Mode DolphinView::mode() const
return m_mode;
}
+void DolphinView::setPreviewsShown(bool show)
+{
+ if (previewsShown() == show) {
+ return;
+ }
+
+ ViewProperties props(url());
+ props.setPreviewsShown(show);
+
+ m_container->setPreviewsShown(show);
+ emit previewsShownChanged(show);
+}
+
bool DolphinView::previewsShown() const
{
return m_container->previewsShown();
}
+void DolphinView::setHiddenFilesShown(bool show)
+{
+ if (m_dirLister->showingDotFiles() == show) {
+ return;
+ }
+
+ const KFileItemList itemList = selectedItems();
+ m_selectedUrls.clear();
+ m_selectedUrls = itemList.urlList();
+
+ ViewProperties props(url());
+ props.setHiddenFilesShown(show);
+
+ m_dirLister->setShowingDotFiles(show);
+ m_dirLister->emitChanges();
+ emit hiddenFilesShownChanged(show);
+}
+
bool DolphinView::hiddenFilesShown() const
{
return m_dirLister->showingDotFiles();
}
-bool DolphinView::categorizedSorting() const
+void DolphinView::setGroupedSorting(bool grouped)
+{
+ if (grouped == groupedSorting()) {
+ return;
+ }
+
+ ViewProperties props(url());
+ props.setGroupedSorting(grouped);
+ props.save();
+
+ m_container->controller()->model()->setGroupedSorting(grouped);
+
+ emit groupedSortingChanged(grouped);
+}
+
+bool DolphinView::groupedSorting() const
{
- return false; //m_storedCategorizedSorting;
+ return fileItemModel()->groupedSorting();
}
KFileItemList DolphinView::items() const
@@ -650,52 +696,6 @@ void DolphinView::pasteIntoFolder()
}
}
-void DolphinView::setPreviewsShown(bool show)
-{
- if (previewsShown() == show) {
- return;
- }
-
- ViewProperties props(url());
- props.setPreviewsShown(show);
-
- m_container->setPreviewsShown(show);
- emit previewsShownChanged(show);
-}
-
-void DolphinView::setHiddenFilesShown(bool show)
-{
- if (m_dirLister->showingDotFiles() == show) {
- return;
- }
-
- const KFileItemList itemList = selectedItems();
- m_selectedUrls.clear();
- m_selectedUrls = itemList.urlList();
-
- ViewProperties props(url());
- props.setHiddenFilesShown(show);
-
- m_dirLister->setShowingDotFiles(show);
- m_dirLister->emitChanges();
- emit hiddenFilesShownChanged(show);
-}
-
-void DolphinView::setCategorizedSorting(bool categorized)
-{
- if (categorized == categorizedSorting()) {
- return;
- }
-
- ViewProperties props(url());
- props.setCategorizedSorting(categorized);
- props.save();
-
- //m_viewAccessor.proxyModel()->setCategorizedModel(categorized);
-
- emit categorizedSortingChanged(categorized);
-}
-
bool DolphinView::eventFilter(QObject* watched, QEvent* event)
{
switch (event->type()) {
@@ -1198,15 +1198,15 @@ void DolphinView::applyViewProperties()
emit hiddenFilesShownChanged(hiddenFilesShown);
}
-/* m_storedCategorizedSorting = props.categorizedSorting();
- const bool categorized = m_storedCategorizedSorting && supportsCategorizedSorting();
- if (categorized != m_viewAccessor.proxyModel()->isCategorizedModel()) {
- m_viewAccessor.proxyModel()->setCategorizedModel(categorized);
- emit categorizedSortingChanged();
- }*/
+ KFileItemModel* model = fileItemModel();
+
+ const bool groupedSorting = props.groupedSorting();
+ if (groupedSorting != model->groupedSorting()) {
+ model->setGroupedSorting(groupedSorting);
+ emit groupedSortingChanged(groupedSorting);
+ }
const DolphinView::Sorting sorting = props.sorting();
- KFileItemModel* model = fileItemModel();
const QByteArray newSortRole = sortRoleForSorting(sorting);
if (newSortRole != model->sortRole()) {
model->setSortRole(newSortRole);
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 770bbde72..c681737c6 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -152,14 +152,31 @@ public:
void setMode(Mode mode);
Mode mode() const;
- /** See setPreviewsShown */
+ /**
+ * Turns on the file preview for the all files of the current directory,
+ * if \a show is true.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * preview setting will be stored automatically.
+ */
+ void setPreviewsShown(bool show);
bool previewsShown() const;
- /** See setShowHiddenFiles */
+ /**
+ * Shows all hidden files of the current directory,
+ * if \a show is true.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * show hidden file setting will be stored automatically.
+ */
+ void setHiddenFilesShown(bool show);
bool hiddenFilesShown() const;
- /** See setCategorizedSorting */
- bool categorizedSorting() const;
+ /**
+ * Turns on sorting by groups if \a enable is true.
+ */
+ void setGroupedSorting(bool grouped);
+ bool groupedSorting() const;
/**
* Returns the items of the view.
@@ -382,33 +399,6 @@ public slots:
*/
void pasteIntoFolder();
- /**
- * Turns on the file preview for the all files of the current directory,
- * if \a show is true.
- * If the view properties should be remembered for each directory
- * (GeneralSettings::globalViewProps() returns false), then the
- * preview setting will be stored automatically.
- */
- void setPreviewsShown(bool show);
-
- /**
- * Shows all hidden files of the current directory,
- * if \a show is true.
- * If the view properties should be remembered for each directory
- * (GeneralSettings::globalViewProps() returns false), then the
- * show hidden file setting will be stored automatically.
- */
- void setHiddenFilesShown(bool show);
-
- /**
- * Summarizes all sorted items by their category \a categorized
- * is true.
- * If the view properties should be remembered for each directory
- * (GeneralSettings::globalViewProps() returns false), then the
- * categorized sorting setting will be stored automatically.
- */
- void setCategorizedSorting(bool categorized);
-
/** Activates the view if the item list container gets focus. */
virtual bool eventFilter(QObject* watched, QEvent* event);
@@ -455,8 +445,8 @@ signals:
/** Is emitted if the 'show hidden files' property has been changed. */
void hiddenFilesShownChanged(bool shown);
- /** Is emitted if the 'categorized sorting' property has been changed. */
- void categorizedSortingChanged(bool sortCategorized);
+ /** Is emitted if the 'grouped sorting' property has been changed. */
+ void groupedSortingChanged(bool groupedSorting);
/** Is emitted if the sorting by name, size or date has been changed. */
void sortingChanged(DolphinView::Sorting sorting);
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp
index cdc9646c6..f765b4a09 100644
--- a/src/views/dolphinviewactionhandler.cpp
+++ b/src/views/dolphinviewactionhandler.cpp
@@ -70,7 +70,7 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
this, SLOT(slotAdditionalInfoListChanged(QList<DolphinView::AdditionalInfo>,
QList<DolphinView::AdditionalInfo>)));
connect(view, SIGNAL(categorizedSortingChanged(bool)),
- this, SLOT(slotCategorizedSortingChanged(bool)));
+ this, SLOT(slotGroupedSortingChanged(bool)));
connect(view, SIGNAL(hiddenFilesShownChanged(bool)),
this, SLOT(slotHiddenFilesShownChanged(bool)));
connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
@@ -196,7 +196,7 @@ void DolphinViewActionHandler::createActions()
KToggleAction* showInGroups = m_actionCollection->add<KToggleAction>("show_in_groups");
showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
- connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleSortCategorization(bool)));
+ connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleGroupedSorting(bool)));
KToggleAction* showHiddenFiles = m_actionCollection->add<KToggleAction>("show_hidden_files");
showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
@@ -339,7 +339,7 @@ void DolphinViewActionHandler::updateViewActions()
slotSortOrderChanged(m_currentView->sortOrder());
slotSortFoldersFirstChanged(m_currentView->sortFoldersFirst());
slotAdditionalInfoListChanged(m_currentView->additionalInfoList(), QList<DolphinView::AdditionalInfo>());
- slotCategorizedSortingChanged(m_currentView->categorizedSorting());
+ slotGroupedSortingChanged(m_currentView->groupedSorting());
slotSortingChanged(m_currentView->sorting());
slotZoomLevelChanged(m_currentView->zoomLevel(), -1);
@@ -428,15 +428,15 @@ void DolphinViewActionHandler::slotAdditionalInfoListChanged(const QList<Dolphin
}
}
-void DolphinViewActionHandler::toggleSortCategorization(bool categorizedSorting)
+void DolphinViewActionHandler::toggleGroupedSorting(bool grouped)
{
- m_currentView->setCategorizedSorting(categorizedSorting);
+ m_currentView->setGroupedSorting(grouped);
}
-void DolphinViewActionHandler::slotCategorizedSortingChanged(bool sortCategorized)
+void DolphinViewActionHandler::slotGroupedSortingChanged(bool groupedSorting)
{
QAction* showInGroupsAction = m_actionCollection->action("show_in_groups");
- showInGroupsAction->setChecked(sortCategorized);
+ showInGroupsAction->setChecked(groupedSorting);
}
void DolphinViewActionHandler::toggleShowHiddenFiles(bool show)
@@ -451,7 +451,6 @@ void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown)
showHiddenFilesAction->setChecked(shown);
}
-
KToggleAction* DolphinViewActionHandler::iconsModeAction()
{
KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("icons");
diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h
index 4e5a0d32f..647c6390c 100644
--- a/src/views/dolphinviewactionhandler.h
+++ b/src/views/dolphinviewactionhandler.h
@@ -176,14 +176,14 @@ private Q_SLOTS:
const QList<DolphinView::AdditionalInfo>& previous);
/**
- * Switches between sorting by categories or not.
+ * Switches between sorting by groups or not.
*/
- void toggleSortCategorization(bool);
+ void toggleGroupedSorting(bool);
/**
* Updates the state of the 'Categorized sorting' menu action.
*/
- void slotCategorizedSortingChanged(bool sortCategorized);
+ void slotGroupedSortingChanged(bool sortCategorized);
/**
* Switches between showing and hiding of hidden marked files
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index e67cbd87a..bb747139f 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -143,17 +143,17 @@ void ViewProperties::setHiddenFilesShown(bool show)
}
}
-void ViewProperties::setCategorizedSorting(bool categorized)
+void ViewProperties::setGroupedSorting(bool grouped)
{
- if (m_node->categorizedSorting() != categorized) {
- m_node->setCategorizedSorting(categorized);
+ if (m_node->groupedSorting() != grouped) {
+ m_node->setGroupedSorting(grouped);
update();
}
}
-bool ViewProperties::categorizedSorting() const
+bool ViewProperties::groupedSorting() const
{
- return m_node->categorizedSorting();
+ return m_node->groupedSorting();
}
bool ViewProperties::hiddenFilesShown() const
@@ -312,7 +312,7 @@ void ViewProperties::setDirProperties(const ViewProperties& props)
setViewMode(props.viewMode());
setPreviewsShown(props.previewsShown());
setHiddenFilesShown(props.hiddenFilesShown());
- setCategorizedSorting(props.categorizedSorting());
+ setGroupedSorting(props.groupedSorting());
setSorting(props.sorting());
setSortOrder(props.sortOrder());
setSortFoldersFirst(props.sortFoldersFirst());
diff --git a/src/views/viewproperties.h b/src/views/viewproperties.h
index c95134a15..50b3b3f1e 100644
--- a/src/views/viewproperties.h
+++ b/src/views/viewproperties.h
@@ -62,8 +62,8 @@ public:
void setHiddenFilesShown(bool show);
bool hiddenFilesShown() const;
- void setCategorizedSorting(bool categorized);
- bool categorizedSorting() const;
+ void setGroupedSorting(bool grouped);
+ bool groupedSorting() const;
void setSorting(DolphinView::Sorting sorting);
DolphinView::Sorting sorting() const;