Bug 109460 - allow to load a data file directly from the command line
Summary: allow to load a data file directly from the command line
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-07-22 12:33 UTC by Nicolas Brisset
Modified: 2005-07-29 18:44 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Brisset 2005-07-22 12:33:53 UTC
Version:           1.2.0_devel (using KDE 3.4.0, compiled sources)
Compiler:          gcc version 3.4.3
OS:                SunOS (sun4u) release 5.8

Currently, if you want to work on a file named "mydata.cdf", you have to:
1) start kst
2) launch the datawizard (one click)
3) select the right file in the first page (can be many clicks)
before you can start working on it (I consider the command line switches "kst -F datafile -x foo -y bar ..." too long to type be used for normal interactive use when you want to plot many variables)

I think "kst mydata.cdf" should see that mydata.cdf is not a valid kst file (which it already sees), and instead of complaining about it, open the datawizard initialized on that file.
Comment 1 Andrew Walker 2005-07-23 00:32:33 UTC
There are problems with doing this, as if we suppress the error message if we don't have a valid kst file and also attempt to open the file in the data wizard then the user who actually does have an invalid kst file will be confused.

The better option would probably be to add another command line setting that would take a datafile name to be loaded directly into the data wizard.

Something like:

kst -w mydata.cdf

This is only slightly more to type with a much clearer intent.
Comment 2 Nicolas Brisset 2005-07-23 01:17:43 UTC
Something like that would be OK :-)
Comment 3 George Staikos 2005-07-25 20:10:04 UTC
Actually it's even worse than Andrew says, because Kst will think that all files passed to it and don't look like .kst files are ASCII files, basically.  At best we could add a new command-line option.
Comment 4 Nicolas Brisset 2005-07-25 22:58:20 UTC
You are right, so let's go for a new command line switch (-w for wizard ?) :-)
Comment 5 Andrew Walker 2005-07-29 18:44:46 UTC
SVN commit 440041 by arwalker:

BUG:109460 Allow user to specify data file to be loaded into data wizard on the command line.

 M  +1 -0      datawizard.ui  
 M  +5 -0      datawizard.ui.h  
 M  +16 -0     kst.cpp  
 M  +1 -0      kst.h  
 M  +11 -1     main.cpp  


--- trunk/extragear/graphics/kst/kst/datawizard.ui #440040:440041
@@ -1397,6 +1397,7 @@
     <variable access="private">QGuardedPtr&lt;QWidget&gt; _configWidget;</variable>
 </variables>
 <slots>
+    <slot access="public">setInput( const QString &amp; input )</slot>
     <slot access="private">init()</slot>
     <slot access="private">xChanged()</slot>
     <slot access="private">sourceChanged( const QString &amp; txt )</slot>
--- trunk/extragear/graphics/kst/kst/datawizard.ui.h #440040:440041
@@ -56,6 +56,11 @@
 }
 
 
+void DataWizard::setInput(const QString &input) {
+  _url->setURL(input);
+}
+
+
 void DataWizard::plotColsChanged() {
   _reGrid->setChecked(true);
 }
--- trunk/extragear/graphics/kst/kst/kst.cpp #440040:440041
@@ -2000,6 +2000,22 @@
   }
 }
 
+
+void KstApp::showDataWizardWithFile(const QString &input) {
+  DataWizard *dw = new DataWizard(this, "DataWizard");
+  dw->setInput(input);
+  dw->exec();
+  if (dw->result() == QDialog::Accepted) {
+    delete dw; // leave this here - releases references
+    forceUpdate();
+    doc->setModified();
+    updateDialogs();
+  } else {
+    delete dw;
+  }
+}
+
+
 void KstApp::registerDocChange() {
   kdDebug() << "register doc changed" << endl;
   forceUpdate();
--- trunk/extragear/graphics/kst/kst/kst.h #440040:440041
@@ -323,6 +323,7 @@
     void showExtensionManager();
 
     /** creates the data wizard */
+    void showDataWizardWithFile(const QString &input);
     void showDataWizard();
 
     //show the quickstart dialog, but only if specified so in the KstSettings
--- trunk/extragear/graphics/kst/kst/main.cpp #440040:440041
@@ -69,6 +69,7 @@
   { "m <NC>", I18N_NOOP("Separate plots arranged in <NC> columns"),0},
   { "d",      I18N_NOOP("Display as points rather than curves"),0},
   { "g",      I18N_NOOP("Provide a legend box"),0},
+  { "w <file>",      I18N_NOOP("Display the data wizard"),"<none>"},
   { "print <file>",  I18N_NOOP("Print to file and exit"),"<none>"},
   { "png <file>",  I18N_NOOP("Save as a png file and exit"),"<none>"},
   { "nq",     I18N_NOOP("Bypass the quickstart dialog"), 0},
@@ -373,12 +374,14 @@
     QCStringList::Iterator hs_string;
     QCStringList::Iterator eq_i;
     bool showQuickStart = false;
+    bool showDataWizard = false;
     bool nOK;
     int n_y = 0;
     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
     CheckForCMDErrors(args);
 
+    QString wizardfile = args->getOption("w");
     QString printfile = args->getOption("print");
     QString pngfile = args->getOption("png");
     bool print_and_exit = false;
@@ -718,7 +721,11 @@
     if (args->isSet("nq")) {
       showQuickStart = false;
     }
-
+    if (args->isSet("w")) {
+      showDataWizard = true;
+      showQuickStart = false;
+    }
+    
     if (printfile != "<none>") {
       kst->forceUpdate();
       kst->immediatePrintToFile(printfile);
@@ -740,6 +747,9 @@
       if (showQuickStart) {
         kst->showQuickStartDialog();
       }
+      if (showDataWizard) {
+        kst->showDataWizardWithFile(wizardfile);
+      }
       for (size_t i=0; i<strErrors.size(); i++) {
         KstDebug::self()->log(strErrors[i], KstDebug::Warning);
       }