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

Andrew Walker arwalker at sumusltd.com
Wed Dec 5 21:41:29 CET 2007


SVN commit 745254 by arwalker:

153152 Enhance the change data sample ranges dialog

 M  +51 -19    libkstapp/kstchangenptsdialog_i.cpp  
 M  +5 -2      libkstapp/kstchangenptsdialog_i.h  
 M  +4 -0      widgets/datarangewidget.ui  
 M  +15 -1     widgets/datarangewidget.ui.h  


--- branches/work/kst/1.6/kst/src/libkstapp/kstchangenptsdialog_i.cpp #745253:745254
@@ -29,21 +29,17 @@
 #include "kstdatacollection.h"
 #include "kstrvector.h"
 
-KstChangeNptsDialogI::KstChangeNptsDialogI(QWidget* parent,
-                                           const char* name,
-                                           bool modal,
-                                           WFlags fl)
+KstChangeNptsDialogI::KstChangeNptsDialogI(
+  QWidget* parent, const char* name, bool modal, WFlags fl)
 : KstChangeNptsDialog(parent, name, modal, fl) {
-    connect(Clear,     SIGNAL(clicked()),
-            CurveList, SLOT(clearSelection()));
-    connect(SelectAll, SIGNAL(clicked()),
-            this,      SLOT(selectAll()));
-    connect(Apply,     SIGNAL(clicked()),
-            this,      SLOT(applyNptsChange()));
-    connect(OK,        SIGNAL(clicked()),
-            this,      SLOT(OKNptsChange()));
-    connect(CurveList, SIGNAL(selected ( int )),
-            this,      SLOT(updateDefaults( int )));
+  connect(Clear, SIGNAL(clicked()), CurveList, SLOT(clearSelection()));
+  connect(SelectAll, SIGNAL(clicked()), this, SLOT(selectAll()));
+  connect(Apply, SIGNAL(clicked()), this, SLOT(applyNptsChange()));
+  connect(OK, SIGNAL(clicked()), this, SLOT(OKNptsChange()));
+  connect(CurveList, SIGNAL(selectionChanged()), this, SLOT(changedSelection()));
+  connect(_kstDataRange, SIGNAL(changed()), this, SLOT(modifiedRange()));
+
+  _modifiedRange = false;
 }
 
 
@@ -59,14 +55,14 @@
 bool KstChangeNptsDialogI::updateChangeNptsDialog() {
   QStringList qsl;
   int inserted = 0;
-  
+
   for (uint i_vector = 0; i_vector < CurveList->count(); i_vector++) {
     if (CurveList->isSelected(i_vector)) {
       qsl.append(CurveList->text(i_vector));
     }
   }
   CurveList->clear();
-  
+
   KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
   // insert vectors into ChangeNptsCurveList
   CurveList->blockSignals(true); // avoid deadlock
@@ -82,25 +78,29 @@
     vector->unlock();
   }
   CurveList->blockSignals(false);
+
   return !qsl.isEmpty();
 }
 
 
 void KstChangeNptsDialogI::showChangeNptsDialog() {
-  bool some_slected = updateChangeNptsDialog();
+  bool selected = updateChangeNptsDialog();
   updateDefaults(0);
-  if (!some_slected) {
+  _modifiedRange = false;
+  if (!selected) {
     CurveList->selectAll(true);
   }
   show();
   raise();
 }
 
+
 void KstChangeNptsDialogI::OKNptsChange() {
   applyNptsChange();
   reject();
 }
 
+
 void KstChangeNptsDialogI::applyNptsChange() {
   KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
   for (uint i = 0; i < CurveList->count(); ++i) {
@@ -152,6 +152,8 @@
     }
   }
 
+  _modifiedRange = false;
+
   // avoid re-entering the dialog
   QTimer::singleShot(0, this, SLOT(emitDocChanged()));
 }
@@ -171,6 +173,8 @@
   KstRVectorPtr vector = rvl[index];
   vector->readLock();
 
+  disconnect(_kstDataRange, SIGNAL(changed()), this, SLOT(modifiedRange()));
+
   _kstDataRange->_startUnits->setCurrentItem(0);
   _kstDataRange->_rangeUnits->setCurrentItem(0);
 
@@ -188,10 +192,35 @@
   _kstDataRange->DoFilter->setChecked(vector->doAve());
   _kstDataRange->updateEnables();
 
+  connect(_kstDataRange, SIGNAL(changed()), this, SLOT(modifiedRange()));
+
   vector->unlock();
 }
 
 
+void KstChangeNptsDialogI::changedSelection() {
+  int index = -1;
+  unsigned int i;
+
+  if (!_modifiedRange) {
+    for (i=0; i<CurveList->count(); ++i) {
+      if (CurveList->isSelected(i)) {
+        if (index == -1) {
+          index = i;
+        } else {
+          index = -1;
+          break;
+        }
+      }
+    }
+
+    if (index != -1) {
+      updateDefaults(index);
+    }
+  }
+}
+
+
 void KstChangeNptsDialogI::updateTimeCombo() {
   KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
   uint cnt = CurveList->count();
@@ -218,5 +247,8 @@
 }
 
 
+void KstChangeNptsDialogI::modifiedRange() {
+  _modifiedRange = true;
+}
+
 #include "kstchangenptsdialog_i.moc"
-// vim: ts=2 sw=2 et
--- branches/work/kst/1.6/kst/src/libkstapp/kstchangenptsdialog_i.h #745253:745254
@@ -47,12 +47,15 @@
   void applyNptsChange();
   void OKNptsChange();
   void updateTimeCombo();
+  void modifiedRange();
+  void changedSelection();
 
 signals:
   /** signal that vectors have changed */
   void docChanged();
+
+private:
+  bool _modifiedRange;
 };
 
-
 #endif
-// vim: ts=2 sw=2 et
--- branches/work/kst/1.6/kst/src/widgets/datarangewidget.ui #745253:745254
@@ -300,7 +300,11 @@
 <variables>
     <variable access="private">bool _time;</variable>
 </variables>
+<signals>
+    <signal>changed()</signal>
+</signals>
 <slots>
+    <slot>modified()</slot>
     <slot>clickedCountFromEnd()</slot>
     <slot>ClickedReadToEnd()</slot>
     <slot>clickedDoSkip()</slot>
--- branches/work/kst/1.6/kst/src/widgets/datarangewidget.ui.h #745253:745254
@@ -10,10 +10,25 @@
 
 void KstDataRange::init()
 {
+    connect(F0, SIGNAL(textChanged(const QString&)), this, SLOT(modified()));
+    connect(N, SIGNAL(textChanged(const QString&)), this, SLOT(modified()));
+    connect(_startUnits, SIGNAL(activated(int)), this, SLOT(modified()));
+    connect(_rangeUnits, SIGNAL(activated(int)), this, SLOT(modified()));
+    connect(CountFromEnd, SIGNAL(clicked()), this, SLOT(modified()));
+    connect(ReadToEnd, SIGNAL(clicked()), this, SLOT(modified()));
+    connect(DoSkip, SIGNAL(clicked()), this, SLOT(modified()));
+    connect(DoFilter, SIGNAL(clicked()), this, SLOT(modified()));
+    connect(Skip, SIGNAL(valueChanged(int)), this, SLOT(modified()));
+
     _time = false;
     update();
 }
 
+void KstDataRange::modified()
+{
+    emit changed();
+}
+
 void KstDataRange::clickedCountFromEnd()
 {
     if (CountFromEnd->isChecked()) {
@@ -185,4 +200,3 @@
     return _rangeUnits->currentItem() > KST::dateTimeEntry;
 }
 
-// vim: ts=8 sw=4 noet


More information about the Kst mailing list