[Kst] branches/work/kst/portto4/kst/src/libkstapp

Barth Netterfield netterfield at astro.utoronto.ca
Wed Jan 30 12:37:55 CET 2008


SVN commit 768565 by netterfield:

Starting command line parsing....
Reading .kst files is temporarily broken.



 M  +4 -3      application.cpp  
 M  +6 -0      document.cpp  
 M  +2 -0      document.h  
 M  +2 -2      libkstapp.pro  
 M  +9 -0      mainwindow.cpp  
 M  +1 -0      mainwindow.h  


--- branches/work/kst/portto4/kst/src/libkstapp/application.cpp #768564:768565
@@ -10,7 +10,6 @@
  ***************************************************************************/
 
 #include "application.h"
-#include "qgetoptions.h"
 
 #include "builtinprimitives.h"
 #include "builtindatasources.h"
@@ -52,7 +51,7 @@
   DialogLauncher::replaceSelf(new DialogLauncherGui);
 
   connect(this, SIGNAL(aboutToQuit()), _mainWindow, SLOT(aboutToQuit()));
-
+/*
   QGetOptions options;
 
   QVariant file;
@@ -61,8 +60,10 @@
   options.getValues();
 
   if (!file.toString().isEmpty())
-    _mainWindow->openFile(file.toString());
+    _mainWindow->openFile(file.toString());*/
 
+  _mainWindow->initFromCommandLine();
+
   _mainWindow->show();
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/document.cpp #768564:768565
@@ -21,6 +21,7 @@
 #include <primitivefactory.h>
 #include <relationfactory.h>
 #include <viewitem.h>
+#include <commandlineparser.h>
 #include "objectstore.h"
 
 #include <QDebug>
@@ -127,7 +128,12 @@
   return true;
 }
 
+bool Document::initFromCommandLine() {
+  CommandLineParser P;
 
+  return(P.processCommandLine());
+}
+
 bool Document::open(const QString& file) {
   _isOpen = false;
   QFile f(file);
--- branches/work/kst/portto4/kst/src/libkstapp/document.h #768564:768565
@@ -31,6 +31,8 @@
 
     QString fileName() const;
 
+    bool initFromCommandLine();
+
     bool open(const QString& file);
     bool save(const QString& to = QString::null);
 
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #768564:768565
@@ -31,6 +31,7 @@
     changedatasampledialog.cpp \
     changefiledialog.cpp \
     choosecolordialog.cpp \
+    commandlineparser.cpp \
     contenttab.cpp \
     csddialog.cpp \
     curvedialog.cpp \
@@ -79,7 +80,6 @@
     plotitemmanager.cpp \
     plotrenderitem.cpp \
     powerspectrumdialog.cpp \
-    qgetoptions.cpp \
     scalardialog.cpp \
     scalarmodel.cpp \
     scene.cpp \
@@ -113,6 +113,7 @@
     changedatasampledialog.h \
     changefiledialog.h \
     choosecolordialog.h \
+    commandlineparser.h\
     contenttab.h \
     csddialog.h \
     curvedialog.h \
@@ -162,7 +163,6 @@
     plotitemmanager.h \
     plotrenderitem.h \
     powerspectrumdialog.h \
-    qgetoptions.h \
     scalardialog.h \
     scalarmodel.h \
     scene.h \
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #768564:768565
@@ -204,6 +204,15 @@
   openFile(fn);
 }
 
+void MainWindow::initFromCommandLine() {
+  delete _doc;
+  _doc = new Document(this);
+  bool ok = _doc->initFromCommandLine();
+  if (!ok) {
+    //FIXME: should now exit cleanly
+    exit(0);
+  }
+}
 
 void MainWindow::openFile(const QString &file) {
   delete _doc;
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #768564:768565
@@ -45,6 +45,7 @@
     TabWidget *tabWidget() const;
     Document *document() const;
     QProgressBar *progressBar() const;
+    void initFromCommandLine();
 
   public Q_SLOTS:
     void showDataManager();


More information about the Kst mailing list