summaryrefslogtreecommitdiffstats
path: root/konqueror
diff options
context:
space:
mode:
Diffstat (limited to 'konqueror')
-rw-r--r--konqueror/listview/konq_detailedlistview.rc13
-rw-r--r--konqueror/listview/konq_infolistview.rc13
-rw-r--r--konqueror/listview/konq_listview.cpp231
-rw-r--r--konqueror/listview/konq_listview.h25
-rw-r--r--konqueror/listview/konq_listview.kcfg32
-rw-r--r--konqueror/listview/konq_listviewitems.cpp16
-rw-r--r--konqueror/listview/konq_textview.rc12
-rw-r--r--konqueror/listview/konq_treeview.rc13
8 files changed, 337 insertions, 18 deletions
diff --git a/konqueror/listview/konq_detailedlistview.rc b/konqueror/listview/konq_detailedlistview.rc
index 593e7f027..79059c6d4 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="11">
+<kpartgui name="KonqDetailedListView" version="12">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Menu name="selection"><text>Selection</text>
@@ -24,8 +24,15 @@
</Menu>
<Separator/>
<Action name="show_dot"/>
- <Action name="sort_caseinsensitive"/>
- <!--<Action name="sort_directoriesfirst" /> TODO -->
+ <Menu name="sort"><text>Sort</text>
+ <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>
<Menu name="listview_show"><text>Show Details</text>
<TearOffHandle />
<Action name="show_size"/>
diff --git a/konqueror/listview/konq_infolistview.rc b/konqueror/listview/konq_infolistview.rc
index 280b2d0ce..451eb5785 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="12">
+<kpartgui name="KonqInfoListView" version="13">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Menu name="selection"><text>Selection</text>
@@ -24,8 +24,15 @@
</Menu>
<Separator/>
<Action name="show_dot"/>
- <Action name="sort_caseinsensitive"/>
- <!--<Action name="sort_directoriesfirst" /> TODO -->
+ <Menu name="sort"><text>Sort</text>
+ <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>
<Action name="view_as"/>
<Separator/>
<Action name="bgsettings"/>
diff --git a/konqueror/listview/konq_listview.cpp b/konqueror/listview/konq_listview.cpp
index 67da49c6d..f8307e84c 100644
--- a/konqueror/listview/konq_listview.cpp
+++ b/konqueror/listview/konq_listview.cpp
@@ -268,6 +268,8 @@ KonqListView::KonqListView( TQWidget *parentWidget, TQObject *parent, const char
m_mimeTypeResolver = new KMimeTypeResolver<KonqBaseListViewItem,KonqListView>(this);
setXMLFile( xmlFile );
+ m_sortColumnIndexPrimary = 0;
+ m_sortColumnIndexAlternate = 1;
setupActions();
@@ -285,7 +287,6 @@ KonqListView::KonqListView( TQWidget *parentWidget, TQObject *parent, const char
// Note: File Type is in fact the mimetype comment. We use UDS_FILE_TYPE but that's not what we show in fact :/
m_pListView->confColumns[10].setData(I18N_NOOP("File Type"),"Type",TDEIO::UDS_FILE_TYPE,m_paShowType);
-
connect( m_pListView, TQT_SIGNAL( selectionChanged() ),
m_extension, TQT_SLOT( updateActions() ) );
connect( m_pListView, TQT_SIGNAL( selectionChanged() ),
@@ -538,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)
@@ -560,15 +564,224 @@ void KonqListView::slotHeaderClicked(int sec)
m_pListView->setAscending(TRUE);
}
else
+ {
m_pListView->setAscending(!m_pListView->ascending());
+ }
+ checkSortConfig() ;
KonqListViewSettings config( m_pListView->url().protocol() );
config.readConfig();
+
+ 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 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();
}
+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()
+{
+ 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)
+ return ;
+
+ 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();
+
+ switch (which)
+ {
+ 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_CHANGE_ORDER:
+ sortOrder = !m_pListView->ascending();
+
+ if ( m_sortColumnNamePrimary == sortColumnNameCurrent )
+ {
+ 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);
+ m_pListView->setSorting( sortColumnIndex, sortOrder );
+ break;
+
+ default:
+ // Do nothing in case of invalid call
+ return;
+ }
+
+ m_pListView->sort();
+
+ config.writeConfig();
+}
+
+void KonqListView::slotSortAlternate()
+{
+ KonqListView::sortListView(LV_SORT_CHANGE_COLUMN);
+}
+
+void KonqListView::slotSortReverse()
+{
+ KonqListView::sortListView(LV_SORT_CHANGE_ORDER);
+}
+
+void KonqListView::slotToggleDisplayDirectoriesFirst()
+{
+ m_pProps->setDirsFirst( m_paDisplayDirectoriesFirst->isChecked() );
+ m_pListView->updateListContents();
+ m_pListView->sort();
+}
+
+void KonqListView::slotToggleDisplayHiddenFirst()
+{
+ m_pProps->setHiddenFirst( m_paDisplayHiddenFirst->isChecked() );
+ m_pListView->updateListContents();
+ m_pListView->sort();
+}
+
void KonqListView::headerDragged(int sec, int from, int to)
{
kdDebug(1202)<<"section: "<<sec<<" fromIndex: "<<from<<" toIndex "<<to<<endl;
@@ -609,6 +822,9 @@ void KonqListView::slotSaveAfterHeaderDrag()
// Update column sizes
slotHeaderSizeChanged();
+
+ // Columns were rearranged, so do this to be safe:
+ resetSortConfig();
}
void KonqListView::slotSaveColumnWidths()
@@ -715,6 +931,19 @@ void KonqListView::setupActions()
// 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");
+ 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,
+ TQT_SLOT(slotToggleDisplayDirectoriesFirst()), actionCollection(), "group_directories_first");
+ m_paDisplayDirectoriesFirst->setChecked(m_pProps->isHiddenFirst());
+
+ m_paDisplayHiddenFirst = new TDEToggleAction( i18n("Group &Hidden First"), 0, this,
+ TQT_SLOT(slotToggleDisplayHiddenFirst()), actionCollection(), "group_hidden_first");
+ m_paDisplayHiddenFirst->setChecked(m_pProps->isHiddenFirst());
+
newIconSize( TDEIcon::SizeSmall /* default size */ );
}
diff --git a/konqueror/listview/konq_listview.h b/konqueror/listview/konq_listview.h
index 4c3719bd0..666ae7743 100644
--- a/konqueror/listview/konq_listview.h
+++ b/konqueror/listview/konq_listview.h
@@ -63,8 +63,10 @@ class KonqListView : public KonqDirPart
{
friend class KonqBaseListViewWidget;
friend class ListViewBrowserExtension;
+
Q_OBJECT
TQ_PROPERTY( bool supportsUndo READ supportsUndo )
+
public:
KonqListView( TQWidget *parentWidget, TQObject *parent, const char *name, const TQString& mode );
virtual ~KonqListView();
@@ -128,6 +130,11 @@ protected slots:
void slotSaveColumnWidths(); // delayed
void slotHeaderClicked(int sec);
+ void slotToggleDisplayDirectoriesFirst();
+ void slotToggleDisplayHiddenFirst();
+ void slotSortAlternate();
+ void slotSortReverse();
+
// This comes from KonqDirPart, it's for the "Find" feature
virtual void slotStarted() { m_pListView->slotStarted(); }
virtual void slotCanceled() { m_pListView->slotCanceled(); }
@@ -148,12 +155,27 @@ private:
KMimeTypeResolver<KonqBaseListViewItem,KonqListView> *m_mimeTypeResolver;
TQTimer *m_headerTimer;
+ bool toggleColumnAlternate = true;
+ TQString m_sortColumnNamePrimary;
+ int m_sortColumnIndexPrimary;
+ int m_sortColumnOrderPrimary;
+ TQString m_sortColumnNameAlternate;
+ int m_sortColumnIndexAlternate;
+ int m_sortColumnOrderAlternate;
+
+ void resetSortConfig();
+ void checkSortConfig();
+ void sortListView(uint which);
+
TDEAction *m_paSelect;
TDEAction *m_paUnselect;
TDEAction *m_paSelectAll;
TDEAction *m_paUnselectAll;
TDEAction *m_paInvertSelection;
+ TDEAction *m_paSortAlternate;
+ TDEAction *m_paSortReverse;
+
// These 2 actions are 'fake' actions. They are defined so that the keyboard shortcuts
// can be set from the 'Configure Shortcuts..." dialog.
// The real actions are performed in the TDEListViewLineEdit::keyPressEvent() in tdeui
@@ -174,6 +196,9 @@ private:
TDEToggleAction *m_paShowGroup;
TDEToggleAction *m_paShowPermissions;
TDEToggleAction *m_paShowURL;
+
+ TDEToggleAction *m_paDisplayDirectoriesFirst;
+ TDEToggleAction *m_paDisplayHiddenFirst;
};
class ListViewBrowserExtension : public KonqDirPartBrowserExtension
diff --git a/konqueror/listview/konq_listview.kcfg b/konqueror/listview/konq_listview.kcfg
index bce9798a6..5c31c5cea 100644
--- a/konqueror/listview/konq_listview.kcfg
+++ b/konqueror/listview/konq_listview.kcfg
@@ -7,7 +7,6 @@
<kcfgfile name="konquerorrc">
<parameter name="Protocol" />
</kcfgfile>
-
<group name="ListView_$(Protocol)">
<entry key="SortBy" type="String">
<default>FileName</default>
@@ -19,6 +18,36 @@
<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>TBD</default>
+ <label>Alternate sort column name</label>
+ <whatsthis></whatsthis>
+ </entry>
+ <entry key="AlternateSortIndex" type="Int">
+ <default>-1</default>
+ <label>Alternate sort column offset</label>
+ <whatsthis></whatsthis>
+ </entry>
+ <entry key="AlternateSortOrder" type="Bool">
+ <default>true</default>
+ <label>Alternate sort column sorting order</label>
+ <whatsthis></whatsthis>
+ </entry>
<entry key="FileNameColumnWidth" type="Int">
<default code="true">25 * TDEApplication::kApplication()->fontMetrics().width( "m" )</default>
<label>Width of the FileName Column</label>
@@ -33,5 +62,4 @@
<whatsthis></whatsthis>
</entry>
</group>
-
</kcfg> \ No newline at end of file
diff --git a/konqueror/listview/konq_listviewitems.cpp b/konqueror/listview/konq_listviewitems.cpp
index 45ff99c1c..cf4322ef0 100644
--- a/konqueror/listview/konq_listviewitems.cpp
+++ b/konqueror/listview/konq_listviewitems.cpp
@@ -84,10 +84,18 @@ void KonqListViewItem::updateContents()
// Set the text of each column
setText( 0, m_fileitem->text() );
- // The order is: .dir (0), dir (1), .file (2), file (3)
- sortChar = S_ISDIR( m_fileitem->mode() ) ? 1 : 3;
- if ( m_fileitem->text()[0] == '.' )
- --sortChar;
+ bool m_groupDirectoriesFirst = m_pListViewWidget->props()->isDirsFirst();
+ bool m_groupHiddenFirst = m_pListViewWidget->props()->isHiddenFirst();
+
+ // The default TDE order is: .dir (0), dir (1), .file (2), file (3)
+
+ if ( m_groupDirectoriesFirst )
+ sortChar = S_ISDIR( m_fileitem->mode() ) ? 1 : 3;
+ else
+ sortChar = 3;
+
+ if ( m_groupHiddenFirst && m_fileitem->text()[0] == '.' )
+ --sortChar;
//now we have the first column, so let's do the rest
diff --git a/konqueror/listview/konq_textview.rc b/konqueror/listview/konq_textview.rc
index 612deb5cb..20b20f451 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="5">
+<kpartgui name="KonqTextView" version="6">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Menu name="selection"><text>Selection</text>
@@ -13,7 +13,15 @@
</Menu>
<Menu name="view"><text>&amp;View</text>
<Action name="show_dot" />
- <Action name="sort_caseinsensitive"/>
+ <Menu name="sort"><text>Sort</text>
+ <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>
<Menu name="listview_show"><text>Show Details</text>
<TearOffHandle />
<Action name="show_size"/>
diff --git a/konqueror/listview/konq_treeview.rc b/konqueror/listview/konq_treeview.rc
index 7f8981779..711f267be 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="10">
+<kpartgui name="KonqTreeView" version="11">
<MenuBar>
<Menu name="edit"><text>&amp;Edit</text>
<Menu name="selection"><text>Selection</text>
@@ -24,8 +24,15 @@
</Menu>
<Separator/>
<Action name="show_dot"/>
- <Action name="sort_caseinsensitive"/>
- <!--<Action name="sort_directoriesfirst" /> TODO -->
+ <Menu name="sort"><text>Sort</text>
+ <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>
<Menu name="listview_show"><text>Show Details</text>
<TearOffHandle />
<Action name="show_size"/>