mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Add case sensitive sorting mode
Dolphin users can now choose between 3 different sorting modes: * natural sorting * case insensitive sorting * case sensitive sorting REVIEW: 126467 BUG: 148550 FIXED-IN: 16.04.0
This commit is contained in:
parent
189d5cd0f9
commit
92c0ecde90
|
@ -41,7 +41,6 @@
|
||||||
KFileItemModel::KFileItemModel(QObject* parent) :
|
KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
KItemModelBase("text", parent),
|
KItemModelBase("text", parent),
|
||||||
m_dirLister(0),
|
m_dirLister(0),
|
||||||
m_naturalSorting(GeneralSettings::naturalSorting()),
|
|
||||||
m_sortDirsFirst(true),
|
m_sortDirsFirst(true),
|
||||||
m_sortRole(NameRole),
|
m_sortRole(NameRole),
|
||||||
m_sortingProgressPercent(-1),
|
m_sortingProgressPercent(-1),
|
||||||
|
@ -58,9 +57,10 @@ KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
m_expandedDirs(),
|
m_expandedDirs(),
|
||||||
m_urlsToExpand()
|
m_urlsToExpand()
|
||||||
{
|
{
|
||||||
m_collator.setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
m_collator.setNumericMode(true);
|
m_collator.setNumericMode(true);
|
||||||
|
|
||||||
|
loadSortingSettings();
|
||||||
|
|
||||||
m_dirLister = new KFileItemModelDirLister(this);
|
m_dirLister = new KFileItemModelDirLister(this);
|
||||||
m_dirLister->setDelayedMimeTypes(true);
|
m_dirLister->setDelayedMimeTypes(true);
|
||||||
|
|
||||||
|
@ -106,8 +106,7 @@ KFileItemModel::KFileItemModel(QObject* parent) :
|
||||||
m_resortAllItemsTimer->setSingleShot(true);
|
m_resortAllItemsTimer->setSingleShot(true);
|
||||||
connect(m_resortAllItemsTimer, &QTimer::timeout, this, &KFileItemModel::resortAllItems);
|
connect(m_resortAllItemsTimer, &QTimer::timeout, this, &KFileItemModel::resortAllItems);
|
||||||
|
|
||||||
connect(GeneralSettings::self(), &GeneralSettings::naturalSortingChanged,
|
connect(GeneralSettings::self(), &GeneralSettings::sortingChoiceChanged, this, &KFileItemModel::slotSortingChoiceChanged);
|
||||||
this, &KFileItemModel::slotNaturalSortingChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KFileItemModel::~KFileItemModel()
|
KFileItemModel::~KFileItemModel()
|
||||||
|
@ -783,6 +782,27 @@ void KFileItemModel::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder pre
|
||||||
resortAllItems();
|
resortAllItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KFileItemModel::loadSortingSettings()
|
||||||
|
{
|
||||||
|
using Choice = GeneralSettings::EnumSortingChoice;
|
||||||
|
switch (GeneralSettings::sortingChoice()) {
|
||||||
|
case Choice::NaturalSorting:
|
||||||
|
m_naturalSorting = true;
|
||||||
|
m_collator.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
break;
|
||||||
|
case Choice::CaseSensitiveSorting:
|
||||||
|
m_naturalSorting = false;
|
||||||
|
m_collator.setCaseSensitivity(Qt::CaseSensitive);
|
||||||
|
break;
|
||||||
|
case Choice::CaseInsensitiveSorting:
|
||||||
|
m_naturalSorting = false;
|
||||||
|
m_collator.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KFileItemModel::resortAllItems()
|
void KFileItemModel::resortAllItems()
|
||||||
{
|
{
|
||||||
m_resortAllItemsTimer->stop();
|
m_resortAllItemsTimer->stop();
|
||||||
|
@ -1103,9 +1123,9 @@ void KFileItemModel::slotClear()
|
||||||
m_expandedDirs.clear();
|
m_expandedDirs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFileItemModel::slotNaturalSortingChanged()
|
void KFileItemModel::slotSortingChoiceChanged()
|
||||||
{
|
{
|
||||||
m_naturalSorting = GeneralSettings::naturalSorting();
|
loadSortingSettings();
|
||||||
resortAllItems();
|
resortAllItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ private slots:
|
||||||
void slotItemsDeleted(const KFileItemList& items);
|
void slotItemsDeleted(const KFileItemList& items);
|
||||||
void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items);
|
void slotRefreshItems(const QList<QPair<KFileItem, KFileItem> >& items);
|
||||||
void slotClear();
|
void slotClear();
|
||||||
void slotNaturalSortingChanged();
|
void slotSortingChoiceChanged();
|
||||||
|
|
||||||
void dispatchPendingItemsToInsert();
|
void dispatchPendingItemsToInsert();
|
||||||
|
|
||||||
|
@ -415,6 +415,11 @@ private:
|
||||||
*/
|
*/
|
||||||
void removeFilteredChildren(const KItemRangeList& parents);
|
void removeFilteredChildren(const KItemRangeList& parents);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the selected choice of sorting method from Dolphin General Settings
|
||||||
|
*/
|
||||||
|
void loadSortingSettings();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps the QByteArray-roles to RoleTypes and provides translation- and
|
* Maps the QByteArray-roles to RoleTypes and provides translation- and
|
||||||
* group-contexts.
|
* group-contexts.
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<include>QUrl</include>
|
<include>QUrl</include>
|
||||||
<include>KCompletion</include>
|
<include>KCompletion</include>
|
||||||
<kcfgfile name="dolphinrc"/>
|
<kcfgfile name="dolphinrc"/>
|
||||||
<signal name="naturalSortingChanged" />
|
<signal name="sortingChoiceChanged" />
|
||||||
<group name="General">
|
<group name="General">
|
||||||
<entry name="EditableUrl" type="Bool">
|
<entry name="EditableUrl" type="Bool">
|
||||||
<label>Should the URL be editable for the user</label>
|
<label>Should the URL be editable for the user</label>
|
||||||
|
@ -93,10 +93,15 @@
|
||||||
<label>Enlarge Small Previews</label>
|
<label>Enlarge Small Previews</label>
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="NaturalSorting" type="Bool">
|
<entry name="SortingChoice" type="Enum">
|
||||||
<label>Natural sorting of items</label>
|
<choices>
|
||||||
<default>true</default>
|
<choice name="NaturalSorting" />
|
||||||
<emit signal="naturalSortingChanged" />
|
<choice name="CaseInsensitiveSorting" />
|
||||||
|
<choice name="CaseSensitiveSorting" />
|
||||||
|
</choices>
|
||||||
|
<label>Choose Natural, Case Sensitive, or Case Insensitive order of sorting the items</label>
|
||||||
|
<default>0</default>
|
||||||
|
<emit signal="sortingChoiceChanged" />
|
||||||
</entry>
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
</kcfg>
|
</kcfg>
|
||||||
|
|
|
@ -39,6 +39,8 @@ BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
|
||||||
m_showToolTips(0),
|
m_showToolTips(0),
|
||||||
m_showSelectionToggle(0),
|
m_showSelectionToggle(0),
|
||||||
m_naturalSorting(0),
|
m_naturalSorting(0),
|
||||||
|
m_caseSensitiveSorting(0),
|
||||||
|
m_caseInsensitiveSorting(0),
|
||||||
m_renameInline(0)
|
m_renameInline(0)
|
||||||
{
|
{
|
||||||
QVBoxLayout* topLayout = new QVBoxLayout(this);
|
QVBoxLayout* topLayout = new QVBoxLayout(this);
|
||||||
|
@ -54,22 +56,32 @@ BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
|
||||||
viewPropsLayout->addWidget(m_localViewProps);
|
viewPropsLayout->addWidget(m_localViewProps);
|
||||||
viewPropsLayout->addWidget(m_globalViewProps);
|
viewPropsLayout->addWidget(m_globalViewProps);
|
||||||
|
|
||||||
|
// Sorting properties
|
||||||
|
QGroupBox* sortingPropsBox = new QGroupBox(i18nc("@title:group", "Sorting Mode"), this);
|
||||||
|
sortingPropsBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||||
|
|
||||||
|
m_naturalSorting = new QRadioButton(i18nc("option:radio", "Natural sorting"), sortingPropsBox);
|
||||||
|
m_caseInsensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical sorting, case insensitive"), sortingPropsBox);
|
||||||
|
m_caseSensitiveSorting = new QRadioButton(i18nc("option:radio", "Alphabetical sorting, case sensitive"), sortingPropsBox);
|
||||||
|
|
||||||
|
QVBoxLayout* sortingPropsLayout = new QVBoxLayout(sortingPropsBox);
|
||||||
|
sortingPropsLayout->addWidget(m_naturalSorting);
|
||||||
|
sortingPropsLayout->addWidget(m_caseInsensitiveSorting);
|
||||||
|
sortingPropsLayout->addWidget(m_caseSensitiveSorting);
|
||||||
|
|
||||||
// 'Show tooltips'
|
// 'Show tooltips'
|
||||||
m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips"), this);
|
m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips"), this);
|
||||||
|
|
||||||
// 'Show selection marker'
|
// 'Show selection marker'
|
||||||
m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker"), this);
|
m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker"), this);
|
||||||
|
|
||||||
// 'Natural sorting of items'
|
|
||||||
m_naturalSorting = new QCheckBox(i18nc("option:check", "Natural sorting of items"), this);
|
|
||||||
|
|
||||||
// 'Inline renaming of items'
|
// 'Inline renaming of items'
|
||||||
m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline"), this);
|
m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline"), this);
|
||||||
|
|
||||||
topLayout->addWidget(viewPropsBox);
|
topLayout->addWidget(viewPropsBox);
|
||||||
|
topLayout->addWidget(sortingPropsBox);
|
||||||
topLayout->addWidget(m_showToolTips);
|
topLayout->addWidget(m_showToolTips);
|
||||||
topLayout->addWidget(m_showSelectionToggle);
|
topLayout->addWidget(m_showSelectionToggle);
|
||||||
topLayout->addWidget(m_naturalSorting);
|
|
||||||
topLayout->addWidget(m_renameInline);
|
topLayout->addWidget(m_renameInline);
|
||||||
topLayout->addStretch();
|
topLayout->addStretch();
|
||||||
|
|
||||||
|
@ -79,7 +91,9 @@ BehaviorSettingsPage::BehaviorSettingsPage(const QUrl& url, QWidget* parent) :
|
||||||
connect(m_globalViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
|
connect(m_globalViewProps, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
|
||||||
connect(m_showToolTips, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
|
connect(m_showToolTips, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
|
||||||
connect(m_showSelectionToggle, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
|
connect(m_showSelectionToggle, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
|
||||||
connect(m_naturalSorting, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
|
connect(m_naturalSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
|
||||||
|
connect(m_caseInsensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
|
||||||
|
connect(m_caseSensitiveSorting, &QRadioButton::toggled, this, &BehaviorSettingsPage::changed);
|
||||||
connect(m_renameInline, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
|
connect(m_renameInline, &QCheckBox::toggled, this, &BehaviorSettingsPage::changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,10 +108,9 @@ void BehaviorSettingsPage::applySettings()
|
||||||
|
|
||||||
const bool useGlobalViewProps = m_globalViewProps->isChecked();
|
const bool useGlobalViewProps = m_globalViewProps->isChecked();
|
||||||
settings->setGlobalViewProps(useGlobalViewProps);
|
settings->setGlobalViewProps(useGlobalViewProps);
|
||||||
|
|
||||||
settings->setShowToolTips(m_showToolTips->isChecked());
|
settings->setShowToolTips(m_showToolTips->isChecked());
|
||||||
settings->setShowSelectionToggle(m_showSelectionToggle->isChecked());
|
settings->setShowSelectionToggle(m_showSelectionToggle->isChecked());
|
||||||
settings->setNaturalSorting(m_naturalSorting->isChecked());
|
setSortingChoiceValue(settings);
|
||||||
settings->setRenameInline(m_renameInline->isChecked());
|
settings->setRenameInline(m_renameInline->isChecked());
|
||||||
settings->save();
|
settings->save();
|
||||||
|
|
||||||
|
@ -127,7 +140,37 @@ void BehaviorSettingsPage::loadSettings()
|
||||||
|
|
||||||
m_showToolTips->setChecked(GeneralSettings::showToolTips());
|
m_showToolTips->setChecked(GeneralSettings::showToolTips());
|
||||||
m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
|
m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
|
||||||
m_naturalSorting->setChecked(GeneralSettings::naturalSorting());
|
|
||||||
m_renameInline->setChecked(GeneralSettings::renameInline());
|
m_renameInline->setChecked(GeneralSettings::renameInline());
|
||||||
|
|
||||||
|
loadSortingChoiceSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BehaviorSettingsPage::setSortingChoiceValue(GeneralSettings *settings)
|
||||||
|
{
|
||||||
|
using Choice = GeneralSettings::EnumSortingChoice;
|
||||||
|
if (m_naturalSorting->isChecked()) {
|
||||||
|
settings->setSortingChoice(Choice::NaturalSorting);
|
||||||
|
} else if (m_caseInsensitiveSorting->isChecked()) {
|
||||||
|
settings->setSortingChoice(Choice::CaseInsensitiveSorting);
|
||||||
|
} else if (m_caseSensitiveSorting->isChecked()) {
|
||||||
|
settings->setSortingChoice(Choice::CaseSensitiveSorting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BehaviorSettingsPage::loadSortingChoiceSettings()
|
||||||
|
{
|
||||||
|
using Choice = GeneralSettings::EnumSortingChoice;
|
||||||
|
switch (GeneralSettings::sortingChoice()) {
|
||||||
|
case Choice::NaturalSorting:
|
||||||
|
m_naturalSorting->setChecked(true);
|
||||||
|
break;
|
||||||
|
case Choice::CaseInsensitiveSorting:
|
||||||
|
m_caseInsensitiveSorting->setChecked(true);
|
||||||
|
break;
|
||||||
|
case Choice::CaseSensitiveSorting:
|
||||||
|
m_caseSensitiveSorting->setChecked(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <settings/settingspagebase.h>
|
#include <settings/settingspagebase.h>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include "dolphin_generalsettings.h"
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
@ -46,6 +47,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
void setSortingChoiceValue(GeneralSettings* settings);
|
||||||
|
void loadSortingChoiceSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
|
@ -56,7 +59,11 @@ private:
|
||||||
QCheckBox* m_showToolTips;
|
QCheckBox* m_showToolTips;
|
||||||
QLabel* m_configureToolTips;
|
QLabel* m_configureToolTips;
|
||||||
QCheckBox* m_showSelectionToggle;
|
QCheckBox* m_showSelectionToggle;
|
||||||
QCheckBox* m_naturalSorting;
|
|
||||||
|
QRadioButton* m_naturalSorting;
|
||||||
|
QRadioButton* m_caseSensitiveSorting;
|
||||||
|
QRadioButton* m_caseInsensitiveSorting;
|
||||||
|
|
||||||
QCheckBox* m_renameInline;
|
QCheckBox* m_renameInline;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue