}
currentTime = QDateTime::fromString(xml.readElementText(),"yyyy-MM-dd hh:mm:ss");
+ currentTime.setTimeSpec(Qt::UTC);
//xml.readNextStartElement(); // end currentTime element
bool inResult = xml.readNextStartElement(); // start result element
if (xml.name() != "result") {
return false;
}
inResult = xml.readNextStartElement();
- while (inResult) {
- if (xml.name() == "row") {
- TrainingEntry entry;
- entry.typeId = xml.attributes().value("","typeID").toString().toInt();
- entry.destSkillpoints = xml.attributes().value("","endSP").toString().toInt();
- entry.startSkillpoints = xml.attributes().value("","startSP").toString().toInt();
- entry.level = xml.attributes().value("","level").toString().toInt();
- if (xml.attributes().hasAttribute("","startTime")) {
- entry.startTime = QDateTime::fromString(xml.attributes().value("","startTime").toString(),
- "yyyy-MM-dd hh:mm:ss");
- entry.startTime.setTimeSpec(Qt::UTC);
- }
- if (xml.attributes().hasAttribute("","endTime")) {
- entry.endTime = QDateTime::fromString(xml.attributes().value("","endtTime").toString(),
- "yyyy-MM-dd hh:mm:ss");
- entry.endTime.setTimeSpec(Qt::UTC);
- }
- m_trainingQueue.append(entry);
+ if (xml.name() == "row") {
+ training = true;
+ m_trainingQueue.clear();
+ }
+ while (xml.name() == "row") {
+ TrainingEntry entry;
+ entry.typeId = xml.attributes().value("","typeID").toString().toInt();
+ entry.destSkillpoints = xml.attributes().value("","endSP").toString().toInt();
+ entry.startSkillpoints = xml.attributes().value("","startSP").toString().toInt();
+ entry.level = xml.attributes().value("","level").toString().toInt();
+ if (xml.attributes().hasAttribute("","startTime")) {
+ entry.startTime = QDateTime::fromString(xml.attributes().value("","startTime").toString(),
+ "yyyy-MM-dd hh:mm:ss");
+ entry.startTime.setTimeSpec(Qt::UTC);
+ }
+ if (xml.attributes().hasAttribute("","endTime")) {
+ entry.endTime = QDateTime::fromString(xml.attributes().value("","endTime").toString(),
+ "yyyy-MM-dd hh:mm:ss");
+ entry.endTime.setTimeSpec(Qt::UTC);
}
+ qDebug() << entry;
+ m_trainingQueue.append(entry);
+ if (!xml.readNextStartElement() ) // end row element
+ xml.readNextStartElement(); // start next row element
}
if (xml.name() == "cachedUntil" ) {
cachedUntil = QDateTime::fromString(xml.readElementText(),"yyyy-MM-dd hh:mm:ss");
qDebug() << "Cached until " << cachedUntil.toString(Qt::SystemLocaleShortDate);
}
qDebug() << "Parsing finished";
+ qDebug() << firstTraining();
return true;
}
m_reply->deleteLater();
emit finished();
}
+
+QDebug operator<<(QDebug dbg, const TrainingEntry &e)
+{
+ dbg.nospace() << e.typeId << " to " << e.level << e.startTime << " -> " << e.endTime;
+ return dbg.space();
+};
{
QPainter p(this);
QColor bgColor(0, 0, 0, 128);
- if (m_training) {
- // Queue empty -> red background
- if (!m_training->training) {
- bgColor.setRed(128);
- bgColor.setAlpha(160);
- } else if (m_training->currentTime.secsTo(m_training->lastTraining().endTime) < 60*60*24) {
- // Queue not full -> yellow background
- bgColor.setGreen(109);
- bgColor.setRed(163);
- }
- }
p.setBrush(bgColor);
p.setPen(Qt::NoPen);
p.drawRoundedRect(rect(), 25, 25);
- p.setPen(Qt::white);
+
QFont dFont(p.font());
dFont.setPixelSize(15);
p.setFont(dFont);
p.drawPixmap(iconLoc,*(character->characterIcon));
}
QRect nameLoc(0,10,150,20);
+ p.setPen(Qt::white);
p.drawText(nameLoc,Qt::AlignCenter,character->name);
if (m_training && m_training->training) {
- QRect skillTitle(0,110,150,50);
+ int timeLeft = m_training->currentTime.secsTo(m_training->lastTraining().endTime);
+ qDebug() << "Time left:" << timeLeft;
+ if (timeLeft < 60*60*24) {
+ // Queue not full -> yellow text
+
+ QColor penColor(254,241,53);
+ p.setPen(penColor);
+ }
+
+ QRect skillTitle(0,100,150,50);
p.drawText(skillTitle,Qt::AlignCenter|Qt::TextWordWrap,
QString("%1 %2").arg(m_skills->skillName(m_training->firstTraining().typeId))
.arg(m_training->firstTraining().level));
- QRect skillLoc(0,155,150,20);
+ QRect skillLoc(0,145,150,20);
p.drawText(skillLoc,Qt::AlignCenter,m_training->firstTraining().endTime.toString(Qt::SystemLocaleShortDate));
} else {
if (m_training != NULL && m_training->training) {
QDateTime limit = (m_training->cachedUntil > m_training->lastTraining().endTime) ?
m_training->cachedUntil : m_training->lastTraining().endTime;
+
qDebug() << "Next refresh:" << limit.toString(Qt::SystemLocaleShortDate);
int interval = 1000 * (m_training->currentTime.secsTo(limit) + 15);
//qDebug() << "Timer interval" << interval;