[Kst] extragear/graphics/kst/src/libkstapp

Eli Fidler eli at staikos.net
Thu Mar 1 19:43:45 CET 2007


SVN commit 638372 by fidler:

enable editing scalars from "View Scalar Values" dialog


 M  +29 -0     kstscalarlistview.cpp  
 M  +3 -0      kstscalarlistview.h  
 M  +3 -2      kstviewscalarsdialog_i.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstscalarlistview.cpp #638371:638372
@@ -23,11 +23,26 @@
 #include "kstscalarlistview.h"
 
 KstScalarListViewItem::KstScalarListViewItem(KstScalarListView *parent, KstObjectTreeNode<KstScalar> *node) : KListViewItem(parent), _node(node) {
+  commonConstructor();
 }
 
 KstScalarListViewItem::KstScalarListViewItem(KstScalarListViewItem *parent, KstObjectTreeNode<KstScalar> *node) : KListViewItem(parent), _node(node) {
+  commonConstructor();
 }
 
+void KstScalarListViewItem::commonConstructor() {
+  if (_node) {
+    KstScalar *s = dynamic_cast<KstScalar*>(_node->object());
+    if (s && s->editable()) {
+      setRenameEnabled(0, false);
+      setRenameEnabled(1, true);
+    } else {
+      setRenameEnabled(0, false);
+      setRenameEnabled(1, false);
+    }
+  }
+}
+
 QString KstScalarListViewItem::text(int column) const {
   if (!_node) {
     return QString::null;
@@ -50,7 +65,21 @@
   }
 }
 
+void KstScalarListViewItem::setText(int column, const QString& text) {
+  if (column == 1 && _node) {
+    KstScalar *s = dynamic_cast<KstScalar*>(_node->object());
+    if (s && s->editable()) {
+      bool ok;
+      double val = text.toDouble(&ok);
+      if (ok) {
+        s->setValue(val);
+      }
+    }
+  }
+}
 
+/*----------------------------------------------------------------------------*/
+
 KstScalarListView::KstScalarListView(QWidget *parent, KstObjectCollection<KstScalar> *coll) : KListView(parent), _coll(coll) {
   addColumn(i18n("Scalar"));
   addColumn(i18n("Value"));
--- trunk/extragear/graphics/kst/src/libkstapp/kstscalarlistview.h #638371:638372
@@ -42,10 +42,13 @@
     KstScalarListViewItem(KstScalarListViewItem *parent, KstObjectTreeNode<KstScalar> *node);
 
     QString text(int column) const;
+    void setText(int column, const QString& text);
 
     KstObjectTreeNode<KstScalar> *node() const { return _node; }
 
   private:
+    void commonConstructor();
+
     KstObjectTreeNode<KstScalar> *_node;
 };
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewscalarsdialog_i.cpp #638371:638372
@@ -31,7 +31,6 @@
 : KstViewScalarsDialog(parent, name, modal, fl) {
   listViewScalars = new KstScalarListView(this, &KST::scalarList);
   listViewScalars->setShowSortIndicator(false);
-  listViewScalars->setSelectionMode(QListView::NoSelection);
   searchWidget = new KListViewSearchLineWidget(listViewScalars, this);
   QBoxLayout *box = dynamic_cast<QBoxLayout*>(layout());
   if (box) {
@@ -55,7 +54,9 @@
 
 void KstViewScalarsDialogI::updateViewScalarsDialog() {
   listViewScalars->update();
-  searchWidget->searchLine()->updateSearch();
+  if (searchWidget) {
+    searchWidget->searchLine()->updateSearch(); 
+  }
 
   // use whole width
   int c0Width = listViewScalars->columnWidth(0);


More information about the Kst mailing list