mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-04-15 05:32:21 +00:00
Show metric refresh progress on Athlete View
.. part of a general process of centralising status, progress messages and indicators into one place.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
// singleton
|
||||
static GlobalContext *globalContext = new GlobalContext();
|
||||
static QList<Context*> _contexts;
|
||||
bool Context::isValid(Context *p) { return p != NULL &&_contexts.contains(p); }
|
||||
GlobalContext *GlobalContext::context() { return globalContext; }
|
||||
|
||||
Context::Context(MainWindow *mainWindow): mainWindow(mainWindow)
|
||||
|
||||
@@ -93,6 +93,9 @@ class Context : public QObject
|
||||
Context(MainWindow *mainWindow);
|
||||
~Context();
|
||||
|
||||
// check if valid (might be deleted)
|
||||
static bool isValid(Context *);
|
||||
|
||||
// mainwindow state
|
||||
NavigationModel *nav;
|
||||
int viewIndex;
|
||||
|
||||
@@ -66,7 +66,7 @@ AthleteView::configChanged(qint32)
|
||||
|
||||
}
|
||||
|
||||
AthleteCard::AthleteCard(ChartSpace *parent, QString path) : ChartSpaceItem(parent, path), path(path)
|
||||
AthleteCard::AthleteCard(ChartSpace *parent, QString path) : ChartSpaceItem(parent, path), path(path), refresh(false)
|
||||
{
|
||||
// no config icon thanks
|
||||
setShowConfig(false);
|
||||
@@ -98,6 +98,12 @@ AthleteCard::AthleteCard(ChartSpace *parent, QString path) : ChartSpaceItem(pare
|
||||
anchor=true;
|
||||
button->setText("Close");
|
||||
button->hide();
|
||||
|
||||
// watch metric updates
|
||||
connect(context, SIGNAL(refreshStart()), this, SLOT(refreshStart()));
|
||||
connect(context, SIGNAL(refreshEnd()), this, SLOT(refreshEnd()));
|
||||
connect(context, SIGNAL(refreshUpdate(QDate)), this, SLOT(refreshUpdate(QDate))); // we might miss 1st one
|
||||
|
||||
} else {
|
||||
context = NULL;
|
||||
loadprogress = 0;
|
||||
@@ -171,10 +177,19 @@ AthleteCard::opening(QString name, Context*context)
|
||||
connect(context,SIGNAL(loadProgress(QString,double)), this, SLOT(loadProgress(QString,double)));
|
||||
connect(context,SIGNAL(loadDone(QString,Context*)), this, SLOT(loadDone(QString,Context*)));
|
||||
connect(context,SIGNAL(athleteClose(QString,Context*)), this, SLOT(closing(QString,Context*)));
|
||||
}
|
||||
|
||||
// refresh updates
|
||||
connect(context, SIGNAL(refreshStart()), this, SLOT(refreshStart()));
|
||||
connect(context, SIGNAL(refreshEnd()), this, SLOT(refreshEnd()));
|
||||
connect(context, SIGNAL(refreshUpdate(QDate)), this, SLOT(refreshUpdate(QDate))); // we might miss 1st one
|
||||
}
|
||||
}
|
||||
|
||||
// track refreshes
|
||||
void AthleteCard::refreshStart() { refresh = true; update(); }
|
||||
void AthleteCard::refreshEnd() { refresh = false; update(); }
|
||||
void AthleteCard::refreshUpdate(QDate) { refresh = true; update(); }
|
||||
|
||||
void AthleteCard::itemGeometryChanged()
|
||||
{
|
||||
button->setGeometry(geometry().width()-(gl_button_width+ROWHEIGHT), geometry().height()-(gl_button_height+ROWHEIGHT),
|
||||
@@ -233,8 +248,15 @@ AthleteCard::itemPaint(QPainter *painter, const QStyleOptionGraphicsItem *, QWid
|
||||
painter->drawText(rectf, message, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
|
||||
// load status
|
||||
QRectF progressbar(0, geometry().height()-gl_progress_width, geometry().width() * (loadprogress/100), gl_progress_width);
|
||||
painter->fillRect(progressbar, QBrush(GColor(CPLOTMARKER)));
|
||||
|
||||
// refresh status
|
||||
if (refresh && Context::isValid(context)) {
|
||||
QRectF progressbar(0, geometry().height()-gl_progress_width, geometry().width() * (double(context->athlete->rideCache->progress())/100), gl_progress_width);
|
||||
QColor over(Qt::white);
|
||||
over.setAlpha(128);
|
||||
painter->fillRect(progressbar, QBrush(over));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,17 @@ class AthleteCard : public ChartSpaceItem
|
||||
static ChartSpaceItem *create(ChartSpace *parent) { return new AthleteCard(parent, ""); }
|
||||
|
||||
public slots:
|
||||
// opening/closing etc
|
||||
void opening(QString, Context*);
|
||||
void closing(QString, Context*);
|
||||
void loadProgress(QString, double);
|
||||
void loadDone(QString, Context*);
|
||||
|
||||
// metric refreshing
|
||||
void refreshStart();
|
||||
void refreshEnd();
|
||||
void refreshUpdate(QDate);
|
||||
|
||||
void clicked();
|
||||
|
||||
private:
|
||||
@@ -55,5 +61,6 @@ class AthleteCard : public ChartSpaceItem
|
||||
// little graph of last 90 days
|
||||
int count; // total activities
|
||||
QDateTime last; // date of last activity recorded
|
||||
bool refresh;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user