[Kst] branches/work/kst/pluginify/kst/src

Adam Treat treat at kde.org
Wed Sep 13 21:10:03 CEST 2006


SVN commit 583903 by treat:

* Add new virtual method 'showNewDialog' and 'showEditDialog'
which replace the single '_showDialog' method.  It is ugly to
have two methods when one would normally suffice, but the non-virtual
'showDialog' method uses a singleShot which can't take parameters.

I presume that 'showDialog' uses a singleShot for threading reasons, but
it would clean up the code considerably if we could get rid of this singleShot.

The reason this is needed is because plugins will not have a singleton config
dialog which the datamanager can call on directly.  It must do it through the
KstDataObject API... hence the need to modify the '*showDialog*' methods.


 M  +6 -1      extensions/js/js_dataobject.cpp  
 M  +2 -1      extensions/js/js_dataobject.h  
 M  +36 -9     libkstapp/dialoglauncher-gui.cpp  
 M  +9 -9      libkstapp/dialoglauncher-gui.h  
 M  +1 -1      libkstapp/kstdatamanager_i.cpp  
 M  +6 -1      libkstapp/ksteventmonitorentry.cpp  
 M  +2 -1      libkstapp/ksteventmonitorentry.h  
 M  +9 -9      libkstmath/dialoglauncher.h  
 M  +2 -1      libkstmath/kstbasecurve.h  
 M  +6 -1      libkstmath/kstcsd.cpp  
 M  +2 -1      libkstmath/kstcsd.h  
 M  +5 -2      libkstmath/kstdataobject.cpp  
 M  +3 -2      libkstmath/kstdataobject.h  
 M  +6 -1      libkstmath/kstequation.cpp  
 M  +2 -1      libkstmath/kstequation.h  
 M  +6 -1      libkstmath/ksthistogram.cpp  
 M  +2 -1      libkstmath/ksthistogram.h  
 M  +6 -1      libkstmath/kstimage.cpp  
 M  +3 -2      libkstmath/kstimage.h  
 M  +6 -1      libkstmath/kstplugin.cpp  
 M  +2 -1      libkstmath/kstplugin.h  
 M  +6 -1      libkstmath/kstpsd.cpp  
 M  +2 -1      libkstmath/kstpsd.h  
 M  +6 -1      libkstmath/kstvcurve.cpp  
 M  +2 -1      libkstmath/kstvcurve.h  
 M  +6 -1      plugins/crossspectrum/crosspowerspectrum.cpp  
 M  +2 -1      plugins/crossspectrum/crosspowerspectrum.h  
 M  +6 -1      plugins/linefit/linefitplugin.cpp  
 M  +2 -1      plugins/linefit/linefitplugin.h  
 M  +5 -1      plugins/testplugin/testplugin.h  


--- branches/work/kst/pluginify/kst/src/extensions/js/js_dataobject.cpp #583902:583903
@@ -84,11 +84,16 @@
 }
 
 
-void JSDataObject::_showDialog() {
+void JSDataObject::showNewDialog() {
   // FIXME
 }
 
 
+void JSDataObject::showEditDialog() {
+  // FIXME
+}
+
+
 const KstCurveHintList* JSDataObject::curveHints() const {
   // FIXME
   return KstDataObject::curveHints();
--- branches/work/kst/pluginify/kst/src/extensions/js/js_dataobject.h #583902:583903
@@ -44,7 +44,8 @@
     void setProperty(const QString& property);
 
   protected:
-    void _showDialog();
+    void showNewDialog();
+    void showEditDialog();
     QString _propertyString;
     QString _script;
 };
--- branches/work/kst/pluginify/kst/src/libkstapp/dialoglauncher-gui.cpp #583902:583903
@@ -37,27 +37,42 @@
 
 
 void KstGuiDialogs::showHistogramDialog(const QString& name) {
-  KstHsDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstHsDialogI::globalInstance()->show();
+  else
+    KstHsDialogI::globalInstance()->showEdit(name);
 }
 
 
 void KstGuiDialogs::showPluginDialog(const QString& name) {
-  KstPluginDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstPluginDialogI::globalInstance()->show();
+  else
+    KstPluginDialogI::globalInstance()->showEdit(name);
 }
 
 
 void KstGuiDialogs::showEquationDialog(const QString& name) {
-  KstEqDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstEqDialogI::globalInstance()->show();
+  else
+    KstEqDialogI::globalInstance()->showEdit(name);
 }
 
 
 void KstGuiDialogs::showCSDDialog(const QString& name) {
-  KstCsdDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstCsdDialogI::globalInstance()->show();
+  else
+    KstCsdDialogI::globalInstance()->showEdit(name);
 }
 
 
 void KstGuiDialogs::showPSDDialog(const QString& name) {
-  KstPsdDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstPsdDialogI::globalInstance()->show();
+  else
+    KstPsdDialogI::globalInstance()->showEdit(name);
 }
 
 
@@ -79,7 +94,10 @@
 
 
 void KstGuiDialogs::showVectorDialog(const QString& name) {
-  KstVectorDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstVectorDialogI::globalInstance()->show();
+  else
+    KstVectorDialogI::globalInstance()->showEdit(name);
 }
 
 
@@ -101,17 +119,26 @@
 
 
 void KstGuiDialogs::showMatrixDialog(const QString& name) {
-  KstMatrixDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstMatrixDialogI::globalInstance()->show();
+  else
+    KstMatrixDialogI::globalInstance()->showEdit(name);
 }
 
 
 void KstGuiDialogs::showImageDialog(const QString& name) {
-  KstImageDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstImageDialogI::globalInstance()->show();
+  else
+    KstImageDialogI::globalInstance()->showEdit(name);
 }
 
 
 void KstGuiDialogs::showCurveDialog(const QString& name) {
-  KstCurveDialogI::globalInstance()->showEdit(name);
+  if ( name.isEmpty() )
+    KstCurveDialogI::globalInstance()->show();
+  else
+    KstCurveDialogI::globalInstance()->showEdit(name);
 }
 
 // vim: ts=2 sw=2 et
--- branches/work/kst/pluginify/kst/src/libkstapp/dialoglauncher-gui.h #583902:583903
@@ -24,25 +24,25 @@
     KstGuiDialogs();
     ~KstGuiDialogs();
 
-    void showHistogramDialog(const QString& name);
+    void showHistogramDialog(const QString& name = QString::null);
 
-    void showPluginDialog(const QString& name);
+    void showPluginDialog(const QString& name = QString::null);
 
-    void showEquationDialog(const QString& name);
+    void showEquationDialog(const QString& name = QString::null);
 
-    void showCSDDialog(const QString& name);
+    void showCSDDialog(const QString& name = QString::null);
 
-    void showPSDDialog(const QString& name);
+    void showPSDDialog(const QString& name = QString::null);
 
     void newMatrixDialog(QWidget *parent, const char *createdSlot = 0L, const char *selectedSlot = 0L, const char *updateSlot = 0L);
-    void showMatrixDialog(const QString& name);
+    void showMatrixDialog(const QString& name = QString::null);
 
-    void showImageDialog(const QString& name);
+    void showImageDialog(const QString& name = QString::null);
 
-    void showCurveDialog(const QString& name);
+    void showCurveDialog(const QString& name = QString::null);
 
     void newVectorDialog(QWidget *parent, const char *createdSlot = 0L, const char *selectedSlot = 0L, const char *updateSlot = 0L);
-    void showVectorDialog(const QString& name);
+    void showVectorDialog(const QString& name = QString::null);
 };
 
 #endif
--- branches/work/kst/pluginify/kst/src/libkstapp/kstdatamanager_i.cpp #583902:583903
@@ -795,7 +795,7 @@
   }
 
   if (qi->rtti() == RTTI_OBJ_OBJECT) {
-    static_cast<KstObjectItem*>(qi)->dataObject()->showDialog();
+    static_cast<KstObjectItem*>(qi)->dataObject()->showDialog(true);
   }
   
   if (qi->rtti() == RTTI_OBJ_DATA_MATRIX) {
--- branches/work/kst/pluginify/kst/src/libkstapp/ksteventmonitorentry.cpp #583902:583903
@@ -367,7 +367,12 @@
 }
 
 
-void EventMonitorEntry::_showDialog() {
+void EventMonitorEntry::showNewDialog() {
+  KstEventMonitorI::globalInstance()->show();
+}
+
+
+void EventMonitorEntry::showEditDialog() {
   KstEventMonitorI::globalInstance()->showEdit(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/libkstapp/ksteventmonitorentry.h #583902:583903
@@ -38,7 +38,8 @@
     UpdateType update(int updateCounter = -1);
     void save(QTextStream &ts, const QString& indent = QString::null);
     QString propertyString() const;
-    void _showDialog();
+    void showNewDialog();
+    void showEditDialog();
 
     bool needToEvaluate();
     bool isValid() const { return _isValid; }
--- branches/work/kst/pluginify/kst/src/libkstmath/dialoglauncher.h #583902:583903
@@ -34,25 +34,25 @@
     static void replaceSelf(KstDialogs *newInstance);
     static KstDialogs *self();
 
-    virtual void showHistogramDialog(const QString& name);
+    virtual void showHistogramDialog(const QString& name = QString::null);
 
-    virtual void showPluginDialog(const QString& name);
+    virtual void showPluginDialog(const QString& name = QString::null);
 
-    virtual void showEquationDialog(const QString& name);
+    virtual void showEquationDialog(const QString& name = QString::null);
 
-    virtual void showCSDDialog(const QString& name);
+    virtual void showCSDDialog(const QString& name = QString::null);
 
-    virtual void showPSDDialog(const QString& name);
+    virtual void showPSDDialog(const QString& name = QString::null);
 
     virtual void newMatrixDialog(QWidget *parent, const char *createdSlot = 0L, const char *selectedSlot = 0L, const char *updateSlot = 0L);
-    virtual void showMatrixDialog(const QString& name);
+    virtual void showMatrixDialog(const QString& name = QString::null);
 
-    virtual void showImageDialog(const QString& name);
+    virtual void showImageDialog(const QString& name = QString::null);
 
-    virtual void showCurveDialog(const QString& name);
+    virtual void showCurveDialog(const QString& name = QString::null);
 
     virtual void newVectorDialog(QWidget *parent, const char *createdSlot = 0L, const char *selectedSlot = 0L, const char *updateSlot = 0L);
-    virtual void showVectorDialog(const QString& name);
+    virtual void showVectorDialog(const QString& name = QString::null);
 };
 
 #endif
--- branches/work/kst/pluginify/kst/src/libkstmath/kstbasecurve.h #583902:583903
@@ -53,7 +53,8 @@
     KstBaseCurve(const QDomElement& e);
     virtual ~KstBaseCurve();
 
-    virtual void _showDialog() { }
+    virtual void showNewDialog() { }
+    virtual void showEditDialog() { }
     virtual void save(QTextStream &ts, const QString& indent = QString::null) = 0;
     virtual QString propertyString() const = 0;
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstcsd.cpp #583902:583903
@@ -269,7 +269,12 @@
 }
 
 
-void KstCSD::_showDialog() {
+void KstCSD::showNewDialog() {
+  KstDialogs::self()->showCSDDialog();
+}
+
+
+void KstCSD::showEditDialog() {
   KstDialogs::self()->showCSDDialog(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstcsd.h #583902:583903
@@ -45,7 +45,8 @@
 
     virtual bool slaveVectorsUsed() const;
 
-    virtual void _showDialog();
+    virtual void showNewDialog();
+    virtual void showEditDialog();
 
     bool apodize() const;
     void setApodize(bool in_apodize);
--- branches/work/kst/pluginify/kst/src/libkstmath/kstdataobject.cpp #583902:583903
@@ -271,8 +271,11 @@
 }
 
 
-void KstDataObject::showDialog() {
-  QTimer::singleShot(0, this, SLOT(_showDialog()));
+void KstDataObject::showDialog( bool edit ) {
+  if (!edit)
+    QTimer::singleShot(0, this, SLOT(showNewDialog()));
+  else
+    QTimer::singleShot(0, this, SLOT(showEditDialog()));
 }
 
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstdataobject.h #583902:583903
@@ -79,7 +79,7 @@
     virtual void load(const QDomElement &e);
     virtual void save(QTextStream& ts, const QString& indent = QString::null);
 
-    void showDialog();
+    void showDialog( bool edit = false );
 
     virtual bool loadInputs();
 
@@ -106,7 +106,8 @@
     virtual bool uses(KstObjectPtr p) const;
 
   protected slots:
-    virtual void _showDialog() = 0;
+    virtual void showNewDialog() = 0;
+    virtual void showEditDialog() = 0;
 
   protected:
     
--- branches/work/kst/pluginify/kst/src/libkstmath/kstequation.cpp #583902:583903
@@ -467,7 +467,12 @@
 }
 
 
-void KstEquation::_showDialog() {
+void KstEquation::showNewDialog() {
+  KstDialogs::self()->showEquationDialog();
+}
+
+
+void KstEquation::showEditDialog() {
   KstDialogs::self()->showEquationDialog(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstequation.h #583902:583903
@@ -57,7 +57,8 @@
 
     virtual void setTagName(const QString& tag);
 
-    virtual void _showDialog();
+    virtual void showNewDialog();
+    virtual void showEditDialog();
 
     virtual QString xVTag() const { return (*_xOutVector)->tagName(); }
     virtual QString yVTag() const { return (*_yOutVector)->tagName(); }
--- branches/work/kst/pluginify/kst/src/libkstmath/ksthistogram.cpp #583902:583903
@@ -376,7 +376,12 @@
 }
 
 
-void KstHistogram::_showDialog() {
+void KstHistogram::showNewDialog() {
+  KstDialogs::self()->showHistogramDialog();
+}
+
+
+void KstHistogram::showEditDialog() {
   KstDialogs::self()->showHistogramDialog(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/libkstmath/ksthistogram.h #583902:583903
@@ -63,7 +63,8 @@
 
   static void AutoBin(const KstVectorPtr, int *n, double *max, double *min);
 
-  virtual void _showDialog();
+  virtual void showNewDialog();
+  virtual void showEditDialog();
 
   virtual bool slaveVectorsUsed() const;
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstimage.cpp #583902:583903
@@ -287,7 +287,12 @@
 }
 
 
-void KstImage::_showDialog() {
+void KstImage::showNewDialog() {
+  KstDialogs::self()->showImageDialog();
+}
+
+
+void KstImage::showEditDialog() {
   KstDialogs::self()->showImageDialog(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstimage.h #583902:583903
@@ -47,11 +47,12 @@
     KstImage(const QDomElement& e);
     virtual ~KstImage();
 
-    virtual void _showDialog();
+    virtual void showNewDialog();
+    virtual void showEditDialog();
     virtual void save(QTextStream &ts, const QString& indent = QString::null);
     virtual UpdateType update(int update_counter = -1);
     virtual QString propertyString() const;
-    
+
     virtual KstCurveType curveType() const;
 
     virtual bool getNearestZ(double x, double y, double& z);
--- branches/work/kst/pluginify/kst/src/libkstmath/kstplugin.cpp #583902:583903
@@ -598,7 +598,12 @@
 }
 
 
-void KstPlugin::_showDialog() {
+void KstPlugin::showNewDialog() {
+  KstDialogs::self()->showPluginDialog();
+}
+
+
+void KstPlugin::showEditDialog() {
   KstDialogs::self()->showPluginDialog(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstplugin.h #583902:583903
@@ -58,7 +58,8 @@
 
   protected:
     static void countScalarsAndVectors(const QValueList<Plugin::Data::IOValue>& table, unsigned& scalars, unsigned& vectors);
-    virtual void _showDialog();
+    virtual void showNewDialog();
+    virtual void showEditDialog();
     KstSharedPtr<Plugin> _plugin;
     unsigned _inScalarCnt, _inArrayCnt, _inStringCnt, _outScalarCnt;
     unsigned _inPid, _outArrayCnt, _outStringCnt;
--- branches/work/kst/pluginify/kst/src/libkstmath/kstpsd.cpp #583902:583903
@@ -387,7 +387,12 @@
 }
 
 
-void KstPSD::_showDialog() {
+void KstPSD::showNewDialog() {
+  KstDialogs::self()->showPSDDialog();
+}
+
+
+void KstPSD::showEditDialog() {
   KstDialogs::self()->showPSDDialog(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstpsd.h #583902:583903
@@ -78,7 +78,8 @@
 
     virtual bool slaveVectorsUsed() const;
 
-    virtual void _showDialog();
+    virtual void showNewDialog();
+    virtual void showEditDialog();
 
     virtual QString xVTag() const { return (*_fVector)->tagName(); }
     virtual QString yVTag() const { return (*_sVector)->tagName(); }
--- branches/work/kst/pluginify/kst/src/libkstmath/kstvcurve.cpp #583902:583903
@@ -587,7 +587,12 @@
 }
 
 
-void KstVCurve::_showDialog() {
+void KstVCurve::showNewDialog() {
+  KstDialogs::self()->showCurveDialog();
+}
+
+
+void KstVCurve::showEditDialog() {
   KstDialogs::self()->showCurveDialog(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/libkstmath/kstvcurve.h #583902:583903
@@ -89,7 +89,8 @@
 
     virtual int samplesPerFrame() const;
 
-    virtual void _showDialog();
+    virtual void showNewDialog();
+    virtual void showEditDialog();
 
     KstVectorPtr xVector() const;
     KstVectorPtr yVector() const;
--- branches/work/kst/pluginify/kst/src/plugins/crossspectrum/crosspowerspectrum.cpp #583902:583903
@@ -45,9 +45,14 @@
   return 0;
 }
 
-void CrossPowerSpectrum::_showDialog()
+void CrossPowerSpectrum::showNewDialog()
 {
   KMessageBox::information( 0, "insert testplugin config widget here :)", "testpluginconfig" );
 }
 
+void CrossPowerSpectrum::showEditDialog()
+{
+  KMessageBox::information( 0, "insert testplugin config widget here :)", "testpluginconfig" );
+}
+
 #include "crosspowerspectrum.moc"
--- branches/work/kst/pluginify/kst/src/plugins/crossspectrum/crosspowerspectrum.h #583902:583903
@@ -31,7 +31,8 @@
     virtual KstDataObjectPtr makeDuplicate(KstDataObjectDataObjectMap&);
 
 protected slots:
-  virtual void _showDialog();
+  virtual void showNewDialog();
+  virtual void showEditDialog();
 };
 
 #endif
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitplugin.cpp #583902:583903
@@ -286,8 +286,13 @@
   return 0;
 }
 
-void LineFit::_showDialog() {
+void LineFit::showNewDialog() {
   LineFitDialogI *dialog = new LineFitDialogI;
+  dialog->show();
+}
+
+void LineFit::showEditDialog() {
+  LineFitDialogI *dialog = new LineFitDialogI;
   dialog->showEdit(tagName());
 }
 
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitplugin.h #583902:583903
@@ -89,7 +89,8 @@
 
 protected slots:
   //Pure virtual slots from KstDataObject
-  virtual void _showDialog();
+  virtual void showNewDialog();
+  virtual void showEditDialog();
 
 private:
   bool m_init;
--- branches/work/kst/pluginify/kst/src/plugins/testplugin/testplugin.h #583902:583903
@@ -42,10 +42,14 @@
     }
 
 protected slots:
-    virtual void _showDialog()
+    virtual void showNewDialog()
     {
         KMessageBox::information( 0, "insert testplugin config widget here :)", "testpluginconfig" );
     }
+    virtual void showEditDialog()
+    {
+      KMessageBox::information( 0, "insert testplugin config widget here :)", "testpluginconfig" );
+    }
 };
 
 #endif


More information about the Kst mailing list