[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Sat May 8 00:23:20 CEST 2004


CVS commit by staikos: 

plot layout fixes, and generate new plots using the template method in
KstTopLevelView


  M +1 -0      Makefile.am   1.101
  M +3 -6      datawizard.ui.h   1.21
  M +10 -0     ksttoplevelview.cpp   1.41
  M +16 -7     ksttoplevelview.h   1.24


--- kdeextragear-2/kst/kst/Makefile.am  #1.100:1.101
@@ -193,4 +193,5 @@
 filterlisteditor.o: filterlisteditor.ui.h filterlisteditor.ui
 kstsettingsdlg.o: kstsettingsdlg.ui.h kstsettingsdlg.ui
+datawizard.o: datawizard.ui.h datawizard.ui
 
 

--- kdeextragear-2/kst/kst/datawizard.ui.h  #1.20:1.21
@@ -354,20 +354,18 @@ void DataWizard::finished()
   // Generate the plots
   if (_onePlot->isChecked()) {
-    Kst2DPlotPtr p = new Kst2DPlot(KST::suggestPlotName());
+    Kst2DPlotPtr p = w->view()->createPlot<Kst2DPlot>(KST::suggestPlotName());
     if (_legends->isChecked()) {
       p->Legend->setShow(true);
       p->Legend->setFront(true);
     }
-    w->view()->appendChild(p.data());
     plots.append(p.data());
   } else if (_multiplePlots->isChecked()) {
     Kst2DPlotPtr p;
     for (uint i = 0; i < l.count(); ++i) {
-      p = new Kst2DPlot(KST::suggestPlotName());
+      p = w->view()->createPlot<Kst2DPlot>(KST::suggestPlotName());
       if (_legends->isChecked()) {
         p->Legend->setShow(true);
         p->Legend->setFront(true);
       }
-      w->view()->appendChild(p.data());
       plots.append(p.data());
     }
@@ -381,10 +379,9 @@ void DataWizard::finished()
     Kst2DPlotPtr p;
     for (int i = 0; i < _plotNumber->value(); ++i) {
-      p = new Kst2DPlot(KST::suggestPlotName());
+      p = w->view()->createPlot<Kst2DPlot>(KST::suggestPlotName());
       if (_legends->isChecked()) {
         p->Legend->setShow(true);
         p->Legend->setFront(true);
       }
-      w->view()->appendChild(p.data());
       plots.append(p.data());
     }

--- kdeextragear-2/kst/kst/ksttoplevelview.cpp  #1.40:1.41
@@ -29,4 +29,5 @@
 KstTopLevelView::KstTopLevelView(QWidget *parent, const char *name, WFlags w)
 : KstViewObject("KstTopLevelView"), _w(new KstViewWidget(this, parent, name, w)) {
+  _onGrid = true;
   _focusOn = false;
   setViewMode(_mode = DisplayMode);
@@ -38,4 +39,5 @@ KstTopLevelView::KstTopLevelView(QWidget
 
 KstTopLevelView::KstTopLevelView(QDomElement& e, QWidget *parent, const char *name, WFlags w) : KstViewObject(e), _w(new KstViewWidget(this, parent, name, w)) {
+  _onGrid = true;
   _focusOn = false;
   setViewMode(_mode = DisplayMode);
@@ -527,8 +529,10 @@ void KstTopLevelView::releasePress(const
         }
       }
+      _onGrid = false;
     } else {
       QRect r = newSize(_pressTarget->geometry(), _pressDirection, pos).intersect(_geom);
       _pressTarget->move(r.topLeft());
       _pressTarget->resize(r.size());
+      _onGrid = false;
     }
     _pressTarget->setFocus(true);
@@ -757,4 +761,10 @@ void KstTopLevelView::cancelMouseOperati
 }
 
+
+void KstTopLevelView::cleanup(int cols) {
+  KstViewObject::cleanup();
+  _onGrid = true;
+}
+
 #include "ksttoplevelview.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/ksttoplevelview.h  #1.23:1.24
@@ -57,5 +57,7 @@ class KstTopLevelView : public KstViewOb
     KstViewObjectPtr pressTarget() const { return _pressTarget; }
 
-    template<class T> KstPlotBasePtr createPlot(const QString& name);
+    template<class T> KstSharedPtr<T> createPlot(const QString& name);
+
+    virtual void cleanup(int cols = -1);
 
   private slots:
@@ -92,4 +94,5 @@ class KstTopLevelView : public KstViewOb
     ViewMode _mode : 4;
     signed int _pressDirection : 5;
+    bool _onGrid;
     QCursor _cursor;
     QPoint _moveOffset;
@@ -103,12 +106,18 @@ typedef KstObjectList<KstTopLevelViewPtr
 
 template<class T>
-KstPlotBasePtr KstTopLevelView::createPlot(const QString& name) {
+KstSharedPtr<T> KstTopLevelView::createPlot(const QString& name) {
   T *plot = new T(name);
+  if (_onGrid) {
+    // FIXME: make this more powerful, preserve columns
+    appendChild(plot);
+    cleanup();
+  } else {
   // FIXME: run the positioning algorithm
   plot->resize(QSize(250, 100));
   plot->move(QPoint(30, 30));
   appendChild(plot);
+  }
   paint();
-  return KstPlotBasePtr(plot);
+  return plot;
 }
 





More information about the Kst mailing list