summaryrefslogtreecommitdiffstats
path: root/libkonq
diff options
context:
space:
mode:
authorVincent Reher <tde@4reher.org>2022-03-05 15:14:32 -0800
committerMichele Calgaro <michele.calgaro@yahoo.it>2022-07-02 16:02:09 +0900
commitd4e06b76962198eb64e6c2826d4695248102037c (patch)
tree2ab32e02df377eb96cc5ba0dc04729ae61c047e9 /libkonq
parentd59c8ee79f91d41d0979bd09c5e50cc43916330c (diff)
downloadtdebase-d4e06b76962198eb64e6c2826d4695248102037c.tar.gz
tdebase-d4e06b76962198eb64e6c2826d4695248102037c.zip
Replace listview's binary "Case Insensitive Sort" option with 3 mutually exclusive options:
1. Unicode based (AB...ab) 2. Unicode based, case insensitive (aAbB) 2. Locale based This resolves issue #252. Signed-off-by: Vincent Reher <tde@4reher.org>
Diffstat (limited to 'libkonq')
-rw-r--r--libkonq/CMakeLists.txt1
-rw-r--r--libkonq/Makefile.am3
-rw-r--r--libkonq/konq_propsview.cpp27
-rw-r--r--libkonq/konq_propsview.h5
-rw-r--r--libkonq/konq_sort_constants.h13
-rw-r--r--libkonq/konq_string_compare.h51
6 files changed, 98 insertions, 2 deletions
diff --git a/libkonq/CMakeLists.txt b/libkonq/CMakeLists.txt
index e774a81bb..c1780780d 100644
--- a/libkonq/CMakeLists.txt
+++ b/libkonq/CMakeLists.txt
@@ -43,6 +43,7 @@ install( FILES
konq_historymgr.h konq_historycomm.h konq_pixmapprovider.h
kivdirectoryoverlay.h kivfreespaceoverlay.h konq_faviconmgr.h
konq_xmlguiclient.h konqbookmarkmanager.h konq_filetip.h
+ konq_sort_constants.h konq_string_compare.h
DESTINATION ${INCLUDE_INSTALL_DIR} )
diff --git a/libkonq/Makefile.am b/libkonq/Makefile.am
index 3290c3e85..3c3897155 100644
--- a/libkonq/Makefile.am
+++ b/libkonq/Makefile.am
@@ -52,7 +52,8 @@ include_HEADERS = konq_popupmenu.h knewmenu.h \
konq_pixmapprovider.h \
kivdirectoryoverlay.h \
kivfreespaceoverlay.h \
- konq_faviconmgr.h konq_xmlguiclient.h konqbookmarkmanager.h konq_filetip.h
+ konq_faviconmgr.h konq_xmlguiclient.h konqbookmarkmanager.h konq_filetip.h \
+ konq_sort_constants.h konq_string_compare.h
if include_ARTS
diff --git a/libkonq/konq_propsview.cpp b/libkonq/konq_propsview.cpp
index af7a65eae..f72aee191 100644
--- a/libkonq/konq_propsview.cpp
+++ b/libkonq/konq_propsview.cpp
@@ -34,6 +34,8 @@
#include <ksimpleconfig.h>
+#include "konq_sort_constants.h"
+
static TQPixmap wallpaperPixmap( const TQString & _wallpaper )
{
TQString key = "wallpapers/";
@@ -65,10 +67,11 @@ static TQPixmap wallpaperPixmap( const TQString & _wallpaper )
struct KonqPropsView::Private
{
TQStringList* previewsToShow;
+ TextSortOrder textSortOrder;
bool previewsEnabled:1;
bool caseInsensitiveSort:1;
- bool hiddenfirst:1;
bool dirsfirst:1;
+ bool hiddenfirst:1;
bool descending:1;
TQString sortcriterion;
};
@@ -91,6 +94,7 @@ KonqPropsView::KonqPropsView( TDEInstance * instance, KonqPropsView * defaultPro
m_iIconSize = config->readNumEntry( "IconSize", 0 );
m_iItemTextPos = config->readNumEntry( "ItemTextPos", TQIconView::Bottom );
d->sortcriterion = config->readEntry( "SortingCriterion", "sort_nci" );
+ d->textSortOrder = (TextSortOrder) config->readNumEntry( "TextSortOrder", 1 );
d->dirsfirst = config->readBoolEntry( "SortDirsFirst", true );
d->hiddenfirst = config->readBoolEntry( "SortHiddenFirst", true );
d->descending = config->readBoolEntry( "SortDescending", false );
@@ -140,6 +144,11 @@ bool KonqPropsView::isCaseInsensitiveSort() const
return d->caseInsensitiveSort;
}
+TextSortOrder KonqPropsView::getSortOrder() const
+{
+ return d->textSortOrder;
+}
+
bool KonqPropsView::isDirsFirst() const
{
return d->dirsfirst;
@@ -206,6 +215,7 @@ bool KonqPropsView::enterDir( const KURL & dir )
m_iIconSize = m_defaultProps->iconSize();
m_iItemTextPos = m_defaultProps->itemTextPos();
d->sortcriterion = m_defaultProps->sortCriterion();
+ d->textSortOrder = m_defaultProps->getSortOrder();
d->dirsfirst = m_defaultProps->isDirsFirst();
d->hiddenfirst = m_defaultProps->isHiddenFirst();
d->descending = m_defaultProps->isDescending();
@@ -226,6 +236,7 @@ bool KonqPropsView::enterDir( const KURL & dir )
m_iIconSize = config->readNumEntry( "IconSize", m_iIconSize );
m_iItemTextPos = config->readNumEntry( "ItemTextPos", m_iItemTextPos );
d->sortcriterion = config->readEntry( "SortingCriterion" , d->sortcriterion );
+ d->textSortOrder = (TextSortOrder) config->readNumEntry( "TextSortOrder", d->textSortOrder );
d->dirsfirst = config->readBoolEntry( "SortDirsFirst", d->dirsfirst );
d->hiddenfirst = config->readBoolEntry( "SortHiddenFirst", d->hiddenfirst );
d->descending = config->readBoolEntry( "SortDescending", d->descending );
@@ -324,6 +335,20 @@ void KonqPropsView::setSortCriterion( const TQString &criterion )
}
}
+void KonqPropsView::setSortOrder( TextSortOrder order)
+{
+ d->textSortOrder = order;
+ if ( m_defaultProps && !m_bSaveViewPropertiesLocally ) {
+ m_defaultProps->setSortOrder( order );
+ }
+ else if (currentConfig())
+ {
+ TDEConfigGroupSaver cgs(currentConfig(), currentGroup());
+ currentConfig()->writeEntry( "TextSortOrder", d->textSortOrder );
+ currentConfig()->sync();
+ }
+}
+
void KonqPropsView::setDirsFirst( bool first)
{
d->dirsfirst = first;
diff --git a/libkonq/konq_propsview.h b/libkonq/konq_propsview.h
index 84ffcf029..132c53a55 100644
--- a/libkonq/konq_propsview.h
+++ b/libkonq/konq_propsview.h
@@ -26,6 +26,8 @@
#include <kurl.h>
#include <libkonq_export.h>
+#include "konq_sort_constants.h"
+
class TDEInstance;
class TDEConfigBase;
class TDEConfig;
@@ -90,6 +92,9 @@ public:
void setSortCriterion( const TQString &criterion );
const TQString& sortCriterion() const;
+ void setSortOrder( TextSortOrder order);
+ TextSortOrder getSortOrder() const;
+
void setDirsFirst ( bool first );
bool isDirsFirst() const;
diff --git a/libkonq/konq_sort_constants.h b/libkonq/konq_sort_constants.h
new file mode 100644
index 000000000..f6c695b19
--- /dev/null
+++ b/libkonq/konq_sort_constants.h
@@ -0,0 +1,13 @@
+#ifndef KONQ_SORT_CONSTANTS_H
+#define KONQ_SORT_CONSTANTS_H
+
+typedef unsigned short TextSortOrder;
+ // Can't use name 'SortOrder' because that's part of TQt
+
+enum {
+ UNICODE_UNMODIFIED = 0,
+ LOCALE_UNMODIFIED = 1,
+ UNICODE_CASEINSENSITIVE = 2,
+} TextSortOrders;
+
+#endif // KONQ_SORT_CONSTANTS_H
diff --git a/libkonq/konq_string_compare.h b/libkonq/konq_string_compare.h
new file mode 100644
index 000000000..8d17d409f
--- /dev/null
+++ b/libkonq/konq_string_compare.h
@@ -0,0 +1,51 @@
+#ifndef KONQ_STRING_COMPARE_H
+#define KONQ_STRING_COMPARE_H
+
+#include "konq_sort_constants.h"
+
+static inline int stringCompare(
+ const TextSortOrder sortorder,
+ const TQString& a,
+ const TQString& b
+)
+{
+ // Our caller probably determined sortorder from KonqPropsView::getSortOrder()
+ // but we have a reasonable fallback position for bogus values.
+
+ switch(sortorder) {
+
+ case UNICODE_UNMODIFIED:
+ /*
+ * Strictly character code(point) numeric comparison as defined
+ * by the Unicode Standard that is backward compatible with the
+ * the ASCII standard.
+ . */
+ return a.compare( b );
+ break;
+
+ case UNICODE_CASEINSENSITIVE:
+ /*
+ * This is the traditional "case-insensitive" variation on character
+ * code order that ensures that ASCII lowercase and uppercase alphabetic
+ * characters are are grouped together instead of being separated by
+ * non-alphabetic ASCII characters [ \ ] ^ _ `
+ */
+ return a.lower().compare( b.lower() );
+ break;
+
+ case LOCALE_UNMODIFIED:
+ /*
+ * This is the pure locale-aware comparison as defined by ICU.
+ * Note: if LC_COLLATE == 'C' or 'Posix', this will produce same
+ * result as UNICODE_UNMODIFIED.
+ */
+ return a.localeAwareCompare( b );
+ break;
+
+ default: // Treat as UNICODE_UNMODIFIED
+ return a.compare( b );
+ break;
+ }
+}
+
+#endif // KONQ_STRING_COMPARE_H