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

Adam Treat treat at kde.org
Mon Sep 24 22:23:29 CEST 2007


SVN commit 716516 by treat:

* Flesh out Kst::DataDialog and provide more hooks
in Kst::Dialog to customize in subclasses.
* Kst::DataDialog is now an abstract class. Real data
dialogs can subclass this and implement the interface.


 M  +37 -6     datadialog.cpp  
 M  +19 -0     datadialog.h  
 M  +5 -0      dialog.cpp  
 M  +1 -0      dialog.h  
 M  +21 -1     vectordialog.cpp  
 M  +5 -0      vectordialog.h  
 M  +3 -12     vectortab.ui  


--- branches/work/kst/portto4/kst/src/libkstapp/datadialog.cpp #716515:716516
@@ -14,15 +14,38 @@
 #include "dialogtab.h"
 #include "dialogpage.h"
 
+#include "kstdataobject.h"
+
 #include <QLabel>
 #include <QLineEdit>
 #include <QHBoxLayout>
+#include <QPushButton>
+#include <QDialogButtonBox>
 
 namespace Kst {
 
 DataDialog::DataDialog(QWidget *parent)
-  : Dialog(parent) {
+  : Dialog(parent), _dataObject(0) {
 
+  createGui();
+}
+
+DataDialog::DataDialog(KstObjectPtr dataObject, QWidget *parent)
+  : Dialog(parent), _dataObject(dataObject) {
+
+  createGui();
+}
+
+
+DataDialog::~DataDialog() {
+}
+
+void DataDialog::createGui() {
+
+  buttonBox()->button(QDialogButtonBox::Apply)->setVisible(false);
+
+  connect(this, SIGNAL(ok()), this, SLOT(slotOk()));
+
   QWidget *box = topCustomWidget();
 
   QHBoxLayout *layout = new QHBoxLayout(box);
@@ -30,17 +53,16 @@
 
   QLabel *name = new QLabel(tr("Unique Name:"), box);
   QLineEdit *edit = new QLineEdit(box);
+
+  if (_dataObject)
+    edit->setText(_dataObject->tagName());
+
   layout->addWidget(name);
   layout->addWidget(edit);
 
   box->setLayout(layout);
-
 }
 
-
-DataDialog::~DataDialog() {
-}
-
 void DataDialog::addDataTab(DialogTab *tab) {
   DialogPage *page = new DialogPage(this);
   page->setPageTitle(tab->tabTitle());
@@ -48,6 +70,15 @@
   addDialogPage(page);
 }
 
+void DataDialog::slotOk() {
+  KstObjectPtr ptr;
+  if (!dataObject())
+    ptr = createNewDataObject();
+  else
+    ptr = editExistingDataObject();
+  setDataObject(ptr);
 }
 
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/datadialog.h #716515:716516
@@ -16,6 +16,8 @@
 
 #include "kst_export.h"
 
+#include "kstdataobject.h"
+
 namespace Kst {
 
 class DialogTab;
@@ -24,9 +26,26 @@
   Q_OBJECT
   public:
     DataDialog(QWidget *parent = 0);
+    DataDialog(KstObjectPtr dataObject, QWidget *parent = 0);
     virtual ~DataDialog();
 
     void addDataTab(DialogTab *tab);
+
+  protected:
+    KstObjectPtr dataObject() const { return _dataObject; }
+    void setDataObject(KstObjectPtr dataObject) { _dataObject = dataObject; }
+
+    virtual KstObjectPtr createNewDataObject() const = 0;
+    virtual KstObjectPtr editExistingDataObject() const = 0;
+
+  private Q_SLOTS:
+    void slotOk();
+
+  private:
+    void createGui();
+
+  private:
+    KstObjectPtr _dataObject;
 };
 
 }
--- branches/work/kst/portto4/kst/src/libkstapp/dialog.cpp #716515:716516
@@ -76,6 +76,11 @@
   return _bottomCustom;
 }
 
+
+QDialogButtonBox *Dialog::buttonBox() const {
+ return _buttonBox;
+}
+
 void Dialog::selectPageForItem(QListWidgetItem *item) {
   if (_itemHash.contains(item))
     _stackedWidget->setCurrentWidget(_itemHash.value(item));
--- branches/work/kst/portto4/kst/src/libkstapp/dialog.h #716515:716516
@@ -46,6 +46,7 @@
     QWidget *rightCustomWidget() const;
     QWidget *topCustomWidget() const;
     QWidget *bottomCustomWidget() const;
+    QDialogButtonBox *buttonBox() const;
 
   private Q_SLOTS:
     void selectPageForItem(QListWidgetItem *item);
--- branches/work/kst/portto4/kst/src/libkstapp/vectordialog.cpp #716515:716516
@@ -33,14 +33,34 @@
   setWindowTitle(tr("New Vector"));
 
   _vectorTab = new VectorTab(this);
-//  connect(_vectorTab, SIGNAL(apply()), this, SLOT(vectorChanged()));
   addDataTab(_vectorTab);
 }
 
 
+VectorDialog::VectorDialog(KstObjectPtr dataObject, QWidget *parent)
+  : DataDialog(dataObject, parent) {
+
+  setWindowTitle(tr("Edit Vector"));
+
+  _vectorTab = new VectorTab(this);
+  addDataTab(_vectorTab);
+}
+
+
 VectorDialog::~VectorDialog() {
 }
 
+KstObjectPtr VectorDialog::createNewDataObject() const {
+  qDebug() << "createNewDataObject" << endl;
+  return 0;
 }
 
+
+KstObjectPtr VectorDialog::editExistingDataObject() const {
+  qDebug() << "editExistingDataObject" << endl;
+  return 0;
+}
+
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/vectordialog.h #716515:716516
@@ -32,8 +32,13 @@
   Q_OBJECT
   public:
     VectorDialog(QWidget *parent = 0);
+    VectorDialog(KstObjectPtr dataObject, QWidget *parent = 0);
     virtual ~VectorDialog();
 
+  protected:
+    virtual KstObjectPtr createNewDataObject() const;
+    virtual KstObjectPtr editExistingDataObject() const;
+
   private:
     VectorTab *_vectorTab;
 };
--- branches/work/kst/portto4/kst/src/libkstapp/vectortab.ui #716515:716516
@@ -121,7 +121,7 @@
        </widget>
       </item>
       <item row="0" column="1" >
-       <widget class="Kst::FileRequester" name="FileName" />
+       <widget class="Kst::FileRequester" name="_fileName" />
       </item>
       <item row="0" column="0" >
        <widget class="QLabel" name="label_4" >
@@ -137,7 +137,7 @@
        </widget>
       </item>
       <item row="1" column="1" >
-       <widget class="Kst::ComboBox" name="Field" />
+       <widget class="Kst::ComboBox" name="_field" />
       </item>
       <item row="2" column="0" colspan="2" >
        <layout class="QHBoxLayout" >
@@ -229,9 +229,6 @@
         <property name="wordWrap" >
          <bool>false</bool>
         </property>
-        <property name="buddy" >
-         <cstring>_N</cstring>
-        </property>
        </widget>
       </item>
       <item row="1" column="0" colspan="2" >
@@ -265,9 +262,6 @@
           <property name="wordWrap" >
            <bool>false</bool>
           </property>
-          <property name="buddy" >
-           <cstring>_xMin</cstring>
-          </property>
          </widget>
         </item>
         <item>
@@ -294,9 +288,6 @@
           <property name="wordWrap" >
            <bool>false</bool>
           </property>
-          <property name="buddy" >
-           <cstring>_xMax</cstring>
-          </property>
          </widget>
         </item>
         <item>
@@ -312,7 +303,7 @@
        </layout>
       </item>
       <item row="0" column="1" >
-       <widget class="QSpinBox" name="_N" >
+       <widget class="QSpinBox" name="_numberOfSamples" >
         <property name="sizePolicy" >
          <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
           <horstretch>0</horstretch>


More information about the Kst mailing list