Bug 147217

Summary: Up/Down arrows in Plot Contents don't enable Apply button
Product: [Applications] kst Reporter: D. V. Wiebe <dvw>
Component: generalAssignee: kst
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description D. V. Wiebe 2007-06-25 21:39:26 UTC
Version:           1.4.1_svn_678561 (using KDE KDE 3.5.7)
Installed from:    Compiled From Sources
Compiler:          gcc (GCC) 4.1.2 
OS:                Linux

Moving plot objects up and down in the list of displayed objects in the Content tab of the Edit Plot dialog doesn't enable the Apply button, even though the rendered plot will change as a result of reordering the objects.

STEPS to REPRODUCE

1) Plot several objects in a single plot.
2) Right click -> Edit...
3) In the content tab, reorder the displayed objects using the up and down arrow buttons

RESULTS:

The "Apply" button, which was disabled when the Edit Plot dialog was opened, is still disabled, even though the appearance of the plot will change as a result of the re-ordering.

EXPECTED RESULTS:

The "Apply" button should be enabled when plot objects are re-ordered, so that the plot can be re-rendered without having to hit "OK".
Comment 1 Andrew Walker 2007-06-25 22:40:08 UTC
SVN commit 680290 by arwalker:

CCBUG:147217 Add functionality to draggablelistbox to report whether a move was actually made

 M  +21 -4     draggablelistbox.cpp  
 M  +3 -3      draggablelistbox.h  


--- branches/work/kst/1.5/kst/src/widgets/draggablelistbox.cpp #680289:680290
@@ -94,9 +94,12 @@
   }
 }
 
-void DraggableListBox::up() {
+bool DraggableListBox::up() {
+  bool bRetVal = false;
+
   if (count() > 1) {
     QString C;
+
     for (unsigned i=1; i<count(); i++) {
       if (isSelected(i)) {
         C = text(i);
@@ -104,13 +107,21 @@
         --i;
         insertItem(C, i);
         setSelected(i, true);
-        while (isSelected(i) && (i<count())) ++i;
+        while (isSelected(i) && (i < count())) {
+          ++i;
+        }
+
+        bRetVal = true;
       }
     }
   }
+
+  return bRetVal;
 }
 
-void DraggableListBox::down() {
+bool DraggableListBox::down() {
+  bool bRetVal = false;
+
   if (count() > 1) {
     QString C;
     for (int i=int(count())-2; i>=0; i--) {
@@ -120,10 +131,16 @@
         ++i;
         insertItem(C, i);
         setSelected(i, true);
-        while (isSelected(i) && (i>0)) --i;
+        while (isSelected(i) && (i > 0)) {
+          --i;
+        }
+
+        bRetVal = true;
       }
     }
   }
+
+  return bRetVal;
 }
 
 #include "draggablelistbox.moc"
--- branches/work/kst/1.5/kst/src/widgets/draggablelistbox.h #680289:680290
@@ -35,9 +35,9 @@
     virtual void setDragEnabled(bool enabled);
 
   public slots:
-    virtual void up();
-    virtual void down();
-    
+    virtual bool up();
+    virtual bool down();
+
   protected:
     virtual void startDrag();
     virtual void mousePressEvent(QMouseEvent *e);
Comment 2 Andrew Walker 2007-06-25 22:40:30 UTC
SVN commit 680291 by arwalker:

BUG:147217 Enable Apply button after moving curves up or down in the displayed objects list

 M  +2 -2      kst2dplot.cpp  
 M  +18 -3     kst2dplotwidget_i.cpp  
 M  +2 -0      kst2dplotwidget_i.h  
 M  +1 -1      labelrenderer.cpp  


--- branches/work/kst/1.5/kst/src/libkstapp/kst2dplot.cpp #680290:680291
@@ -1953,7 +1953,7 @@
   tp.labels.clear();
   tp.oppLabels.clear();
   tp.delta = false;
-  
+
   if (isLog && isInterpreted) {
     setTicks(tp.tick, tp.org, Max + log10(range) + log10(scale), Min + log10(range) + log10(scale), isLog, logBase, isX, base);
     tp.org -= log10(range) + log10(scale);
@@ -1962,7 +1962,7 @@
     tp.tick /= range*scale;
     tp.org  /= range*scale;
   }
-    
+
   tp.iLo = int((Min-tp.org)/tp.tick);
   tp.iHi = int((Max-tp.org)/tp.tick)+1;
   iShort = tp.iLo;
--- branches/work/kst/1.5/kst/src/libkstapp/kst2dplotwidget_i.cpp #680290:680291
@@ -94,8 +94,8 @@
   connect(AvailableCurveList, SIGNAL(selectionChanged()), this, SLOT(updateButtons()));
   connect(_remove, SIGNAL(clicked()), this, SLOT(removeDisplayedCurve()));
   connect(_add, SIGNAL(clicked()), this, SLOT(addDisplayedCurve()));
-  connect(_up, SIGNAL(clicked()), DisplayedCurveList, SLOT(up()));
-  connect(_down, SIGNAL(clicked()), DisplayedCurveList, SLOT(down()));
+  connect(_up, SIGNAL(clicked()), this, SLOT(upDisplayedCurve()));
+  connect(_down, SIGNAL(clicked()), this, SLOT(downDisplayedCurve()));
 
   connect(AutoLabel, SIGNAL(clicked()), this, SLOT(generateDefaultLabels()));
 
@@ -315,8 +315,8 @@
       if (DisplayedCurveList->isSelected(i)) {
         AvailableCurveList->insertItem(DisplayedCurveList->text(i));
         DisplayedCurveList->removeItem(i);
+      }
     }
-    }
     updateButtons();
     emit changed();
   }
@@ -324,7 +324,22 @@
 }
 
 
+void Kst2dPlotWidget::upDisplayedCurve()
+{
+  if (DisplayedCurveList->up()) {
+    emit changed();
+  }
+}
 
+
+void Kst2dPlotWidget::downDisplayedCurve()
+{
+  if (DisplayedCurveList->down()) {
+    emit changed();
+  }
+}
+
+
 void Kst2dPlotWidget::fillMarkerLineCombo() {
   QRect rect = _comboMarkerLineStyle->style().querySubControlMetrics(QStyle::CC_ComboBox, _comboMarkerLineStyle, QStyle::SC_ComboBoxEditField);
   rect.setLeft(rect.left() + 2);
--- branches/work/kst/1.5/kst/src/libkstapp/kst2dplotwidget_i.h #680290:680291
@@ -35,6 +35,8 @@
   public slots:
     void generateDefaultLabels();
     void updateButtons();
+    void upDisplayedCurve();
+    void downDisplayedCurve();
     void addDisplayedCurve();
     void removeDisplayedCurve();
     void fillMarkerLineCombo();
--- branches/work/kst/1.5/kst/src/libkstapp/labelrenderer.cpp #680290:680291
@@ -63,7 +63,7 @@
       // not an object reference
       continue;
     }
-    
+
 //    kstdWarning() << "Label references unknown object [" << fi->text << "]." << endl;
     return false;
   }