OSDN Git Service

Qt4ProFileNode: Add project version information.
authorChristian Kandeler <christian.kandeler@nokia.com>
Fri, 13 May 2011 11:23:38 +0000 (13:23 +0200)
committerChristian Kandeler <christian.kandeler@nokia.com>
Fri, 13 May 2011 11:55:05 +0000 (13:55 +0200)
Reviewed-by: dt
src/plugins/qt4projectmanager/qt4nodes.cpp
src/plugins/qt4projectmanager/qt4nodes.h

index 8c60947..a695e3c 100644 (file)
@@ -1739,6 +1739,7 @@ void Qt4ProFileNode::applyEvaluate(EvalResult evalResult, bool async)
         m_qt4targetInformation = targetInformation(m_readerExact);
 
         setupInstallsList(m_readerExact);
+        setupProjectVersion(m_readerExact);
 
         // update other variables
         QHash<Qt4Variable, QStringList> newVarValues;
@@ -2131,6 +2132,59 @@ void Qt4ProFileNode::setupInstallsList(const ProFileReader *reader)
     }
 }
 
+void Qt4ProFileNode::setupProjectVersion(const ProFileReader *reader)
+{
+    m_projectVersion.major = m_projectVersion.minor = m_projectVersion.patch = -1;
+    bool ok;
+    int val = reader->value(QLatin1String("VER_MAJ")).toInt(&ok);
+    if (ok)
+        m_projectVersion.major = val;
+    val = reader->value(QLatin1String("VER_MIN")).toInt(&ok);
+    if (ok)
+        m_projectVersion.minor = val;
+    val = reader->value(QLatin1String("VER_PAT")).toInt(&ok);
+    if (ok)
+        m_projectVersion.patch = val;
+    if (m_projectVersion.major != -1 && m_projectVersion.minor != -1
+            && m_projectVersion.patch != -1) {
+        return;
+    }
+
+    const QString &version = reader->value(QLatin1String("VERSION"));
+    const QChar dot(QLatin1Char('.'));
+    int dotIndex = version.indexOf(dot);
+    if (m_projectVersion.major == -1) {
+        val = version.left(dotIndex).toInt(&ok);
+        if (ok)
+            m_projectVersion.major = val;
+    }
+    if (dotIndex != -1) {
+        int numberStartIndex = dotIndex + 1;
+        dotIndex = version.indexOf(dot, numberStartIndex);
+        if (m_projectVersion.minor == -1) {
+            val = version.mid(numberStartIndex, dotIndex - numberStartIndex).toInt(&ok);
+            if (ok)
+                m_projectVersion.minor = val;
+        }
+    }
+    if (dotIndex != -1) {
+        int numberStartIndex = dotIndex + 1;
+        dotIndex = version.indexOf(dot, numberStartIndex);
+        if (m_projectVersion.patch == -1) {
+            val = version.mid(numberStartIndex, dotIndex - numberStartIndex).toInt(&ok);
+            if (ok)
+                m_projectVersion.patch= val;
+        }
+    }
+
+    if (m_projectVersion.major == -1)
+        m_projectVersion.major = 1;
+    if (m_projectVersion.minor == -1)
+        m_projectVersion.minor = 0;
+    if (m_projectVersion.patch == -1)
+        m_projectVersion.patch = 0;
+}
+
 InstallsList Qt4ProFileNode::installsList() const
 {
     return m_installsList;
index 9f72455..8a6c500 100644 (file)
@@ -269,6 +269,12 @@ struct InstallsList {
     QList<InstallsItem> items;
 };
 
+struct ProjectVersion {
+    int major;
+    int minor;
+    int patch;
+};
+
 // Implements ProjectNode for qt4 pro files
 class Qt4ProFileNode : public Qt4PriFileNode
 {
@@ -301,6 +307,7 @@ public:
     TargetInformation targetInformation() const;
 
     InstallsList installsList() const;
+    ProjectVersion projectVersion() const { return m_projectVersion; }
 
     QString makefile() const;
     QStringList symbianCapabilities() const;
@@ -343,6 +350,7 @@ private:
     QStringList subDirsPaths(ProFileReader *reader) const;
     TargetInformation targetInformation(ProFileReader *reader) const;
     void setupInstallsList(const ProFileReader *reader);
+    void setupProjectVersion(const ProFileReader *reader);
 
     void invalidate();
 
@@ -353,6 +361,7 @@ private:
     QMap<QString, QDateTime> m_uitimestamps;
     TargetInformation m_qt4targetInformation;
     InstallsList m_installsList;
+    ProjectVersion m_projectVersion;
     friend class Qt4NodeHierarchy;
 
     bool m_validParse;