#include "timeline.h" // --- cTimelineElement ------------------------------------------------------------- cTimelineElement::cTimelineElement(time_t elementTime) { init = true; this->elementTime = elementTime; } cTimelineElement::~cTimelineElement() { } bool cTimelineElement::IsNew(void) { if (init) { init = false; return true; } return init; } bool cTimelineElement::IsFullHour(void) { if (elementTime%3600 == 0) return true; return false; } // --- cTimeline ------------------------------------------------------------- cTimeline::cTimeline(skindesignerapi::cViewGrid *timelineGrid, skindesignerapi::cViewElement *timelineDate, skindesignerapi::cViewElement *timeIndicator, cTimeManager *timeManager) { this->timelineGrid = timelineGrid; this->timelineDate = timelineDate; this->timeIndicator = timeIndicator; this->timeManager = timeManager; steps = config.displayHours * 2; stepDuration = 30 * 60; weekday = ""; timeIndicatorShown = true; } cTimeline::~cTimeline(void) { Clear(); delete timelineDate; delete timeIndicator; delete timelineGrid; } void cTimeline::Init(void) { time_t startTime = timeManager->GetStart(); time_t elementTime = startTime; for (int i=0; i < steps; i++) { cTimelineElement *e = new cTimelineElement(elementTime); grids.Add(e); elementTime += stepDuration; } } void cTimeline::Clear(void) { timelineGrid->Clear(); grids.Clear(); } void cTimeline::ScrollForward(int stepMinutes) { int numSteps = stepMinutes / 30; for (int i=0; iDelete(e->Id()); grids.Del(e); } time_t newStartTime = timeManager->GetEnd() - stepMinutes * 60; for (int i=0; iDelete(e->Id()); grids.Del(e); } time_t newStartTime = timeManager->GetStart() + (numSteps-1) * 30 * 60; for (int i=0; iIsNew()) { timelineGrid->ClearTokens(); timelineGrid->AddIntToken("fullhour", e->IsFullHour()); timelineGrid->AddStringToken("timestring", e->ToString()); timelineGrid->SetGrid(e->Id(), x, y, width, height); } else { timelineGrid->MoveGrid(e->Id(), x, y, width, height); } if (config.displayMode == eHorizontal) x += width; else y += height; } timelineGrid->Display(); } void cTimeline::DrawDate(void) { string weekdayNew = *(timeManager->GetWeekday()); if (!weekdayNew.compare(weekday)) return; weekday = weekdayNew; timelineDate->Clear(); timelineDate->ClearTokens(); string date = *(timeManager->GetDate()); timelineDate->AddStringToken("weekday", weekday); timelineDate->AddStringToken("date", date); timelineDate->Display(); } void cTimeline::DrawTimeIndicator(void) { if (timeManager->NowVisible()) { timeIndicatorShown = true; int distance = (timeManager->GetNow() - timeManager->GetStart()) / 60; int percentTotal = distance*1000/(config.displayHours*60); timeIndicator->Clear(); timeIndicator->ClearTokens(); timeIndicator->AddIntToken("percenttotal", percentTotal); timeIndicator->Display(); } else if (timeIndicatorShown) { timeIndicatorShown = false; timeIndicator->Clear(); } }