Indicate loading state, fix cache time parsing
authorjasu <jasu@skeletor.(none)>
Sun, 23 May 2010 18:33:56 +0000 (21:33 +0300)
committerjasu <jasu@skeletor.(none)>
Sun, 23 May 2010 18:33:56 +0000 (21:33 +0300)
src/eveskilltraining.cpp

index bb86cb3..c3e7bd8 100644 (file)
@@ -15,7 +15,8 @@ EveSkillTraining::EveSkillTraining(QObject *parent) :
     training(false),
     m_character(NULL),
     m_account(NULL),
-    m_reply(NULL)
+    m_reply(NULL),
+    m_loading(false)
 {
 }
 
@@ -69,8 +70,14 @@ bool EveSkillTraining::fromXml(QXmlStreamReader &xml)
         if (!xml.readNextStartElement() ) // end row element
             xml.readNextStartElement(); // start next row element
     }
+    xml.readNextStartElement(); // end rowset
+    xml.readNextStartElement(); // end result
+
     if (xml.name() == "cachedUntil" ) {
-        cachedUntil = QDateTime::fromString(xml.readElementText(),"yyyy-MM-dd hh:mm:ss");
+        QString cacheDate = xml.readElementText();
+        qDebug() << "Cache date: " << cacheDate;
+        cachedUntil = QDateTime::fromString(cacheDate,"yyyy-MM-dd hh:mm:ss");
+
         cachedUntil.setTimeSpec(Qt::UTC);
         qDebug() << "Cached until " << cachedUntil.toString(Qt::SystemLocaleShortDate);
     }
@@ -89,6 +96,7 @@ void EveSkillTraining::fetchInfo()
             return;
         }
     }
+    m_loading = true;
     QNetworkRequest req(QUrl(QString("http://api.eveonline.com/char/SkillQueue.xml.aspx?apiKey=%1&userID=%2&characterID=%3")
                              .arg(m_account->apiKey())
                              .arg(m_account->userId())
@@ -110,11 +118,15 @@ void EveSkillTraining::infoReady()
     QXmlStreamReader reader(reply);
     fromXml(reader);
     m_reply->deleteLater();
+    m_loading = false;
     emit finished();
 }
 
 QDebug operator<<(QDebug dbg, const TrainingEntry &e)
 {
-    dbg.nospace() << e.typeId << " to " << e.level << e.startTime << " -> " << e.endTime;
+    dbg.nospace() << e.typeId << " to "
+                << e.level << " "
+                << e.startTime.toString(Qt::SystemLocaleShortDate) << " -> "
+                << e.endTime.toString(Qt::SystemLocaleShortDate);
     return dbg.space();
 };