BuildLogViewer/AtAGlance.cpp
changeset 2 6894bf2709c0
parent 1 8e9c5760ce6f
child 3 e6d1a78b6db9
--- a/BuildLogViewer/AtAGlance.cpp	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/AtAGlance.cpp	Thu Sep 03 16:31:30 2009 -0700
@@ -7,6 +7,7 @@
 
 #include <QtGlobal>
 #include <QRegExp>
+#include <QStringList>
 
 #include <QGridLayout>
 #include <QLabel>
@@ -52,6 +53,7 @@
 {
     this->traveAndPopulate(m_log->documentElement());
 }
+
 void AtAGlance::traveAndPopulate(QDomElement e)
 {
     QString name = e.tagName();
@@ -67,25 +69,58 @@
     {
         // example
         // System Definition file sf/app/organizer/package_definition.xml
-        QRegExp re("^System Definition file .*package_definition.*$");
+        QRegExp re("System*package_definition.xml");
         re.setPatternSyntax(QRegExp::Wildcard);
 
-        string blah = e.text().toStdString();
-
         if (re.exactMatch( e.text() ) )
         {
-            std::cout << "info: " << e.text().toStdString()<< std::endl;
+            QRegExp reToken("*package_definition.xml");
+            // Which regex syntax should be used? Wildcard is ...
+            reToken.setPatternSyntax(QRegExp::Wildcard);
+
+            QStringList tokens = e.text().split(" ");
+            QStringList::const_iterator constIterator;
+            for (constIterator = tokens.constBegin();
+                    constIterator != tokens.constEnd();
+                    ++constIterator)
+            {
+                if (reToken.exactMatch(*constIterator))
+                {
+                    m_buildStatus->setName((*constIterator).toLocal8Bit().constData());
+                }
+            }
         }
     }
 
     // if this is a status tag and the exit attribute is failed, the build failed.
     if (name.compare("status",Qt::CaseInsensitive)== 0 )
     {
-        m_buildStatus->setStatus(false);
+        QString rc = e.attribute("exit");
+        if (!rc.isEmpty() && (rc.compare("failed", Qt::CaseInsensitive) == 0))
+        {
+            m_buildStatus->setStatus(false);
+        }
+    }
+
+    // unforunately, the build log isn't valid xml.  The recipe tag often contains
+    // trace output from a shell program in addition to the status tag.  Sigh.
+    // So this condition looks for the status tag in the body for the recipe tag.
+    // here is what the status tag should look like:
+    //   <status exit='ok' attempt='1' />
+    if (name.compare("recipe",Qt::CaseInsensitive)== 0 )
+    {
+        QRegExp re("*status exit*fail*");
+        re.setPatternSyntax(QRegExp::Wildcard); 
+        if (re.exactMatch(e.text()))
+        {
+            m_buildStatus->setStatus(false);
+        }
     }
 
     QString text_debug;
     QDomElement e1 = e.firstChild().toElement();
+    name = e1.tagName();
+    text_debug = e1.text();
     while(!e1.isNull())
     {
         this->traveAndPopulate(e1);
@@ -100,6 +135,9 @@
     QGridLayout *layout = new QGridLayout(this);
 
     layout->addWidget(new QLabel("What: "), 1, 1);
+    layout->addWidget(new QLabel(*m_buildStatus->name()),1,2);
     layout->addWidget(new QLabel("When: "), 2, 1);
+    layout->addWidget(new QLabel(m_buildStatus->time()) ,2,2);
     layout->addWidget(new QLabel("Status: "), 3, 1);
+    layout->addWidget(new QLabel(*m_buildStatus->status()),3,2);
 }