mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Revert "Revert "Configurable Show hidden files and folders last toggle""
This reverts commit bb67def173
.
This commit is contained in:
parent
3286a194d6
commit
011fe5b1e8
|
@ -34,6 +34,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
|
|||
KItemModelBase("text", parent),
|
||||
m_dirLister(nullptr),
|
||||
m_sortDirsFirst(true),
|
||||
m_sortHiddenLast(true),
|
||||
m_sortRole(NameRole),
|
||||
m_sortingProgressPercent(-1),
|
||||
m_roles(),
|
||||
|
@ -207,6 +208,19 @@ bool KFileItemModel::sortDirectoriesFirst() const
|
|||
return m_sortDirsFirst;
|
||||
}
|
||||
|
||||
void KFileItemModel::setSortHiddenLast(bool hiddenLast)
|
||||
{
|
||||
if (hiddenLast != m_sortHiddenLast) {
|
||||
m_sortHiddenLast = hiddenLast;
|
||||
resortAllItems();
|
||||
}
|
||||
}
|
||||
|
||||
bool KFileItemModel::sortHiddenLast() const
|
||||
{
|
||||
return m_sortHiddenLast;
|
||||
}
|
||||
|
||||
void KFileItemModel::setShowHiddenFiles(bool show)
|
||||
{
|
||||
m_dirLister->setShowingDotFiles(show);
|
||||
|
@ -1754,12 +1768,14 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b, const QColla
|
|||
}
|
||||
|
||||
// Show hidden files and folders last
|
||||
const bool isHiddenA = a->item.isHidden();
|
||||
const bool isHiddenB = b->item.isHidden();
|
||||
if (isHiddenA && !isHiddenB) {
|
||||
return false;
|
||||
} else if (!isHiddenA && isHiddenB) {
|
||||
return true;
|
||||
if (m_sortHiddenLast) {
|
||||
const bool isHiddenA = a->item.isHidden();
|
||||
const bool isHiddenB = b->item.isHidden();
|
||||
if (isHiddenA && !isHiddenB) {
|
||||
return false;
|
||||
} else if (!isHiddenA && isHiddenB) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_sortDirsFirst || (DetailsModeSettings::directorySizeCount() && m_sortRole == SizeRole)) {
|
||||
|
|
|
@ -85,6 +85,12 @@ public:
|
|||
void setSortDirectoriesFirst(bool dirsFirst);
|
||||
bool sortDirectoriesFirst() const;
|
||||
|
||||
/**
|
||||
* Sets a separate sorting with hidden files and folders last (true) or not (false).
|
||||
*/
|
||||
void setSortHiddenLast(bool hiddenLast);
|
||||
bool sortHiddenLast() const;
|
||||
|
||||
void setShowHiddenFiles(bool show);
|
||||
bool showHiddenFiles() const;
|
||||
|
||||
|
@ -469,6 +475,7 @@ private:
|
|||
QCollator m_collator;
|
||||
bool m_naturalSorting;
|
||||
bool m_sortDirsFirst;
|
||||
bool m_sortHiddenLast;
|
||||
|
||||
RoleType m_sortRole;
|
||||
int m_sortingProgressPercent; // Value of directorySortingProgress() signal
|
||||
|
|
|
@ -57,6 +57,11 @@
|
|||
<default>true</default>
|
||||
</entry>
|
||||
|
||||
<entry name="SortHiddenLast" type="Bool" >
|
||||
<label context="@label">Show hidden files and folders last</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
||||
<entry name="VisibleRoles" type="StringList">
|
||||
<label context="@label">Visible roles</label>
|
||||
<default></default>
|
||||
|
|
|
@ -44,6 +44,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
m_sortOrder(nullptr),
|
||||
m_sorting(nullptr),
|
||||
m_sortFoldersFirst(nullptr),
|
||||
m_sortHiddenLast(nullptr),
|
||||
m_previewsShown(nullptr),
|
||||
m_showInGroups(nullptr),
|
||||
m_showHiddenFiles(nullptr),
|
||||
|
@ -82,6 +83,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
}
|
||||
|
||||
m_sortFoldersFirst = new QCheckBox(i18nc("@option:check", "Show folders first"));
|
||||
m_sortHiddenLast = new QCheckBox(i18nc("@option:check", "Show hidden files last"));
|
||||
m_previewsShown = new QCheckBox(i18nc("@option:check", "Show preview"));
|
||||
m_showInGroups = new QCheckBox(i18nc("@option:check", "Show in groups"));
|
||||
m_showHiddenFiles = new QCheckBox(i18nc("@option:check", "Show hidden files"));
|
||||
|
@ -146,6 +148,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
layout->addRow(QString(), m_previewsShown);
|
||||
layout->addRow(QString(), m_showInGroups);
|
||||
layout->addRow(QString(), m_showHiddenFiles);
|
||||
layout->addRow(QString(), m_sortHiddenLast);
|
||||
|
||||
connect(m_viewMode, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &ViewPropertiesDialog::slotViewModeChanged);
|
||||
|
@ -155,6 +158,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
this, &ViewPropertiesDialog::slotSortOrderChanged);
|
||||
connect(m_sortFoldersFirst, &QCheckBox::clicked,
|
||||
this, &ViewPropertiesDialog::slotSortFoldersFirstChanged);
|
||||
connect(m_sortHiddenLast, &QCheckBox::clicked,
|
||||
this, &ViewPropertiesDialog::slotSortHiddenLastChanged);
|
||||
connect(m_previewsShown, &QCheckBox::clicked,
|
||||
this, &ViewPropertiesDialog::slotShowPreviewChanged);
|
||||
connect(m_showInGroups, &QCheckBox::clicked,
|
||||
|
@ -282,6 +287,13 @@ void ViewPropertiesDialog::slotSortFoldersFirstChanged()
|
|||
markAsDirty(true);
|
||||
}
|
||||
|
||||
void ViewPropertiesDialog::slotSortHiddenLastChanged()
|
||||
{
|
||||
const bool hiddenLast = m_sortHiddenLast->isChecked();
|
||||
m_viewProps->setSortHiddenLast(hiddenLast);
|
||||
markAsDirty(true);
|
||||
}
|
||||
|
||||
void ViewPropertiesDialog::slotShowPreviewChanged()
|
||||
{
|
||||
const bool show = m_previewsShown->isChecked();
|
||||
|
@ -383,6 +395,7 @@ void ViewPropertiesDialog::applyViewProperties()
|
|||
m_dolphinView->setSortRole(m_viewProps->sortRole());
|
||||
m_dolphinView->setSortOrder(m_viewProps->sortOrder());
|
||||
m_dolphinView->setSortFoldersFirst(m_viewProps->sortFoldersFirst());
|
||||
m_dolphinView->setSortHiddenLast(m_viewProps->sortHiddenLast());
|
||||
m_dolphinView->setGroupedSorting(m_viewProps->groupedSorting());
|
||||
m_dolphinView->setVisibleRoles(m_viewProps->visibleRoles());
|
||||
m_dolphinView->setPreviewsShown(m_viewProps->previewsShown());
|
||||
|
@ -418,6 +431,7 @@ void ViewPropertiesDialog::loadSettings()
|
|||
m_sorting->setCurrentIndex(sortRoleIndex);
|
||||
|
||||
m_sortFoldersFirst->setChecked(m_viewProps->sortFoldersFirst());
|
||||
m_sortHiddenLast->setChecked(m_viewProps->sortHiddenLast());
|
||||
|
||||
// Load show preview, show in groups and show hidden files settings
|
||||
m_previewsShown->setChecked(m_viewProps->previewsShown());
|
||||
|
|
|
@ -46,6 +46,7 @@ private Q_SLOTS:
|
|||
void slotSortOrderChanged(int index);
|
||||
void slotGroupedSortingChanged();
|
||||
void slotSortFoldersFirstChanged();
|
||||
void slotSortHiddenLastChanged();
|
||||
void slotShowPreviewChanged();
|
||||
void slotShowHiddenFilesChanged();
|
||||
void slotItemChanged(QListWidgetItem *item);
|
||||
|
@ -67,6 +68,7 @@ private:
|
|||
QComboBox* m_sortOrder;
|
||||
QComboBox* m_sorting;
|
||||
QCheckBox* m_sortFoldersFirst;
|
||||
QCheckBox* m_sortHiddenLast;
|
||||
QCheckBox* m_previewsShown;
|
||||
QCheckBox* m_showInGroups;
|
||||
QCheckBox* m_showHiddenFiles;
|
||||
|
|
|
@ -465,6 +465,18 @@ bool DolphinView::sortFoldersFirst() const
|
|||
return m_model->sortDirectoriesFirst();
|
||||
}
|
||||
|
||||
void DolphinView::setSortHiddenLast(bool hiddenLast)
|
||||
{
|
||||
if (sortHiddenLast() != hiddenLast) {
|
||||
updateSortHiddenLast(hiddenLast);
|
||||
}
|
||||
}
|
||||
|
||||
bool DolphinView::sortHiddenLast() const
|
||||
{
|
||||
return m_model->sortHiddenLast();
|
||||
}
|
||||
|
||||
void DolphinView::setVisibleRoles(const QList<QByteArray>& roles)
|
||||
{
|
||||
const QList<QByteArray> previousRoles = roles;
|
||||
|
@ -1375,6 +1387,17 @@ void DolphinView::updateSortFoldersFirst(bool foldersFirst)
|
|||
Q_EMIT sortFoldersFirstChanged(foldersFirst);
|
||||
}
|
||||
|
||||
void DolphinView::updateSortHiddenLast(bool hiddenLast)
|
||||
{
|
||||
ViewProperties props(viewPropertiesUrl());
|
||||
props.setSortHiddenLast(hiddenLast);
|
||||
|
||||
m_model->setSortHiddenLast(hiddenLast);
|
||||
|
||||
Q_EMIT sortHiddenLastChanged(hiddenLast);
|
||||
}
|
||||
|
||||
|
||||
QPair<bool, QString> DolphinView::pasteInfo() const
|
||||
{
|
||||
const QMimeData *mimeData = QApplication::clipboard()->mimeData();
|
||||
|
@ -1919,6 +1942,12 @@ void DolphinView::applyViewProperties(const ViewProperties& props)
|
|||
Q_EMIT sortFoldersFirstChanged(sortFoldersFirst);
|
||||
}
|
||||
|
||||
const bool sortHiddenLast = props.sortHiddenLast();
|
||||
if (sortHiddenLast != m_model->sortHiddenLast()) {
|
||||
m_model->setSortHiddenLast(sortHiddenLast);
|
||||
Q_EMIT sortHiddenLastChanged(sortHiddenLast);
|
||||
}
|
||||
|
||||
const QList<QByteArray> visibleRoles = props.visibleRoles();
|
||||
if (visibleRoles != m_visibleRoles) {
|
||||
const QList<QByteArray> previousVisibleRoles = m_visibleRoles;
|
||||
|
|
|
@ -206,6 +206,10 @@ public:
|
|||
void setSortFoldersFirst(bool foldersFirst);
|
||||
bool sortFoldersFirst() const;
|
||||
|
||||
/** Sets a separate sorting with hidden files and folders last (true) or not (false). */
|
||||
void setSortHiddenLast(bool hiddenLast);
|
||||
bool sortHiddenLast() const;
|
||||
|
||||
/** Sets the additional information which should be shown for the items. */
|
||||
void setVisibleRoles(const QList<QByteArray>& roles);
|
||||
|
||||
|
@ -470,6 +474,11 @@ Q_SIGNALS:
|
|||
*/
|
||||
void sortFoldersFirstChanged(bool foldersFirst);
|
||||
|
||||
/**
|
||||
* Is emitted if the sorting of hidden files has been changed.
|
||||
*/
|
||||
void sortHiddenLastChanged(bool hiddenLast);
|
||||
|
||||
/** Is emitted if the additional information shown for this view has been changed. */
|
||||
void visibleRolesChanged(const QList<QByteArray>& current,
|
||||
const QList<QByteArray>& previous);
|
||||
|
@ -679,6 +688,12 @@ private Q_SLOTS:
|
|||
*/
|
||||
void updateSortFoldersFirst(bool foldersFirst);
|
||||
|
||||
/**
|
||||
* Updates the view properties of the current URL to the
|
||||
* sorting of hidden files given by \a hiddenLast.
|
||||
*/
|
||||
void updateSortHiddenLast(bool hiddenLast);
|
||||
|
||||
/**
|
||||
* Indicates in the status bar that the delete operation
|
||||
* of the job \a job has been finished.
|
||||
|
|
|
@ -57,6 +57,8 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
|
|||
this, &DolphinViewActionHandler::slotSortOrderChanged);
|
||||
connect(view, &DolphinView::sortFoldersFirstChanged,
|
||||
this, &DolphinViewActionHandler::slotSortFoldersFirstChanged);
|
||||
connect(view, &DolphinView::sortHiddenLastChanged,
|
||||
this, &DolphinViewActionHandler::slotSortHiddenLastChanged);
|
||||
connect(view, &DolphinView::visibleRolesChanged,
|
||||
this, &DolphinViewActionHandler::slotVisibleRolesChanged);
|
||||
connect(view, &DolphinView::groupedSortingChanged,
|
||||
|
@ -253,6 +255,10 @@ void DolphinViewActionHandler::createActions()
|
|||
sortFoldersFirst->setText(i18nc("@action:inmenu Sort", "Folders First"));
|
||||
connect(sortFoldersFirst, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortFoldersFirst);
|
||||
|
||||
KToggleAction* sortHiddenLast = m_actionCollection->add<KToggleAction>(QStringLiteral("hidden_last"));
|
||||
sortHiddenLast->setText(i18nc("@action:inmenu Sort", "Hidden Files Last"));
|
||||
connect(sortHiddenLast, &KToggleAction::triggered, this, &DolphinViewActionHandler::toggleSortHiddenLast);
|
||||
|
||||
// View -> Sort By
|
||||
QActionGroup* sortByActionGroup = createFileItemRolesActionGroup(QStringLiteral("sort_by_"));
|
||||
|
||||
|
@ -287,6 +293,7 @@ void DolphinViewActionHandler::createActions()
|
|||
sortByActionMenu->addAction(descendingAction);
|
||||
sortByActionMenu->addSeparator();
|
||||
sortByActionMenu->addAction(sortFoldersFirst);
|
||||
sortByActionMenu->addAction(sortHiddenLast);
|
||||
|
||||
// View -> Additional Information
|
||||
QActionGroup* visibleRolesGroup = createFileItemRolesActionGroup(QStringLiteral("show_"));
|
||||
|
@ -481,6 +488,7 @@ void DolphinViewActionHandler::updateViewActions()
|
|||
|
||||
slotSortOrderChanged(m_currentView->sortOrder());
|
||||
slotSortFoldersFirstChanged(m_currentView->sortFoldersFirst());
|
||||
slotSortHiddenLastChanged(m_currentView->sortHiddenLast());
|
||||
slotVisibleRolesChanged(m_currentView->visibleRoles(), QList<QByteArray>());
|
||||
slotGroupedSortingChanged(m_currentView->groupedSorting());
|
||||
slotSortRoleChanged(m_currentView->sortRole());
|
||||
|
@ -516,6 +524,12 @@ void DolphinViewActionHandler::toggleSortFoldersFirst()
|
|||
m_currentView->setSortFoldersFirst(!sortFirst);
|
||||
}
|
||||
|
||||
void DolphinViewActionHandler::toggleSortHiddenLast()
|
||||
{
|
||||
const bool sortHiddenLast = m_currentView->sortHiddenLast();
|
||||
m_currentView->setSortHiddenLast(!sortHiddenLast);
|
||||
}
|
||||
|
||||
void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order)
|
||||
{
|
||||
QAction* descending = m_actionCollection->action(QStringLiteral("descending"));
|
||||
|
@ -530,6 +544,11 @@ void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst)
|
|||
m_actionCollection->action(QStringLiteral("folders_first"))->setChecked(foldersFirst);
|
||||
}
|
||||
|
||||
void DolphinViewActionHandler::slotSortHiddenLastChanged(bool hiddenLast)
|
||||
{
|
||||
m_actionCollection->action(QStringLiteral("hidden_last"))->setChecked(hiddenLast);
|
||||
}
|
||||
|
||||
void DolphinViewActionHandler::toggleVisibleRole(QAction* action)
|
||||
{
|
||||
Q_EMIT actionBeingHandled();
|
||||
|
|
|
@ -136,6 +136,16 @@ private Q_SLOTS:
|
|||
*/
|
||||
void slotSortFoldersFirstChanged(bool foldersFirst);
|
||||
|
||||
/**
|
||||
* Switches between showing hidden files last or not.
|
||||
*/
|
||||
void toggleSortHiddenLast();
|
||||
|
||||
/**
|
||||
* Updates the state of the 'Sort Hidden Last' action.
|
||||
*/
|
||||
void slotSortHiddenLastChanged(bool hiddenLast);
|
||||
|
||||
/**
|
||||
* Updates the state of the 'Sort by' actions.
|
||||
*/
|
||||
|
|
|
@ -245,6 +245,19 @@ bool ViewProperties::sortFoldersFirst() const
|
|||
return m_node->sortFoldersFirst();
|
||||
}
|
||||
|
||||
void ViewProperties::setSortHiddenLast(bool hiddenLast)
|
||||
{
|
||||
if (m_node->sortHiddenLast() != hiddenLast) {
|
||||
m_node->setSortHiddenLast(hiddenLast);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProperties::sortHiddenLast() const
|
||||
{
|
||||
return m_node->sortHiddenLast();
|
||||
}
|
||||
|
||||
void ViewProperties::setVisibleRoles(const QList<QByteArray>& roles)
|
||||
{
|
||||
if (roles == visibleRoles()) {
|
||||
|
@ -353,6 +366,7 @@ void ViewProperties::setDirProperties(const ViewProperties& props)
|
|||
setSortRole(props.sortRole());
|
||||
setSortOrder(props.sortOrder());
|
||||
setSortFoldersFirst(props.sortFoldersFirst());
|
||||
setSortHiddenLast(props.sortHiddenLast());
|
||||
setVisibleRoles(props.visibleRoles());
|
||||
setHeaderColumnWidths(props.headerColumnWidths());
|
||||
m_node->setVersion(props.m_node->version());
|
||||
|
|
|
@ -62,6 +62,9 @@ public:
|
|||
void setSortFoldersFirst(bool foldersFirst);
|
||||
bool sortFoldersFirst() const;
|
||||
|
||||
void setSortHiddenLast(bool hiddenLast);
|
||||
bool sortHiddenLast() const;
|
||||
|
||||
/**
|
||||
* Sets the additional information for the current set view-mode.
|
||||
* Note that the additional-info property is the only property where
|
||||
|
|
Loading…
Reference in a new issue