Yellow text color if training queue has room for more skills, adjust text location
[evehomescreen] / src / eveskilltraining.cpp
index 4a09391..bb86cb3 100644 (file)
@@ -30,6 +30,7 @@ bool EveSkillTraining::fromXml(QXmlStreamReader &xml)
     }
 
     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") {
@@ -42,26 +43,31 @@ bool EveSkillTraining::fromXml(QXmlStreamReader &xml)
         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");
@@ -69,6 +75,7 @@ bool EveSkillTraining::fromXml(QXmlStreamReader &xml)
         qDebug() << "Cached until " << cachedUntil.toString(Qt::SystemLocaleShortDate);
     }
     qDebug() << "Parsing finished";
+    qDebug() << firstTraining();
     return true;
 }
 
@@ -105,3 +112,9 @@ void EveSkillTraining::infoReady()
     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();
+};