Fix plot importance changes if delete earlier plot and click other plots

The root cause was a mismatch between plot IDs and plot model rows.

This issue would appear when a plot was deleted such that the plot IDs
did not match the plot model row numbers and different plots had
different importance levels.  The problem would not occur if the most
recently added plot was deleted.

The plot ID / plot model row mismatch was introduced with the
following commit:

    Fixes: add plot then choose new plot does not set \
    importance slider
    3569f78928

Closes issue #404
This commit is contained in:
Curtis Gedak 2018-11-04 17:28:51 -07:00
parent 729489a77e
commit 026861ee87
2 changed files with 4 additions and 5 deletions

View file

@ -417,8 +417,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
PlotStep.meta, QHeaderView.ResizeToContents)
self.lstSubPlots.verticalHeader().hide()
def updatePlotImportance(self, ID):
imp = self.mdlPlots.getPlotImportanceByID(ID)
def updatePlotImportance(self, row):
imp = self.mdlPlots.getPlotImportanceByRow(row)
self.sldPlotImportance.setValue(int(imp))
def changeCurrentSubPlot(self, index):

View file

@ -68,10 +68,9 @@ class plotModel(QStandardItemModel):
return name
return None
def getPlotImportanceByID(self, ID):
def getPlotImportanceByRow(self, row):
for i in range(self.rowCount()):
_ID = self.item(i, Plot.ID).text()
if _ID == ID or toInt(_ID) == ID:
if i == row:
importance = self.item(i, Plot.importance).text()
return importance
return "0" # Default to "Minor"