mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Reinstating Interval functions: ADD ON GOOGLE MAP
.. by click and drag
This commit is contained in:
@@ -2018,18 +2018,9 @@ AllPlotWindow::setEndSelection(AllPlot* plot, double xValue, bool newInterval, Q
|
||||
// are we adjusting an existing interval? - if so delete it and readd it
|
||||
if (users.count() > 0 && users.last()->name.startsWith(name)) {
|
||||
|
||||
// update interval
|
||||
// update interval - could do via a IntervalItem::setXX() function
|
||||
IntervalItem *interval = users.last();
|
||||
interval->rideInterval->start = interval->start = duration1;
|
||||
interval->rideInterval->stop = interval->stop = duration2;
|
||||
interval->startKM = distance1;
|
||||
interval->stopKM = distance2;
|
||||
interval->refresh();
|
||||
|
||||
// update ridefile
|
||||
ride->setDirty(true);
|
||||
|
||||
//
|
||||
interval->setValues(interval->name, duration1, duration2, distance1, distance2);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
@@ -765,16 +765,15 @@ void
|
||||
WebBridge::hoverPath(double lat, double lng)
|
||||
{
|
||||
if (point) {
|
||||
#if 0 //XXX REFACTOR -- HOW TO CREATE AND EDIT AN INTERVAL!
|
||||
|
||||
RideItem *rideItem = gm->property("ride").value<RideItem*>();
|
||||
QString name = QString(tr("Selection #%1 ")).arg(selection);
|
||||
|
||||
int count =
|
||||
if (rideItem->intervals(RideFileInterval::USER).count()) {
|
||||
|
||||
if (count > 0) {
|
||||
IntervalItem *bottom = (IntervalItem *) allIntervals->child(count-1);
|
||||
if (bottom->text(0).startsWith(name)) { //delete allIntervals->takeChild(count-1);
|
||||
IntervalItem *last = rideItem->intervals(RideFileInterval::USER).last();
|
||||
|
||||
if (last->name.startsWith(name) && last->rideInterval) {
|
||||
|
||||
QList<RideFilePoint*> list = searchPoint(lat, lng);
|
||||
|
||||
@@ -783,80 +782,70 @@ WebBridge::hoverPath(double lat, double lng)
|
||||
RideFilePoint* secondPoint = list.at(0);
|
||||
|
||||
if (secondPoint->secs>point->secs) {
|
||||
bottom->start = point->secs;
|
||||
bottom->stop = secondPoint->secs;
|
||||
last->rideInterval->start = last->start = point->secs;
|
||||
last->rideInterval->stop = last->stop = secondPoint->secs;
|
||||
} else {
|
||||
bottom->stop = point->secs;
|
||||
bottom->start = secondPoint->secs;
|
||||
last->rideInterval->stop = last->stop = point->secs;
|
||||
last->rideInterval->start = last->start = secondPoint->secs;
|
||||
}
|
||||
last->startKM = last->rideItem()->ride()->timeToDistance(last->start);
|
||||
last->stopKM = last->rideItem()->ride()->timeToDistance(last->stop);
|
||||
|
||||
// update metrics
|
||||
last->refresh();
|
||||
|
||||
// mark dirty
|
||||
last->rideItem()->setDirty(true);
|
||||
|
||||
// overlay a shaded route
|
||||
gm->drawTempInterval(bottom);
|
||||
gm->drawTempInterval(last);
|
||||
|
||||
// update charts etc
|
||||
context->notifyIntervalsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// add average power to the end of the selection name
|
||||
//name += QString("(%1 watts)").arg(round((wattsTotal && arrayLength) ? wattsTotal/arrayLength : 0));
|
||||
|
||||
|
||||
// now update the RideFileIntervals and all the plots etc
|
||||
//context->athlete->updateRideFileIntervals();
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebBridge::clickPath(double lat, double lng)
|
||||
{
|
||||
|
||||
#if 0 //XXX REFACTOR HOW TO SELECT AND EDIT AND INTERVAL
|
||||
selection++;
|
||||
RideItem *rideItem = gm->property("ride").value<RideItem*>();
|
||||
QString name = QString(tr("Selection #%1 ")).arg(selection);
|
||||
QList<RideFilePoint*> list = searchPoint(lat, lng);
|
||||
|
||||
if (list.count() > 0) {
|
||||
|
||||
point = list.at(0);
|
||||
|
||||
QTreeWidgetItem *allIntervals = context->athlete->mutableIntervalItems();
|
||||
IntervalItem *add = rideItem->newInterval(name, point->secs, point->secs, 0, 0);
|
||||
add->selected = true;
|
||||
|
||||
QTreeWidgetItem *last = new IntervalItem(rideItem->ride(), name, point->secs, point->secs, 0, 0,
|
||||
allIntervals->childCount()+1, RideFileInterval::USER);
|
||||
last->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled);
|
||||
allIntervals->addChild(last);
|
||||
// rebuild list in sidebar
|
||||
context->notifyIntervalsUpdate(rideItem);
|
||||
|
||||
context->athlete->intervalTreeWidget()->clearSelection();
|
||||
context->athlete->intervalTreeWidget()->setItemSelected(last, true);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
point = NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebBridge::mouseup()
|
||||
{
|
||||
#if 0 //XXX REFACTOR CREATE AND EDIT NEW INTERVAL
|
||||
// clear the temorary highlighter
|
||||
if (point) {
|
||||
gm->clearTempInterval();
|
||||
QTreeWidgetItem *allIntervals = context->athlete->mutableIntervalItems();
|
||||
int count = allIntervals->childCount();
|
||||
|
||||
if (count > 0) {
|
||||
IntervalItem *bottom = (IntervalItem *) allIntervals->child(count-1);
|
||||
context->athlete->intervalTreeWidget()->setItemSelected(bottom, true);
|
||||
}
|
||||
|
||||
context->athlete->updateRideFileIntervals();
|
||||
point = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,34 @@ IntervalItem::setFrom(IntervalItem &other)
|
||||
selected = false;
|
||||
}
|
||||
|
||||
void
|
||||
IntervalItem::setValues(QString name, double duration1, double duration2,
|
||||
double distance1, double distance2)
|
||||
{
|
||||
// apply the update
|
||||
this->name = name;
|
||||
start = duration1;
|
||||
stop = duration2;
|
||||
startKM = distance1;
|
||||
stopKM = distance2;
|
||||
|
||||
// only accept changes if we can send on
|
||||
if (type == RideFileInterval::USER && rideInterval) {
|
||||
|
||||
// update us and our ridefileinterval
|
||||
rideInterval->start = start = duration1;
|
||||
rideInterval->stop = stop = duration2;
|
||||
startKM = distance1;
|
||||
stopKM = distance2;
|
||||
|
||||
// update ridefile
|
||||
rideItem_->setDirty(true);
|
||||
}
|
||||
|
||||
// update metrics
|
||||
refresh();
|
||||
}
|
||||
|
||||
void
|
||||
IntervalItem::refresh()
|
||||
{
|
||||
|
||||
@@ -44,6 +44,10 @@ class IntervalItem
|
||||
// set from other
|
||||
void setFrom(IntervalItem &other);
|
||||
|
||||
// change basic values, will also apply to ridefile
|
||||
void setValues(QString name, double duration1, double duration2,
|
||||
double distance1, double distance2);
|
||||
|
||||
// is this interval currently selected ?
|
||||
bool selected;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user