mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
AnalysisSidebar: Reinstate interval DRAG/DROP in list 2
- Apply change to RideFile
This commit is contained in:
@@ -65,18 +65,22 @@ IntervalTreeView::dropEvent(QDropEvent* event)
|
||||
QList<IntervalItem*> intervals = context->rideItem()->intervals();
|
||||
QList<IntervalItem*> userIntervals = context->rideItem()->intervals(RideFileInterval::USER);
|
||||
|
||||
int indexTo = intervals.indexOf(userIntervals.at(parent->indexOfChild(target)));
|
||||
int indexTo1 = parent->indexOfChild(target);
|
||||
int indexTo2 = intervals.indexOf(userIntervals.at(indexTo1));
|
||||
int offsetFrom = 0;
|
||||
int offsetTo = 0;
|
||||
|
||||
bool change = false;
|
||||
foreach (QTreeWidgetItem *p, selectedItems()) {
|
||||
if (p->parent() == parent) {
|
||||
int indexFrom = intervals.indexOf(userIntervals.at(parent->indexOfChild(p)));
|
||||
int indexFrom1 = parent->indexOfChild(p);
|
||||
int indexFrom2 = intervals.indexOf(userIntervals.at(indexFrom1));
|
||||
|
||||
context->rideItem()->ride()->moveInterval(indexFrom1+offsetFrom,indexTo1+offsetTo);
|
||||
context->rideItem()->intervals().move(indexFrom2+offsetFrom,indexTo2+offsetTo);
|
||||
|
||||
context->rideItem()->intervals().move(indexFrom+offsetFrom,indexTo+offsetTo);
|
||||
change = true;
|
||||
if (indexFrom<indexTo)
|
||||
if (indexFrom1<indexTo1)
|
||||
offsetFrom--;
|
||||
else
|
||||
offsetTo++;
|
||||
|
||||
@@ -370,6 +370,12 @@ RideFile::removeInterval(RideFileInterval*x)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RideFile::moveInterval(int from, int to)
|
||||
{
|
||||
intervals_.move(from, to);
|
||||
}
|
||||
|
||||
struct ComparePointKm {
|
||||
bool operator()(const RideFilePoint *p1, const RideFilePoint *p2) {
|
||||
return p1->km < p2->km;
|
||||
|
||||
@@ -268,6 +268,7 @@ class RideFile : public QObject // QObject to emit signals
|
||||
int intervalBegin(const RideFileInterval &interval) const;
|
||||
int intervalBeginSecs(const double secs) const;
|
||||
bool removeInterval(RideFileInterval*);
|
||||
void moveInterval(int from, int to);
|
||||
|
||||
// Working with CAIBRATIONS
|
||||
const QList<RideFileCalibration*> &calibrations() const { return calibrations_; }
|
||||
|
||||
Reference in New Issue
Block a user