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

Eli Fidler eli at staikos.net
Tue Mar 6 21:18:37 CET 2007


SVN commit 640094 by fidler:

fixed string editing and creation

this should fix the remaining issues in bug 120772


 M  +35 -46    stringselector.ui.h  


--- trunk/extragear/graphics/kst/src/widgets/stringselector.ui.h #640093:640094
@@ -16,7 +16,6 @@
     connect(_newString, SIGNAL(clicked()), this, SLOT(createNewString()));
     connect(_editString, SIGNAL(clicked()), this, SLOT(editString()));
     connect(_string, SIGNAL(activated(const QString&)), this, SIGNAL(selectionChanged(const QString&)));
-    connect(_string, SIGNAL(textChanged(const QString&)), this, SIGNAL(selectionChanged(const QString&)));
     connect(this, SIGNAL(selectionChanged(const QString&)), this, SLOT(selectionWatcher(const QString&)));
 }
 
@@ -56,8 +55,14 @@
     qHeapSort(strings);
     _string->insertStringList(strings);
     if (found) {
-        _string->setCurrentText(prev);
+		if (_string->currentText() != prev) {
+			_string->setCurrentText(prev);
+		}
     }
+
+	if (!_string->currentText().isNull()) {
+		selectionWatcher(_string->currentText());
+	}
     
     blockSignals(false);
 }
@@ -66,30 +71,19 @@
 {
     StringEditor *se = new StringEditor(this, "string editor");
     
-    int rc = se->exec();
-    if (rc == QDialog::Accepted) {
-        bool ok = false;
-        double val = se->_value->text().toFloat(&ok);
-        
- 	if (!ok) {
-	    val = Equation::interpret(se->_value->text().latin1(), &ok);
+	int rc = se->exec();
+	if (rc == QDialog::Accepted) {
+		KstStringPtr s = new KstString(KstObjectTag(se->_name->text(), KstObjectTag::globalTagContext), 0L, se->_value->text());
+
+		s->setOrphan(true);
+		s->setEditable(true);
+		emit newStringCreated();
+		update();
+		setSelection(s);
+		_editString->setEnabled(true);
 	}
 
-        if (ok) {
-            KstStringPtr s = new KstString(KstObjectTag(se->_name->text(), KstObjectTag::globalTagContext), 0L);
-            
-            s->setOrphan(true);
-            s->setEditable(true);
-            emit newStringCreated();
-            update();
-            setSelection(s);
-            _editString->setEnabled(true);
-        } else {
-            KMessageBox::sorry(this, tr("Error saving your new string."), tr("Kst"));
-        }
-    }
-    
-    delete se;
+	delete se;
 }
 
 void StringSelector::selectString()
@@ -103,7 +97,7 @@
     }
     selection->sort();
     int rc = selection->exec();
-    if (rc == QDialog::Accepted) {        
+    if (rc == QDialog::Accepted && _string->currentText() != selection->selected()) {        
         _string->setCurrentText(selection->selected());   
     }
     
@@ -124,28 +118,23 @@
     
     int rc = se->exec();
     if (rc == QDialog::Accepted) {
-        bool ok = false;
-        QString val = se->_value->text();
+		QString val = se->_value->text();
 
-        if (ok) {
-            KstStringPtr p = *KST::stringList.findTag(se->_name->text());
-            if (p) {
-                p->setValue(val);
-                setSelection(p);
-            } else {
-                p = new KstString(KstObjectTag(se->_name->text(), KstObjectTag::globalTagContext), 0L, val);
+		KstStringPtr p = *KST::stringList.findTag(se->_name->text());
+		if (p) {
+			p->setValue(val);
+			setSelection(p);
+		} else {
+			p = new KstString(KstObjectTag(se->_name->text(), KstObjectTag::globalTagContext), 0L, val);
 
-                p->setOrphan(true);
-                p->setEditable(true);
-                emit newStringCreated();
-                update();
-                setSelection(p);
-                _editString->setEnabled(true);
-            }
-        } else {
-            KMessageBox::sorry(this, tr("Error saving your new string."), tr("Kst"));
-        }
-    }
+			p->setOrphan(true);
+			p->setEditable(true);
+			emit newStringCreated();
+			update();
+			setSelection(p);
+			_editString->setEnabled(true);
+		}
+	}
     
     delete se;
 }
@@ -167,7 +156,7 @@
 
 void StringSelector::setSelection( const QString & tag )
 {
-    if (tag.isEmpty()) {
+    if (tag.isEmpty() || _string->currentText() == tag) {
         return;
     }
     blockSignals(true);


More information about the Kst mailing list