mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
allow to enable the categorization feature for sorting
svn path=/trunk/KDE/kdebase/apps/; revision=652200
This commit is contained in:
parent
5b5a7b8da8
commit
6422ae393e
|
@ -29,6 +29,12 @@
|
|||
<default>false</default>
|
||||
</entry>
|
||||
|
||||
<entry name="CategorizedSorting" type="Bool" >
|
||||
<label>Categorized Sorting</label>
|
||||
<whatsthis>When this option is enabled, the sorted items get summarized by their category.</whatsthis>
|
||||
<default>false</default>
|
||||
</entry>
|
||||
|
||||
<entry name="Sorting" type="Int" >
|
||||
<label>Sort files by</label>
|
||||
<whatsthis>This option defines which attribute (name, size, date, etc) sorting is performed on.</whatsthis>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "dolphiniconsview.h"
|
||||
|
||||
#include "dolphinitemcategorizer.h"
|
||||
#include "dolphincontroller.h"
|
||||
#include "dolphinsettings.h"
|
||||
#include "dolphinitemcategorizer.h"
|
||||
|
@ -35,8 +34,7 @@
|
|||
|
||||
DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
|
||||
KListView(parent),
|
||||
m_controller(controller),
|
||||
m_itemCategorizer(0)
|
||||
m_controller(controller)
|
||||
{
|
||||
Q_ASSERT(controller != 0);
|
||||
setViewMode(QListView::IconMode);
|
||||
|
@ -75,17 +73,10 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
|
|||
setFlow(QListView::TopToBottom);
|
||||
m_viewOptions.decorationPosition = QStyleOptionViewItem::Left;
|
||||
}
|
||||
|
||||
m_itemCategorizer = new DolphinItemCategorizer();
|
||||
// setItemCategorizer(m_itemCategorizer);
|
||||
}
|
||||
|
||||
DolphinIconsView::~DolphinIconsView()
|
||||
{
|
||||
setItemCategorizer(0);
|
||||
delete m_itemCategorizer;
|
||||
m_itemCategorizer = 0;
|
||||
}
|
||||
{}
|
||||
|
||||
QStyleOptionViewItem DolphinIconsView::viewOptions() const
|
||||
{
|
||||
|
|
|
@ -73,7 +73,6 @@ private:
|
|||
private:
|
||||
DolphinController* m_controller;
|
||||
QStyleOptionViewItem m_viewOptions;
|
||||
DolphinItemCategorizer* m_itemCategorizer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -275,6 +275,14 @@ void DolphinMainWindow::slotShowHiddenFilesChanged()
|
|||
showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
|
||||
}
|
||||
|
||||
void DolphinMainWindow::slotCategorizedSortingChanged()
|
||||
{
|
||||
KToggleAction* categorizedSortingAction =
|
||||
static_cast<KToggleAction*>(actionCollection()->action("categorized"));
|
||||
categorizedSortingAction->setChecked(m_activeView->categorizedSorting());
|
||||
categorizedSortingAction->setEnabled(m_activeView->supportsCategorizedSorting());
|
||||
}
|
||||
|
||||
void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
|
||||
{
|
||||
QAction* action = 0;
|
||||
|
@ -714,6 +722,12 @@ void DolphinMainWindow::toggleSortOrder()
|
|||
m_activeView->setSortOrder(order);
|
||||
}
|
||||
|
||||
void DolphinMainWindow::toggleSortCategorization()
|
||||
{
|
||||
const bool categorizedSorting = m_activeView->categorizedSorting();
|
||||
m_activeView->setCategorizedSorting(!categorizedSorting);
|
||||
}
|
||||
|
||||
void DolphinMainWindow::clearInfo()
|
||||
{
|
||||
m_activeView->setAdditionalInfo(KFileItemDelegate::NoInformation);
|
||||
|
@ -1157,6 +1171,10 @@ void DolphinMainWindow::setupActions()
|
|||
sortDescending->setText(i18n("Descending"));
|
||||
connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
|
||||
|
||||
KToggleAction* sortCategorized = actionCollection()->add<KToggleAction>("categorized");
|
||||
sortCategorized->setText(i18n("Categorized"));
|
||||
connect(sortCategorized, SIGNAL(triggered()), this, SLOT(toggleSortCategorization()));
|
||||
|
||||
KToggleAction* clearInfo = actionCollection()->add<KToggleAction>("clear_info");
|
||||
clearInfo->setText(i18n("No Information"));
|
||||
connect(clearInfo, SIGNAL(triggered()), this, SLOT(clearInfo()));
|
||||
|
@ -1391,6 +1409,7 @@ void DolphinMainWindow::updateViewActions()
|
|||
|
||||
slotSortingChanged(m_activeView->sorting());
|
||||
slotSortOrderChanged(m_activeView->sortOrder());
|
||||
slotCategorizedSortingChanged();
|
||||
slotAdditionalInfoChanged(m_activeView->additionalInfo());
|
||||
|
||||
KToggleAction* showFilterBarAction =
|
||||
|
@ -1452,6 +1471,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex)
|
|||
this, SLOT(slotShowPreviewChanged()));
|
||||
connect(view, SIGNAL(showHiddenFilesChanged()),
|
||||
this, SLOT(slotShowHiddenFilesChanged()));
|
||||
connect(view, SIGNAL(categorizedSortingChanged()),
|
||||
this, SLOT(slotCategorizedSortingChanged()));
|
||||
connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
|
||||
this, SLOT(slotSortingChanged(DolphinView::Sorting)));
|
||||
connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
|
||||
|
|
|
@ -265,6 +265,9 @@ private slots:
|
|||
/** Switches between an ascending and descending sorting order. */
|
||||
void toggleSortOrder();
|
||||
|
||||
/** Switches between sorting by categories or not. */
|
||||
void toggleSortCategorization();
|
||||
|
||||
/**
|
||||
* Clears any additional information for an item except for the
|
||||
* name and the icon.
|
||||
|
@ -364,6 +367,9 @@ private slots:
|
|||
/** Updates the state of the 'Show hidden files' menu action. */
|
||||
void slotShowHiddenFilesChanged();
|
||||
|
||||
/** Updates the state of the 'Categorized sorting' menu action. */
|
||||
void slotCategorizedSortingChanged();
|
||||
|
||||
/** Updates the state of the 'Sort by' actions. */
|
||||
void slotSortingChanged(DolphinView::Sorting sorting);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<Action name="by_group" />
|
||||
<Separator/>
|
||||
<Action name="descending" />
|
||||
<Action name="categorized" />
|
||||
</Menu>
|
||||
<Menu name="additional_info">
|
||||
<text>Additional Information</text>
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "dolphindetailsview.h"
|
||||
#include "dolphiniconsview.h"
|
||||
#include "dolphincontextmenu.h"
|
||||
#include "dolphinitemcategorizer.h"
|
||||
#include "filterbar.h"
|
||||
#include "renamedialog.h"
|
||||
#include "kurlnavigator.h"
|
||||
|
@ -255,6 +256,44 @@ bool DolphinView::showHiddenFiles() const
|
|||
return m_dirLister->showingDotFiles();
|
||||
}
|
||||
|
||||
void DolphinView::setCategorizedSorting(bool categorized)
|
||||
{
|
||||
if (!supportsCategorizedSorting() || (categorized == categorizedSorting())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_iconsView != 0);
|
||||
if (categorized) {
|
||||
Q_ASSERT(m_iconsView->itemCategorizer() == 0);
|
||||
m_iconsView->setItemCategorizer(new DolphinItemCategorizer());
|
||||
} else {
|
||||
KItemCategorizer* categorizer = m_iconsView->itemCategorizer();
|
||||
m_iconsView->setItemCategorizer(0);
|
||||
delete categorizer;
|
||||
}
|
||||
|
||||
ViewProperties props(m_urlNavigator->url());
|
||||
props.setCategorizedSorting(categorized);
|
||||
props.save();
|
||||
|
||||
emit categorizedSortingChanged();
|
||||
}
|
||||
|
||||
bool DolphinView::categorizedSorting() const
|
||||
{
|
||||
if (!supportsCategorizedSorting()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_iconsView != 0);
|
||||
return m_iconsView->itemCategorizer() != 0;
|
||||
}
|
||||
|
||||
bool DolphinView::supportsCategorizedSorting() const
|
||||
{
|
||||
return m_iconsView != 0;
|
||||
}
|
||||
|
||||
void DolphinView::renameSelectedItems()
|
||||
{
|
||||
DolphinView* view = mainWindow()->activeView();
|
||||
|
@ -612,6 +651,22 @@ void DolphinView::loadDirectory(const KUrl& url)
|
|||
emit showHiddenFilesChanged();
|
||||
}
|
||||
|
||||
const bool categorized = props.categorizedSorting();
|
||||
if (categorized != categorizedSorting()) {
|
||||
if (supportsCategorizedSorting()) {
|
||||
Q_ASSERT(m_iconsView != 0);
|
||||
if (categorized) {
|
||||
Q_ASSERT(m_iconsView->itemCategorizer() == 0);
|
||||
m_iconsView->setItemCategorizer(new DolphinItemCategorizer());
|
||||
} else {
|
||||
KItemCategorizer* categorizer = m_iconsView->itemCategorizer();
|
||||
m_iconsView->setItemCategorizer(0);
|
||||
delete categorizer;
|
||||
}
|
||||
}
|
||||
emit categorizedSortingChanged();
|
||||
}
|
||||
|
||||
const DolphinView::Sorting sorting = props.sorting();
|
||||
if (sorting != m_proxyModel->sorting()) {
|
||||
m_proxyModel->setSorting(sorting);
|
||||
|
@ -1096,6 +1151,11 @@ void DolphinView::createView()
|
|||
if (view != 0) {
|
||||
m_topLayout->removeWidget(view);
|
||||
view->close();
|
||||
if (view == m_iconsView) {
|
||||
KItemCategorizer* categorizer = m_iconsView->itemCategorizer();
|
||||
m_iconsView->setItemCategorizer(0);
|
||||
delete categorizer;
|
||||
}
|
||||
view->deleteLater();
|
||||
view = 0;
|
||||
m_iconsView = 0;
|
||||
|
|
|
@ -164,6 +164,24 @@ public:
|
|||
void setShowHiddenFiles(bool show);
|
||||
bool showHiddenFiles() const;
|
||||
|
||||
/**
|
||||
* 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 be stored automatically.
|
||||
*/
|
||||
void setCategorizedSorting(bool categorized);
|
||||
bool categorizedSorting() const;
|
||||
|
||||
/**
|
||||
* Returns true, if the categorized sorting is supported by the current
|
||||
* used mode (see DolphinView::setMode()). Currently only DolphinView::IconsView
|
||||
* supports categorizations. To check whether the categorized
|
||||
* sorting is set, use DolphinView::categorizedSorting().
|
||||
*/
|
||||
bool supportsCategorizedSorting() const;
|
||||
|
||||
/**
|
||||
* Triggers the renaming of the currently selected items, where
|
||||
* the user must input a new name for the items.
|
||||
|
@ -375,6 +393,9 @@ signals:
|
|||
/** Is emitted if the 'show hidden files' property has been changed. */
|
||||
void showHiddenFilesChanged();
|
||||
|
||||
/** Is emitted if the 'categorized sorting' property has been changed. */
|
||||
void categorizedSortingChanged();
|
||||
|
||||
/** Is emitted if the sorting by name, size or date has been changed. */
|
||||
void sortingChanged(DolphinView::Sorting sorting);
|
||||
|
||||
|
|
|
@ -131,6 +131,20 @@ void ViewProperties::setShowHiddenFiles(bool show)
|
|||
}
|
||||
}
|
||||
|
||||
void ViewProperties::setCategorizedSorting(bool categorized)
|
||||
{
|
||||
if (m_node->categorizedSorting() != categorized) {
|
||||
m_node->setCategorizedSorting(categorized);
|
||||
updateTimeStamp();
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProperties::categorizedSorting() const
|
||||
{
|
||||
return m_node->categorizedSorting();
|
||||
}
|
||||
|
||||
|
||||
bool ViewProperties::showHiddenFiles() const
|
||||
{
|
||||
return m_node->showHiddenFiles();
|
||||
|
@ -181,6 +195,7 @@ void ViewProperties::setDirProperties(const ViewProperties& props)
|
|||
setViewMode(props.viewMode());
|
||||
setShowPreview(props.showPreview());
|
||||
setShowHiddenFiles(props.showHiddenFiles());
|
||||
setCategorizedSorting(props.categorizedSorting());
|
||||
setSorting(props.sorting());
|
||||
setSortOrder(props.sortOrder());
|
||||
setAdditionalInfo(props.additionalInfo());
|
||||
|
|
|
@ -66,6 +66,9 @@ public:
|
|||
void setShowHiddenFiles(bool show);
|
||||
bool showHiddenFiles() const;
|
||||
|
||||
void setCategorizedSorting(bool categorized);
|
||||
bool categorizedSorting() const;
|
||||
|
||||
void setSorting(DolphinView::Sorting sorting);
|
||||
DolphinView::Sorting sorting() const;
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
m_viewMode(0),
|
||||
m_sorting(0),
|
||||
m_sortOrder(0),
|
||||
m_categorizedSorting(0),
|
||||
m_additionalInfo(0),
|
||||
m_showPreview(0),
|
||||
m_showHiddenFiles(0),
|
||||
|
@ -94,6 +95,11 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
const int sortOrderIdx = (m_viewProps->sortOrder() == Qt::AscendingOrder) ? 0 : 1;
|
||||
m_sortOrder->setCurrentIndex(sortOrderIdx);
|
||||
|
||||
m_categorizedSorting = new QComboBox(sortingBox);
|
||||
m_categorizedSorting->addItem(i18n("Uncategorized"));
|
||||
m_categorizedSorting->addItem(i18n("Categorized"));
|
||||
m_categorizedSorting->setCurrentIndex(m_viewProps->categorizedSorting() ? 1 : 0);
|
||||
|
||||
m_sorting = new QComboBox(sortingBox);
|
||||
m_sorting->addItem("By Name");
|
||||
m_sorting->addItem("By Size");
|
||||
|
@ -107,6 +113,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
sortingLayout->setMargin(0);
|
||||
sortingLayout->addWidget(m_sortOrder);
|
||||
sortingLayout->addWidget(m_sorting);
|
||||
sortingLayout->addWidget(m_categorizedSorting);
|
||||
sortingBox->setLayout(sortingLayout);
|
||||
|
||||
QLabel* additionalInfoLabel = new QLabel(i18n("Additional information:"), propsBox);
|
||||
|
@ -143,6 +150,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
this, SLOT(slotSortingChanged(int)));
|
||||
connect(m_sortOrder, SIGNAL(activated(int)),
|
||||
this, SLOT(slotSortOrderChanged(int)));
|
||||
connect(m_categorizedSorting, SIGNAL(activated(int)),
|
||||
this, SLOT(slotCategorizedSortingChanged(int)));
|
||||
connect(m_additionalInfo, SIGNAL(activated(int)),
|
||||
this, SLOT(slotAdditionalInfoChanged(int)));
|
||||
connect(m_showPreview, SIGNAL(clicked()),
|
||||
|
@ -216,7 +225,9 @@ void ViewPropertiesDialog::slotViewModeChanged(int index)
|
|||
m_viewProps->setViewMode(static_cast<DolphinView::Mode>(index));
|
||||
m_isDirty = true;
|
||||
|
||||
m_additionalInfo->setEnabled(m_viewProps->viewMode() == DolphinView::IconsView);
|
||||
const bool iconsViewEnabled = (m_viewProps->viewMode() == DolphinView::IconsView);
|
||||
m_categorizedSorting->setEnabled(iconsViewEnabled);
|
||||
m_additionalInfo->setEnabled(iconsViewEnabled);
|
||||
}
|
||||
|
||||
void ViewPropertiesDialog::slotSortingChanged(int index)
|
||||
|
@ -233,6 +244,12 @@ void ViewPropertiesDialog::slotSortOrderChanged(int index)
|
|||
m_isDirty = true;
|
||||
}
|
||||
|
||||
void ViewPropertiesDialog::slotCategorizedSortingChanged(int index)
|
||||
{
|
||||
m_viewProps->setCategorizedSorting(index == 1);
|
||||
m_isDirty = true;
|
||||
}
|
||||
|
||||
void ViewPropertiesDialog::slotAdditionalInfoChanged(int index)
|
||||
{
|
||||
KFileItemDelegate::AdditionalInformation info = KFileItemDelegate::NoInformation;
|
||||
|
@ -307,6 +324,7 @@ void ViewPropertiesDialog::applyViewProperties()
|
|||
m_dolphinView->setMode(m_viewProps->viewMode());
|
||||
m_dolphinView->setSorting(m_viewProps->sorting());
|
||||
m_dolphinView->setSortOrder(m_viewProps->sortOrder());
|
||||
m_dolphinView->setCategorizedSorting(m_viewProps->categorizedSorting());
|
||||
m_dolphinView->setAdditionalInfo(m_viewProps->additionalInfo());
|
||||
m_dolphinView->setShowPreview(m_viewProps->showPreview());
|
||||
m_dolphinView->setShowHiddenFiles(m_viewProps->showHiddenFiles());
|
||||
|
|
|
@ -50,6 +50,7 @@ private slots:
|
|||
void slotViewModeChanged(int index);
|
||||
void slotSortingChanged(int index);
|
||||
void slotSortOrderChanged(int index);
|
||||
void slotCategorizedSortingChanged(int index);
|
||||
void slotAdditionalInfoChanged(int index);
|
||||
void slotShowPreviewChanged();
|
||||
void slotShowHiddenFilesChanged();
|
||||
|
@ -63,6 +64,7 @@ private:
|
|||
QComboBox* m_viewMode;
|
||||
QComboBox* m_sorting;
|
||||
QComboBox* m_sortOrder;
|
||||
QComboBox* m_categorizedSorting;
|
||||
QComboBox* m_additionalInfo;
|
||||
QCheckBox* m_showPreview;
|
||||
QCheckBox* m_showHiddenFiles;
|
||||
|
|
Loading…
Reference in a new issue