Version: 1.2.1 (using KDE KDE 3.5.0) Installed from: Compiled From Sources OS: Linux PROBLEM: The user can create a meaningless empty entry in the Selected listbox of the Differentiate Curves dialog. STEPS TO REPRODUCE: Start Kst Select the Tools... Differentiate Between Curves menu entry Hit the down arrow RESULTS: An empty entry in the Selected list box is created EXPECTED RESULTS: The down arrow is disabled until an appropriate entry is selected
SVN commit 551110 by arwalker: BUG:129101 Do not assume a listbox has a selected entry. Do not equate the current item with being selected. M +33 -13 kstcurvedifferentiate_i.cpp --- trunk/extragear/graphics/kst/src/libkstapp/kstcurvedifferentiate_i.cpp #551109:551110 @@ -81,6 +81,7 @@ } + void KstCurveDifferentiateI::updateCurveDifferentiate() { updateButtons(); } @@ -92,11 +93,25 @@ raise(); } + void KstCurveDifferentiateI::updateButtons() { - _remove->setEnabled(selectedListBox->currentItem() >= 0); - _add->setEnabled(availableListBox->currentItem() >= 0); + int i = selectedListBox->currentItem(); + if (i >= 0 && selectedListBox->isSelected(i)) { + _remove->setEnabled(true); + } else { + _remove->setEnabled(false); + } + + i = availableListBox->currentItem(); + if (i >= 0 && availableListBox->isSelected(i)) { + _add->setEnabled(true); + } else { + _add->setEnabled(false); + } + _up->setEnabled(selectedListBox->currentItem() > 0); - _down->setEnabled(selectedListBox->currentItem() < (int)selectedListBox->count() - 1); + _down->setEnabled(selectedListBox->currentItem() >= 0 && + selectedListBox->currentItem() < (int)selectedListBox->count() - 1); } @@ -170,6 +185,7 @@ } } + void KstCurveDifferentiateI::getOptions( ) { _lineColorOrder = selectedListBox->index(selectedListBox->findItem(i18n("Line Color"), ExactMatch)); _pointStyleOrder = selectedListBox->index(selectedListBox->findItem(i18n("Point Style"), ExactMatch)); @@ -213,22 +229,26 @@ void KstCurveDifferentiateI::upButtonClicked() { // move item up int i = selectedListBox->currentItem(); - QString text = selectedListBox->currentText(); - selectedListBox->removeItem(i); - selectedListBox->insertItem(text, i-1); - selectedListBox->setSelected(i-1, true); - updateButtons(); + if (i != -1) { + QString text = selectedListBox->currentText(); + selectedListBox->removeItem(i); + selectedListBox->insertItem(text, i-1); + selectedListBox->setSelected(i-1, true); + updateButtons(); + } } void KstCurveDifferentiateI::downButtonClicked() { // move item down int i = selectedListBox->currentItem(); - QString text = selectedListBox->currentText(); - selectedListBox->removeItem(i); - selectedListBox->insertItem(text, i+1); - selectedListBox->setSelected(i+1, true); - updateButtons(); + if (i != -1) { + QString text = selectedListBox->currentText(); + selectedListBox->removeItem(i); + selectedListBox->insertItem(text, i+1); + selectedListBox->setSelected(i+1, true); + updateButtons(); + } }