Skip to content

Commit

Permalink
Overview base setup
Browse files Browse the repository at this point in the history
.. although hacked in, at least we get a dashboard that looks
   like the real thing (till we have configuration code).

.. need to work on adding time in zones via Qt Charts next !
  • Loading branch information
liversedge committed Feb 11, 2017
1 parent d12e03f commit 7c7028a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
59 changes: 37 additions & 22 deletions src/Charts/OverviewWindow.cpp
Expand Up @@ -57,27 +57,37 @@ OverviewWindow::OverviewWindow(Context *context) :
// default column widths - max 10 columns;
// note the sizing is such that each card is the equivalent of a full screen
// so we can embed charts etc without compromising what they can display
columns << 800 << 1600 << 1600 << 800 << 1600 << 1600 << 800 << 1600 << 1600 << 800;

// XXX lets hack in some tiles to start (will load from config later XXX
newCard("Duration", 0, 1, 14, Card::METRIC, "workout_time");
newCard("Route", 0, 2, 20);
newCard("Power Zones", 0, 3, 20);
newCard("Distance", 0, 4, 14, Card::METRIC, "total_distance");
newCard("W'bal Zones", 1, 1, 20);
newCard("Stress", 1, 2, 14, Card::METRIC, "coggan_tss");
newCard("Intensity", 1, 3, 14, Card::METRIC, "coggan_if");
newCard("Equivalent Power", 1, 4, 14, Card::METRIC, "coggan_np");
newCard("Pace Zones", 1, 5, 20);
newCard("Heartrate Zones", 1, 5, 14);
newCard("Power Model", 2, 1, 20);
newCard("Intervals", 2, 2, 14);
newCard("Cadence", 2, 3, 20, Card::METRIC, "average_cad");
newCard("Heartrate", 2, 4, 14, Card::METRIC, "average_hr");
newCard("Power", 3, 1, 14, Card::METRIC, "average_power");
newCard("RPE", 3, 2, 20);
newCard("HRV", 3, 3, 14);
newCard("Speed", 3, 4, 20, Card::METRIC, "average_speed");
columns << 1200 << 1200 << 1200 << 1200 << 1200 << 1200 << 1200 << 1200 << 1200 << 1200;

// XXX lets hack in some tiles to start (will load from config later) XXX

// column 0
newCard("Sport", 0, 0, 5);
newCard("Duration", 0, 1, 5, Card::METRIC, "workout_time");
newCard("Route", 0, 2, 10);
newCard("Distance", 0, 3, 5, Card::METRIC, "total_distance");
newCard("Climbing", 0, 4, 5, Card::METRIC, "elevation_gain");
newCard("Speed", 0, 6, 5, Card::METRIC, "average_speed");

// column 1
newCard("Heartrate", 1, 0, 5, Card::METRIC, "average_hr");
newCard("HRV", 1, 1, 5);
newCard("Heartrate Zones", 1, 2, 10);
newCard("Pace Zones", 1, 3, 11);
newCard("Cadence", 1, 4, 5, Card::METRIC, "average_cad");

// column 2
newCard("RPE", 2, 0, 5);
newCard("Stress", 2, 1, 5, Card::METRIC, "coggan_tss");
newCard("W'bal Zones", 2, 2, 10);
newCard("Intervals", 2, 3, 17);

// column 3
newCard("Power", 3, 0, 5, Card::METRIC, "average_power");
newCard("Intensity", 3, 1, 5, Card::METRIC, "coggan_if");
newCard("Power Zones", 3, 2, 10);
newCard("Equivalent Power", 3, 3, 5, Card::METRIC, "coggan_np");
newCard("Power Model", 3, 4, 11);

// for changing the view
group = new QParallelAnimationGroup(this);
Expand Down Expand Up @@ -143,6 +153,9 @@ Card::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
painter->setFont(titlefont);
painter->drawText(QPointF(ROWHEIGHT /2.0f, QFontMetrics(titlefont, parent->device()).height()), name);

// only paint contents if not dragging
if (drag) return;

if (type == METRIC) {

// we need the metric units
Expand Down Expand Up @@ -569,6 +582,7 @@ OverviewWindow::eventFilter(QObject *, QEvent *event)
// it around when we start dragging
state = DRAG;
card->invisible = true;
card->drag = true;
card->brush = GColor(CPLOTMARKER); //XXX hack whilst they're tiles
card->setZValue(100);

Expand Down Expand Up @@ -599,6 +613,7 @@ OverviewWindow::eventFilter(QObject *, QEvent *event)
stateData.drag.card->invisible = false;
stateData.drag.card->setZValue(10);
stateData.drag.card->placing = true;
stateData.drag.card->drag = false;
stateData.drag.card->brush = GColor(CCARDBACKGROUND);
}

Expand Down Expand Up @@ -771,7 +786,7 @@ OverviewWindow::eventFilter(QObject *, QEvent *event)
int setdeep = stateData.yresize.deep + addrows;

//min height
if (setdeep < 6) setdeep=6; // min of 6 rows
if (setdeep < 5) setdeep=5; // min of 5 rows

stateData.yresize.card->deep = setdeep;

Expand Down
4 changes: 2 additions & 2 deletions src/Charts/OverviewWindow.h
Expand Up @@ -52,7 +52,7 @@ class Card : public QGraphicsWidget

Card(int deep, QString name) : QGraphicsWidget(NULL), name(name),
column(0), order(0), deep(deep), onscene(false),
placing(false), invisible(false) {
placing(false), drag(false), invisible(false) {

// no mouse event delivery allowed to contained QWidgets-
// this is so we can normal embed charts etc
Expand Down Expand Up @@ -104,7 +104,7 @@ class Card : public QGraphicsWidget

// which column, sequence and size in rows
int column, order, deep;
bool onscene, placing;
bool onscene, placing, drag;
bool invisible;

void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *);
Expand Down

0 comments on commit 7c7028a

Please sign in to comment.