mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 16:39:57 +00:00
Add interval sort function
.. added to the splitter handle context menu .. also took IntervalItem.h and IntervalTreeView.h from MainWindow.h coz I was getting pissed with recompiling everything when changing it. Thats why so many other files have been changed in this commit. Fixes #338.
This commit is contained in:
@@ -1334,6 +1334,13 @@ MainWindow::intervalPopup()
|
||||
menu.addAction(actFindPeak);
|
||||
menu.addAction(actFindBest);
|
||||
|
||||
// sort but only if 2 or more intervals
|
||||
if (allIntervals->childCount() > 1) {
|
||||
QAction *actSort = new QAction(tr("Sort Intervals"), intervalItem);
|
||||
connect(actSort, SIGNAL(triggered(void)), this, SLOT(sortIntervals(void)));
|
||||
menu.addAction(actSort);
|
||||
}
|
||||
|
||||
if (intervalWidget->selectedItems().count()) menu.addSeparator();
|
||||
}
|
||||
|
||||
@@ -2358,6 +2365,36 @@ MainWindow::updateRideFileIntervals()
|
||||
which->setDirty(true);
|
||||
}
|
||||
|
||||
bool
|
||||
lessItem(const IntervalItem *s1, const IntervalItem *s2) {
|
||||
return s1->start < s2->start;
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::sortIntervals()
|
||||
{
|
||||
// sort them chronologically
|
||||
QList<IntervalItem*> intervals;
|
||||
|
||||
// set string to first interval selected
|
||||
for (int i=0; i<allIntervals->childCount();i++)
|
||||
intervals.append((IntervalItem*)(allIntervals->child(i)));
|
||||
|
||||
// now sort them into start time order
|
||||
qStableSort(intervals.begin(), intervals.end(), lessItem);
|
||||
|
||||
// empty allIntervals
|
||||
allIntervals->takeChildren();
|
||||
|
||||
// and put em back in chronological sequence
|
||||
foreach(IntervalItem* item, intervals) {
|
||||
allIntervals->addChild(item);
|
||||
}
|
||||
|
||||
// now update the ridefile
|
||||
updateRideFileIntervals(); // will emit intervalChanged() signal
|
||||
}
|
||||
|
||||
// rename multiple intervals
|
||||
void
|
||||
MainWindow::renameIntervalsSelected()
|
||||
|
||||
Reference in New Issue
Block a user