aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-09-06 12:54:16 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-09-07 12:02:20 +0200
commit5efc4cf00b42c72244b7e93d863291c53058d7c2 (patch)
tree8457bf2f4d3b573c637b9235a875f5a61f859de8
parent8ea4ed6b53a80a3c1a01d24b19263f1991cb4f49 (diff)
Template project wizards: Add date and time.
Task-number: QTCREATORBUG-7827 Initial-patch-by: Christian A. Reiter <christian.a.reiter@gmail.com> Change-Id: I241887acf0ff8006de74e0d67f3291b5638a54c8 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@nokia.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
-rw-r--r--doc/src/projects/creator-projects-custom-wizards.qdoc6
-rw-r--r--src/plugins/projectexplorer/customwizard/customwizardpage.cpp9
2 files changed, 15 insertions, 0 deletions
diff --git a/doc/src/projects/creator-projects-custom-wizards.qdoc b/doc/src/projects/creator-projects-custom-wizards.qdoc
index 8c4e3bc5ab..90aa8ba8ce 100644
--- a/doc/src/projects/creator-projects-custom-wizards.qdoc
+++ b/doc/src/projects/creator-projects-custom-wizards.qdoc
@@ -440,6 +440,12 @@
\o \c {%CppHeaderSuffix%} is replaced by the default header suffix,
which is also defined in \gui {File Naming}.
+ \o \c {%CurrentDate%} is replaced by the current date in the format
+ \c {yyyy-MM-dd}.
+
+ \o \c {%CurrentTime%} is replaced by the current time in the short
+ format of the locale.
+
\endlist
\section1 Validating User Input
diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
index a67321ff6f..ad5911a257 100644
--- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
+++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp
@@ -37,6 +37,8 @@
#include <QRegExp>
#include <QDebug>
#include <QDir>
+#include <QDate>
+#include <QTime>
#include <QWizardPage>
#include <QFormLayout>
@@ -462,6 +464,13 @@ QMap<QString, QString> CustomWizardFieldPage::replacementMap(const QWizard *w,
// Insert paths for generator scripts.
fieldReplacementMap.insert(QLatin1String("Path"), QDir::toNativeSeparators(ctx->path));
fieldReplacementMap.insert(QLatin1String("TargetPath"), QDir::toNativeSeparators(ctx->targetPath));
+
+ // Insert additional pre-defined variables
+ fieldReplacementMap.insert(QLatin1String("CurrentDate"),
+ QDate::currentDate().toString(QLatin1String("yyyy-MM-dd")));
+ fieldReplacementMap.insert(QLatin1String("CurrentTime"),
+ QTime::currentTime().toString(QLocale::system().
+ timeFormat(QLocale::ShortFormat)));
return fieldReplacementMap;
}