diff options
author | Vincent Reher <[email protected]> | 2022-03-05 15:14:32 -0800 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2022-07-02 16:02:09 +0900 |
commit | d4e06b76962198eb64e6c2826d4695248102037c (patch) | |
tree | 2ab32e02df377eb96cc5ba0dc04729ae61c047e9 /konqueror | |
parent | d59c8ee79f91d41d0979bd09c5e50cc43916330c (diff) | |
download | tdebase-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 <[email protected]>
Diffstat (limited to 'konqueror')
-rw-r--r-- | konqueror/listview/konq_detailedlistview.rc | 10 | ||||
-rw-r--r-- | konqueror/listview/konq_infolistview.rc | 10 | ||||
-rw-r--r-- | konqueror/listview/konq_listview.cpp | 71 | ||||
-rw-r--r-- | konqueror/listview/konq_listview.h | 8 | ||||
-rw-r--r-- | konqueror/listview/konq_listviewitems.cpp | 10 | ||||
-rw-r--r-- | konqueror/listview/konq_listviewwidget.cpp | 12 | ||||
-rw-r--r-- | konqueror/listview/konq_listviewwidget.h | 3 | ||||
-rw-r--r-- | konqueror/listview/konq_textview.rc | 10 | ||||
-rw-r--r-- | konqueror/listview/konq_treeview.rc | 10 |
9 files changed, 106 insertions, 38 deletions
diff --git a/konqueror/listview/konq_detailedlistview.rc b/konqueror/listview/konq_detailedlistview.rc index 79059c6d4..06c9bc318 100644 --- a/konqueror/listview/konq_detailedlistview.rc +++ b/konqueror/listview/konq_detailedlistview.rc @@ -1,5 +1,5 @@ <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<kpartgui name="KonqDetailedListView" version="12"> +<kpartgui name="KonqDetailedListView" version="13"> <MenuBar> <Menu name="edit"><text>&Edit</text> <Menu name="selection"><text>Selection</text> @@ -24,12 +24,14 @@ </Menu> <Separator/> <Action name="show_dot"/> - <Menu name="sort"><text>Sort</text> + <Menu name="sort"><text>&Sort</text> + <Action name="order_unicode_based"/> + <Action name="order_unicode_based_case_insensitive"/> + <Action name="order_locale_based"/> + <Separator/> <Action name="group_directories_first"/> <Action name="group_hidden_first"/> <Separator/> - <Action name="sort_caseinsensitive"/> - <Separator/> <Action name="alternate_sort_order"/> <Action name="reverse_sort_order"/> </Menu> diff --git a/konqueror/listview/konq_infolistview.rc b/konqueror/listview/konq_infolistview.rc index 451eb5785..60f511b1f 100644 --- a/konqueror/listview/konq_infolistview.rc +++ b/konqueror/listview/konq_infolistview.rc @@ -1,5 +1,5 @@ <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<kpartgui name="KonqInfoListView" version="13"> +<kpartgui name="KonqInfoListView" version="14"> <MenuBar> <Menu name="edit"><text>&Edit</text> <Menu name="selection"><text>Selection</text> @@ -24,12 +24,14 @@ </Menu> <Separator/> <Action name="show_dot"/> - <Menu name="sort"><text>Sort</text> + <Menu name="sort"><text>&Sort</text> + <Action name="order_unicode_based"/> + <Action name="order_unicode_based_case_insensitive"/> + <Action name="order_locale_based"/> + <Separator/> <Action name="group_directories_first"/> <Action name="group_hidden_first"/> <Separator/> - <Action name="sort_caseinsensitive"/> - <Separator/> <Action name="alternate_sort_order"/> <Action name="reverse_sort_order"/> </Menu> diff --git a/konqueror/listview/konq_listview.cpp b/konqueror/listview/konq_listview.cpp index f8307e84c..5a06068ca 100644 --- a/konqueror/listview/konq_listview.cpp +++ b/konqueror/listview/konq_listview.cpp @@ -48,6 +48,8 @@ #include <unistd.h> #include <kinstance.h> +#include <konq_sort_constants.h> + KonqListViewFactory::KonqListViewFactory() { s_instance = 0; @@ -929,19 +931,50 @@ void KonqListView::setupActions() m_paShowDot = new TDEToggleAction( i18n( "Show &Hidden Files" ), 0, this, TQT_SLOT( slotShowDot() ), actionCollection(), "show_dot" ); // m_paShowDot->setCheckedState(i18n("Hide &Hidden Files")); + m_paCaseInsensitive = new TDEToggleAction(i18n("Case Insensitive Sort"), 0, this, TQT_SLOT(slotCaseInsensitive()),actionCollection(), "sort_caseinsensitive" ); m_paSortAlternate = new TDEAction( i18n( "&Alternate Sort Order" ), CTRL+Key_S, this, - TQT_SLOT( slotSortAlternate() ), actionCollection(), "alternate_sort_order"); + TQT_SLOT( slotSortAlternate() ), actionCollection(), "alternate_sort_order"); + m_paSortAlternate->setToolTip( i18n( "Sort by PREVIOUS sort column" ) ); m_paSortReverse = new TDEAction( i18n( "&Reverse Sort Order" ), CTRL+Key_R, this, TQT_SLOT( slotSortReverse() ), actionCollection(), "reverse_sort_order"); - - m_paDisplayDirectoriesFirst = new TDEToggleAction( i18n("Group &Directories First"), 0, this, + m_paSortReverse->setToolTip( i18n( "Reverse sort order of current sort column" ) ); + + /* + Build View->Sort submenu interface to properties + SortOrder, SortDirsFirst & SortHiddenFirst + */ + TextSortOrder initialOrder = m_pProps->getSortOrder(); + + m_paOrderUnicodeUnmodified = new TDEToggleAction( i18n( "&Unicode based" ), ALT+Key_1, this, + TQT_SLOT( slotOrderUnicodeUnmodified() ), actionCollection(), "order_unicode_based" ); + m_paOrderUnicodeUnmodified->setToolTip( i18n( "Strict numeric Unicode based order" ) ); + m_paOrderUnicodeUnmodified->setChecked( initialOrder == UNICODE_UNMODIFIED ); + + m_paOrderUnicodeCaseInsensitive = new TDEToggleAction( i18n( "Unicode based, &case insensitive" ), ALT+Key_2, this, + TQT_SLOT( slotOrderUnicodeCaseInsensitive() ), actionCollection(), "order_unicode_based_case_insensitive" ); + m_paOrderUnicodeCaseInsensitive->setToolTip( i18n( "Unicode based order but with lower/upper case ASCII letters adjacent" ) ); + m_paOrderUnicodeCaseInsensitive->setChecked(initialOrder == UNICODE_CASEINSENSITIVE); + + m_paOrderLocale = new TDEToggleAction( i18n( "&Locale based" ), ALT+Key_3, this, + TQT_SLOT( slotOrderLocale() ), actionCollection(), "order_locale_based" ); + m_paOrderLocale->setToolTip( i18n( "Locale based order, usually \"friendly\"" ) ); + m_paOrderLocale->setChecked(initialOrder == LOCALE_UNMODIFIED); + + // Convert above 3 checkbox menu items into single 3-way radio button menu item + m_paOrderUnicodeUnmodified->setExclusiveGroup( "sortOrder" ); + m_paOrderUnicodeCaseInsensitive->setExclusiveGroup( "sortOrder" ); + m_paOrderLocale->setExclusiveGroup( "sortOrder" ); + + m_paDisplayDirectoriesFirst = new TDEToggleAction( i18n("Group &Directories First"), CTRL+SHIFT+Key_F, this, TQT_SLOT(slotToggleDisplayDirectoriesFirst()), actionCollection(), "group_directories_first"); - m_paDisplayDirectoriesFirst->setChecked(m_pProps->isHiddenFirst()); + m_paDisplayDirectoriesFirst->setToolTip( i18n( "Always display directories before non-directories" ) ); + m_paDisplayDirectoriesFirst->setChecked(m_pProps->isDirsFirst()); - m_paDisplayHiddenFirst = new TDEToggleAction( i18n("Group &Hidden First"), 0, this, + m_paDisplayHiddenFirst = new TDEToggleAction( i18n("Group &Hidden First"), CTRL+SHIFT+Key_H, this, TQT_SLOT(slotToggleDisplayHiddenFirst()), actionCollection(), "group_hidden_first"); + m_paDisplayHiddenFirst->setToolTip( i18n( "Always display hidden files before non-hidden files" ) ); m_paDisplayHiddenFirst->setChecked(m_pProps->isHiddenFirst()); newIconSize( TDEIcon::SizeSmall /* default size */ ); @@ -955,6 +988,32 @@ void KonqListView::slotSelectionChanged() // m_paInvertSelection->setEnabled( itemSelected ); } -#include "konq_listview.moc" +void KonqListView::slotOrderUnicodeUnmodified() +{ + TextSortOrder sortOrder = UNICODE_UNMODIFIED ; + kdDebug(1202) << "Setting name order = " << sortOrder << endl; + m_pProps->setSortOrder( sortOrder ); + m_pListView->m_sortOrder = sortOrder; + m_pListView->sort(); +} +void KonqListView::slotOrderUnicodeCaseInsensitive() +{ + TextSortOrder sortOrder = UNICODE_CASEINSENSITIVE; + kdDebug(1202) << "Setting name order = " << sortOrder << endl; + m_pProps->setSortOrder( sortOrder ); + m_pListView->m_sortOrder = sortOrder; + m_pListView->sort(); +} + +void KonqListView::slotOrderLocale() +{ + TextSortOrder sortOrder = LOCALE_UNMODIFIED; + kdDebug(1202) << "Setting name order = " << sortOrder << endl; + m_pProps->setSortOrder( sortOrder ); + m_pListView->m_sortOrder = sortOrder; + m_pListView->sort(); +} + +#include "konq_listview.moc" diff --git a/konqueror/listview/konq_listview.h b/konqueror/listview/konq_listview.h index 666ae7743..fc72f6e87 100644 --- a/konqueror/listview/konq_listview.h +++ b/konqueror/listview/konq_listview.h @@ -130,8 +130,12 @@ protected slots: void slotSaveColumnWidths(); // delayed void slotHeaderClicked(int sec); + void slotOrderUnicodeUnmodified(); + void slotOrderUnicodeCaseInsensitive(); + void slotOrderLocale(); void slotToggleDisplayDirectoriesFirst(); void slotToggleDisplayHiddenFirst(); + void slotSortAlternate(); void slotSortReverse(); @@ -197,6 +201,10 @@ private: TDEToggleAction *m_paShowPermissions; TDEToggleAction *m_paShowURL; + TDEToggleAction *m_paOrderUnicodeUnmodified; + TDEToggleAction *m_paOrderUnicodeCaseInsensitive; + TDEToggleAction *m_paOrderLocale; + TDEToggleAction *m_paDisplayDirectoriesFirst; TDEToggleAction *m_paDisplayHiddenFirst; }; diff --git a/konqueror/listview/konq_listviewitems.cpp b/konqueror/listview/konq_listviewitems.cpp index cf4322ef0..1766a0b0b 100644 --- a/konqueror/listview/konq_listviewitems.cpp +++ b/konqueror/listview/konq_listviewitems.cpp @@ -19,6 +19,7 @@ #include "konq_listview.h" #include <konq_settings.h> +#include "konq_string_compare.h" #include <kdebug.h> #include <tdelocale.h> #include <assert.h> @@ -303,11 +304,10 @@ int KonqBaseListViewItem::compare( TQListViewItem* item, int col, bool ascending break; } } - if ( m_pListViewWidget->caseInsensitiveSort() ) - return text( col ).lower().localeAwareCompare( k->text( col ).lower() ); - else { - return m_pListViewWidget->m_pSettings->caseSensitiveCompare( text( col ), k->text( col ) ); - } + + /* If we reach here, we are comparing text columns (e.g file name). */ + + return stringCompare( m_pListViewWidget->m_sortOrder, text( col ), k->text( col ) ); } void KonqListViewItem::paintCell( TQPainter *_painter, const TQColorGroup & _cg, int _column, int _width, int _alignment ) diff --git a/konqueror/listview/konq_listviewwidget.cpp b/konqueror/listview/konq_listviewwidget.cpp index 4c89f529d..ef70fe949 100644 --- a/konqueror/listview/konq_listviewwidget.cpp +++ b/konqueror/listview/konq_listviewwidget.cpp @@ -100,6 +100,7 @@ KonqBaseListViewWidget::KonqBaseListViewWidget( KonqListView *parent, TQWidget * ,m_bAscending(true) ,m_itemFound(false) ,m_restored(false) + ,m_sortOrder(0) ,m_filenameColumn(0) ,m_itemToGoTo("") ,m_backgroundTimer(0) @@ -1211,11 +1212,7 @@ bool KonqBaseListViewWidget::openURL( const KURL &url ) { m_pBrowserView->newIconSize( m_pBrowserView->m_pProps->iconSize() ); m_pBrowserView->m_paShowDot->setChecked( m_pBrowserView->m_pProps->isShowingDotFiles() ); - if ( m_pBrowserView->m_paCaseInsensitive->isChecked() != m_pBrowserView->m_pProps->isCaseInsensitiveSort() ) { - m_pBrowserView->m_paCaseInsensitive->setChecked( m_pBrowserView->m_pProps->isCaseInsensitiveSort() ); - // This is in case openURL returned all items synchronously. - sort(); - } + m_sortOrder = m_pBrowserView->m_pProps->getSortOrder(); // It has to be "viewport()" - this is what KonqDirPart's slots act upon, // and otherwise we get a color/pixmap in the square between the scrollbars. @@ -1571,11 +1568,6 @@ void KonqBaseListViewWidget::slotUpdateBackground() } } -bool KonqBaseListViewWidget::caseInsensitiveSort() const -{ - return m_pBrowserView->m_pProps->isCaseInsensitiveSort(); -} - // based on isExecuteArea from tdelistview.cpp int KonqBaseListViewWidget::executeArea( TQListViewItem *_item ) { diff --git a/konqueror/listview/konq_listviewwidget.h b/konqueror/listview/konq_listviewwidget.h index 613f012b3..a8a06408b 100644 --- a/konqueror/listview/konq_listviewwidget.h +++ b/konqueror/listview/konq_listviewwidget.h @@ -137,7 +137,6 @@ public: void setAscending( bool b ) { m_bAscending = b; } bool ascending() const { return m_bAscending; } - bool caseInsensitiveSort() const; virtual void paintEmptyArea( TQPainter *p, const TQRect &r ); @@ -260,6 +259,8 @@ protected: bool m_itemFound:1; bool m_restored:1; + TextSortOrder m_sortOrder; + int m_filenameColumn; int m_filenameColumnWidth; diff --git a/konqueror/listview/konq_textview.rc b/konqueror/listview/konq_textview.rc index 20b20f451..e29a0293b 100644 --- a/konqueror/listview/konq_textview.rc +++ b/konqueror/listview/konq_textview.rc @@ -1,5 +1,5 @@ <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<kpartgui name="KonqTextView" version="6"> +<kpartgui name="KonqTextView" version="7"> <MenuBar> <Menu name="edit"><text>&Edit</text> <Menu name="selection"><text>Selection</text> @@ -13,12 +13,14 @@ </Menu> <Menu name="view"><text>&View</text> <Action name="show_dot" /> - <Menu name="sort"><text>Sort</text> + <Menu name="sort"><text>&Sort</text> + <Action name="order_unicode_based"/> + <Action name="order_unicode_based_case_insensitive"/> + <Action name="order_locale_based"/> + <Separator/> <Action name="group_directories_first"/> <Action name="group_hidden_first"/> <Separator/> - <Action name="sort_caseinsensitive"/> - <Separator/> <Action name="alternate_sort_order"/> <Action name="reverse_sort_order"/> </Menu> diff --git a/konqueror/listview/konq_treeview.rc b/konqueror/listview/konq_treeview.rc index 711f267be..9ef045785 100644 --- a/konqueror/listview/konq_treeview.rc +++ b/konqueror/listview/konq_treeview.rc @@ -1,5 +1,5 @@ <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> -<kpartgui name="KonqTreeView" version="11"> +<kpartgui name="KonqTreeView" version="12"> <MenuBar> <Menu name="edit"><text>&Edit</text> <Menu name="selection"><text>Selection</text> @@ -24,12 +24,14 @@ </Menu> <Separator/> <Action name="show_dot"/> - <Menu name="sort"><text>Sort</text> + <Menu name="sort"><text>&Sort</text> + <Action name="order_unicode_based"/> + <Action name="order_unicode_based_case_insensitive"/> + <Action name="order_locale_based"/> + <Separator/> <Action name="group_directories_first"/> <Action name="group_hidden_first"/> <Separator/> - <Action name="sort_caseinsensitive"/> - <Separator/> <Action name="alternate_sort_order"/> <Action name="reverse_sort_order"/> </Menu> |