Bug 96441 - datawizard should not sort available fields alphabetically
Summary: datawizard should not sort available fields alphabetically
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Solaris
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-06 14:38 UTC by Nicolas Brisset
Modified: 2005-01-07 00:45 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Brisset 2005-01-06 14:38:18 UTC
Version:           1.1.0_dr1 (using KDE 3.3.0, compiled sources)
Compiler:          gcc version 3.3.2
OS:                SunOS (sun4u) release 5.8

When using the datawizard to load data from a file, the available variables are listed and automatically sorted alphabetically in the listview on the left. Very often, you know inwhat order variables come in you data file, and it is a common complaint around here that variables can only be sorted alphabetically.
It would be better to allow sorting alphabetically by clicking on the column header, but NOT sort by default (I think this should be easy to implement, like _vectors->setSorting(2) or something similar). 
It is probably also useful to add a button somewhere to allow resetting the order to that in the datafile, in case the user wants to come backto the initial order, which is currently not possible.
Comment 1 Andrew Walker 2005-01-07 00:45:45 UTC
CVS commit by arwalker: 

CCMAIL: 96441-done@bugs.kde.org

I think this addresses the problem. I've added an additional column to the list of vectors which is the position of the vector in the list. Sorting is done on this column by default, but can be changed by clicking on the column header.


  M +24 -6     datawizard.ui.h   1.105


--- kdeextragear-2/kst/kst/datawizard.ui.h  #1.104:1.105
@@ -31,4 +31,7 @@ void DataWizard::init()
     connect(finishButton(), SIGNAL(clicked()), this, SLOT(finished()));
 
+    _vectors->addColumn(i18n("Position"));
+    _vectors->setSorting(1);
+
     // No help button
     setHelpEnabled(_pageDataSource, false);
@@ -114,4 +117,7 @@ void DataWizard::sourceChanged( const QS
         bool complete = false;
         QString fileType;
+  QString str;
+  int index = 0;
+  int count;
 
         if (ds) {
@@ -143,7 +149,19 @@ void DataWizard::sourceChanged( const QS
         _xVector->completionObject()->insertItems(fl);
         _xVector->setEditable(!complete);
+
+  count = fl.count();
+  if (count > 0) {
+    count = 1+(int)log10((double)count);
+  } else {
+    count = 1;
+  }
         for (QStringList::ConstIterator it = fl.begin(); it != fl.end(); ++it) {
-            new QCheckListItem(_vectors, *it, QCheckListItem::CheckBox);
+            QCheckListItem *pItem = new QCheckListItem(_vectors, *it, QCheckListItem::CheckBox);
+      str.sprintf("%0*d", count, index);
+      pItem->setText(1, str);
+      index++;
         }
+  _vectors->sort();
+  
         KST::vectorDefaults.sync();
         QString defaultX = KST::vectorDefaults.wizardXVector();
@@ -310,5 +328,5 @@ void DataWizard::vectorSubset(const QStr
     QListViewItem *after = 0L;
     _vectors->clearSelection();
-    _vectors->setSorting(2, true); // Qt 3.1 compat
+    _vectors->setSorting(3, true); // Qt 3.1 compat
     QRegExp re(filter, true /* case insensitive */, true /* wildcard */);
     QListViewItemIterator it(_vectors);