IntervalItem::name removed

The class member IntervalItem::name is redundant since it is a duplicate
of the text() member of the base class QTreeWidgetItem. By removing it
we both simplify the code and remove the need to keep name and text in
sync when renaming and creating intervals.

As a result the itemChanged signal that was connected for renames and
then disconnected when the items are cleared can be connected once
and no disconnect is neccessary.

This connect/disconnect oddity was originally to avoid a SEGV that
resulted from accessing text() whilst the QTreeWidgetItem was being
destroyed. The code for removing intervals when a new ride is selected
no longer destroys and recreats MainWindow::allIntervals (which was also an
artefact of the original code to avoid a SEGV).
This commit is contained in:
Mark Liversedge
2009-12-13 17:38:24 +00:00
committed by Sean Rhea
parent 0dc9f6a4c0
commit bfc0d1575a
5 changed files with 17 additions and 43 deletions

View File

@@ -399,7 +399,7 @@ AllPlotWindow::setEndSelection(double xValue, bool newInterval, QString name)
// are we adjusting an existing interval? - if so delete it and readd it
if (count > 0) {
IntervalItem *bottom = (IntervalItem *) allIntervals->child(count-1);
if (bottom->name == name) delete allIntervals->takeChild(count-1);
if (bottom->text(0) == name) delete allIntervals->takeChild(count-1);
}
QTreeWidgetItem *last = new IntervalItem(ride->ride, name, duration1, duration2, distance1, distance2);