summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Reher <vreher@google.com>2021-04-27 11:53:13 -0700
committerVincent Reher <vreher@google.com>2021-04-27 11:53:13 -0700
commit9b28ca939f404fef2b31be737d81feaa8c62257a (patch)
tree118773c641cd90034ec305d3d154604435355e76
parent974182fe6aad9c3f033b1d599d0d284a3703a565 (diff)
downloadtdebase-reworked/feature/konq_listview++_14.1.tar.gz
tdebase-reworked/feature/konq_listview++_14.1.zip
Changes made that affect "Alternate Sort Order" feature:reworked/feature/konq_listview++_14.1
1. Primary column for "Alternate Sort Order" feature is no longer fixed to FileName. Last 2 columns clicked will define columns to alternate between with Ctrl-S. 2. Tightened up when & how associated configuration data items are initialized or reset. Changes should address suggestions made here: https://mirror.git.trinitydesktop.org/gitea/TDE/tdebase/issues/196#issuecomment-12271 Signed-off-by: Vincent Reher <vreher@google.com>
-rw-r--r--konqueror/listview/konq_listview.cpp154
-rw-r--r--konqueror/listview/konq_listview.h3
-rw-r--r--konqueror/listview/konq_listview.kcfg18
3 files changed, 146 insertions, 29 deletions
diff --git a/konqueror/listview/konq_listview.cpp b/konqueror/listview/konq_listview.cpp
index 2df4db77c..426577194 100644
--- a/konqueror/listview/konq_listview.cpp
+++ b/konqueror/listview/konq_listview.cpp
@@ -539,6 +539,9 @@ void KonqListView::slotColumnToggled()
// Update column sizes
slotHeaderSizeChanged();
+
+ // Columns may have been rearranged, so do this to be safe:
+ resetSortConfig();
}
void KonqListView::slotHeaderClicked(int sec)
@@ -565,68 +568,166 @@ void KonqListView::slotHeaderClicked(int sec)
m_pListView->setAscending(!m_pListView->ascending());
}
+ checkSortConfig() ;
KonqListViewSettings config( m_pListView->url().protocol() );
config.readConfig();
- if (nameOfSortColumn == m_sortColumnNamePrimary)
- {
- m_sortColumnNamePrimary = nameOfSortColumn;
- m_sortColumnIndexPrimary = sec;
- m_sortColumnOrderPrimary = m_pListView->ascending();
- config.setPrimarySortOrder(m_pListView->ascending());
+ if (sec == m_sortColumnIndexPrimary) {
+ kdDebug(1202)<<"Changing sort order on primary sort column"<<endl;
+ m_sortColumnOrderPrimary = m_pListView->ascending();
+ config.setPrimarySortOrder(m_pListView->ascending());
}
- else
- {
- m_sortColumnNameAlternate = nameOfSortColumn;
- m_sortColumnIndexAlternate = sec;
- m_sortColumnOrderAlternate = m_pListView->ascending();
- config.setAlternateSortCol(nameOfSortColumn);
- config.setAlternateSortIndex(sec);
- config.setAlternateSortOrder(m_pListView->ascending());
+ else if (sec == m_sortColumnIndexAlternate) {
+ kdDebug(1202)<<"Changing sort order on alternate sort column"<<endl;
+ m_sortColumnOrderAlternate = m_pListView->ascending();
+ config.setAlternateSortOrder(m_pListView->ascending());
+ }
+ else if ( toggleColumnAlternate ) {
+ kdDebug(1202)<<"Setting new alternate sort column"<<endl;
+ m_sortColumnNameAlternate = nameOfSortColumn;
+ m_sortColumnIndexAlternate = sec;
+ m_sortColumnOrderAlternate = true;
+ config.setAlternateSortCol(nameOfSortColumn);
+ config.setAlternateSortIndex(sec);
+ config.setAlternateSortOrder(true);
+ toggleColumnAlternate = false;
+ }
+ else {
+ kdDebug(1202)<<"Setting new primary sort column"<<endl;
+ m_sortColumnNamePrimary = nameOfSortColumn;
+ m_sortColumnIndexPrimary = sec;
+ m_sortColumnOrderPrimary = true;
+ config.setPrimarySortCol(nameOfSortColumn);
+ config.setPrimarySortIndex(sec);
+ config.setPrimarySortOrder(true);
+ toggleColumnAlternate = true;
}
+
config.setSortBy( nameOfSortColumn );
config.setSortOrder( m_pListView->ascending() );
config.writeConfig();
}
-#define LV_SORT_ASCENDING 1
-#define LV_SORT_REVERSE 2
+void KonqListView::resetSortConfig()
+{
+ int defaultVisibleColumn;
+ int columnNumber;
+
+ defaultVisibleColumn=0; // First visible column from left
+ columnNumber = -1;
+ for (uint i=0; i<m_pListView->NumberOfAtoms; i++)
+ if (m_pListView->confColumns[i].displayInColumn==defaultVisibleColumn)
+ columnNumber=i;
+ if (columnNumber==-1) {
+ // This should not happen!
+ kdDebug() << "We did not find columnNumber" <<endl;
+ m_sortColumnIndexPrimary = 0;
+ m_sortColumnNamePrimary = "FileName";
+ }
+ else {
+ m_sortColumnIndexPrimary = defaultVisibleColumn;
+ m_sortColumnNamePrimary=m_pListView->confColumns[columnNumber].desktopFileName;
+ }
+
+ defaultVisibleColumn=1 ; // Second visible column from left
+ columnNumber=-1;
+ for (uint i=0; i<m_pListView->NumberOfAtoms; i++)
+ if (m_pListView->confColumns[i].displayInColumn==defaultVisibleColumn)
+ columnNumber=i;
+ if (columnNumber==-1) {
+ // This should not happen!
+ kdDebug() << "We did not find columnNumber" <<endl;
+ m_sortColumnIndexAlternate = 0;
+ m_sortColumnNameAlternate = "FileName";
+ }
+ else {
+ m_sortColumnIndexAlternate = defaultVisibleColumn;
+ m_sortColumnNameAlternate=m_pListView->confColumns[columnNumber].desktopFileName;
+ }
+
+ m_sortColumnOrderPrimary = true ;
+ m_sortColumnOrderAlternate = true ;
+
+ kdDebug(1202) << "Initialized m_sortColumnIndexPrimary to " <<m_sortColumnIndexPrimary <<endl;
+ kdDebug(1202) << "Initialized m_sortColumnNamePrimary to " <<m_sortColumnNamePrimary <<endl;
+ kdDebug(1202) << "Initialized m_sortColumnIndexAlternate to " <<m_sortColumnIndexAlternate <<endl;
+ kdDebug(1202) << "Initialized m_sortColumnNameAlternate to " <<m_sortColumnNameAlternate <<endl;
+
+ KonqListViewSettings config( m_pListView->url().protocol() );
+ config.setPrimarySortCol(m_sortColumnNamePrimary);
+ config.setPrimarySortIndex(m_sortColumnIndexPrimary);
+ config.setPrimarySortOrder(m_sortColumnOrderPrimary);
+ config.setAlternateSortCol(m_sortColumnNameAlternate);
+ config.setAlternateSortIndex(m_sortColumnIndexAlternate);
+ config.setAlternateSortOrder(m_sortColumnOrderAlternate);
+ config.writeConfig() ;
+}
+
+void KonqListView::checkSortConfig()
+{
+ int defaultVisibleColumn;
+ int columnNumber;
+
+ KonqListViewSettings config( m_pListView->url().protocol() );
+ config.readConfig();
+
+ m_sortColumnIndexPrimary = config.primarySortIndex();
+ m_sortColumnNamePrimary = config.primarySortCol();
+ m_sortColumnOrderPrimary = config.primarySortOrder();
+
+ m_sortColumnIndexAlternate = config.alternateSortIndex();
+ m_sortColumnNameAlternate = config.alternateSortCol();
+ m_sortColumnOrderAlternate = config.alternateSortOrder();
+
+ if (m_sortColumnIndexPrimary >= 0 && m_sortColumnIndexAlternate >= 0)
+ if (m_sortColumnIndexPrimary != m_sortColumnIndexAlternate)
+ return ;
+ // FIXME: should we check other values?
+
+ resetSortConfig();
+}
+
+#define LV_SORT_CHANGE_COLUMN 1
+#define LV_SORT_CHANGE_ORDER 2
void KonqListView::sortListView(uint which)
{
TQString sortColumnNameCurrent = m_pListView->sortedByColumn;
+ if (sortColumnNameCurrent == "" ) {
+ sortColumnNameCurrent = "FileName" ;
+ m_pListView->sortedByColumn = sortColumnNameCurrent ;
+ }
TQString sortColumnNameNext;
int sortColumnIndex;
bool sortOrder;
+ checkSortConfig() ;
KonqListViewSettings config( m_pListView->url().protocol() );
config.readConfig();
- m_sortColumnOrderPrimary = config.primarySortOrder();
- m_sortColumnNameAlternate = config.alternateSortCol();
- m_sortColumnOrderAlternate = config.alternateSortOrder();
- m_sortColumnIndexAlternate = config.alternateSortIndex();
switch (which)
{
- case LV_SORT_ASCENDING:
+ case LV_SORT_CHANGE_COLUMN:
if (m_sortColumnNamePrimary == sortColumnNameCurrent)
{
sortColumnNameNext = m_sortColumnNameAlternate;
sortColumnIndex = m_sortColumnIndexAlternate;
sortOrder = m_sortColumnOrderAlternate;
+ kdDebug(1202) << "Changing sort column to alternate"<<endl ;
}
else
{
sortColumnNameNext = m_sortColumnNamePrimary;
sortColumnIndex = m_sortColumnIndexPrimary;
sortOrder = m_sortColumnOrderPrimary;
+ kdDebug(1202) << "Changing sort column to primary"<<endl ;
}
m_pListView->setSorting( sortColumnIndex, sortOrder );
m_pListView->sortedByColumn = sortColumnNameNext;
config.setSortBy( sortColumnNameNext );
break;
- case LV_SORT_REVERSE:
+ case LV_SORT_CHANGE_ORDER:
sortOrder = !m_pListView->ascending();
if ( m_sortColumnNamePrimary == sortColumnNameCurrent )
@@ -634,12 +735,14 @@ void KonqListView::sortListView(uint which)
sortColumnIndex = m_sortColumnIndexPrimary;
m_sortColumnOrderPrimary = sortOrder;
config.setPrimarySortOrder( sortOrder );
+ kdDebug(1202) << "Changing sort order of primary"<<endl ;
}
else
{
sortColumnIndex = m_sortColumnIndexAlternate;
m_sortColumnOrderAlternate = sortOrder ;
config.setAlternateSortOrder( sortOrder ) ;
+ kdDebug(1202) << "Changing sort order of alternate"<<endl ;
}
m_pListView->setAscending(sortOrder) ;
config.setSortOrder(sortOrder);
@@ -658,12 +761,12 @@ void KonqListView::sortListView(uint which)
void KonqListView::slotSortAlternate()
{
- KonqListView::sortListView(LV_SORT_ASCENDING);
+ KonqListView::sortListView(LV_SORT_CHANGE_COLUMN);
}
void KonqListView::slotSortReverse()
{
- KonqListView::sortListView(LV_SORT_REVERSE);
+ KonqListView::sortListView(LV_SORT_CHANGE_ORDER);
}
void KonqListView::slotToggleDisplayDirectoriesFirst()
@@ -727,6 +830,9 @@ void KonqListView::slotSaveAfterHeaderDrag()
// Update column sizes
slotHeaderSizeChanged();
+
+ // Columns were rearranged, so do this to be safe:
+ resetSortConfig();
}
void KonqListView::slotSaveColumnWidths()
diff --git a/konqueror/listview/konq_listview.h b/konqueror/listview/konq_listview.h
index 011542581..f32d5405a 100644
--- a/konqueror/listview/konq_listview.h
+++ b/konqueror/listview/konq_listview.h
@@ -158,6 +158,7 @@ private:
KMimeTypeResolver<KonqBaseListViewItem,KonqListView> *m_mimeTypeResolver;
TQTimer *m_headerTimer;
+ bool toggleColumnAlternate = true;
TQString m_sortColumnNamePrimary;
int m_sortColumnIndexPrimary;
int m_sortColumnOrderPrimary;
@@ -165,6 +166,8 @@ private:
int m_sortColumnIndexAlternate;
int m_sortColumnOrderAlternate;
+ void resetSortConfig();
+ void checkSortConfig();
void sortListView(uint which);
TDEAction *m_paSelect;
diff --git a/konqueror/listview/konq_listview.kcfg b/konqueror/listview/konq_listview.kcfg
index 8d208dcb4..027c39ba7 100644
--- a/konqueror/listview/konq_listview.kcfg
+++ b/konqueror/listview/konq_listview.kcfg
@@ -2,12 +2,11 @@
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
- http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<include>tdeapplication.h</include>
<kcfgfile name="konquerorrc">
<parameter name="Protocol" />
</kcfgfile>
-
<group name="ListView_$(Protocol)">
<entry key="SortBy" type="String">
<default>FileName</default>
@@ -19,18 +18,28 @@
<label>Sort Order</label>
<whatsthis></whatsthis>
</entry>
+ <entry key="PrimarySortCol" type="String">
+ <default>TBD</default>
+ <label>Primary sort column name</label>
+ <whatsthis></whatsthis>
+ </entry>
+ <entry key="PrimarySortIndex" type="Int">
+ <default>-1</default>
+ <label>Primary sort column offset</label>
+ <whatsthis></whatsthis>
+ </entry>
<entry key="PrimarySortOrder" type="Bool">
<default>true</default>
<label>Primary sort column sorting order</label>
<whatsthis></whatsthis>
</entry>
<entry key="AlternateSortCol" type="String">
- <default>Date</default>
+ <default>TBD</default>
<label>Alternate sort column name</label>
<whatsthis></whatsthis>
</entry>
<entry key="AlternateSortIndex" type="Int">
- <default>0</default>
+ <default>-1</default>
<label>Alternate sort column offset</label>
<whatsthis></whatsthis>
</entry>
@@ -53,5 +62,4 @@
<whatsthis></whatsthis>
</entry>
</group>
-
</kcfg> \ No newline at end of file