Commit 5efc4cf0 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Template project wizards: Add date and time.



Task-number: QTCREATORBUG-7827
Initial-patch-by: default avatarChristian A. Reiter <christian.a.reiter@gmail.com>

Change-Id: I241887acf0ff8006de74e0d67f3291b5638a54c8
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@nokia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent 8ea4ed6b
...@@ -440,6 +440,12 @@ ...@@ -440,6 +440,12 @@
\o \c {%CppHeaderSuffix%} is replaced by the default header suffix, \o \c {%CppHeaderSuffix%} is replaced by the default header suffix,
which is also defined in \gui {File Naming}. 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 \endlist
\section1 Validating User Input \section1 Validating User Input
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include <QRegExp> #include <QRegExp>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QDate>
#include <QTime>
#include <QWizardPage> #include <QWizardPage>
#include <QFormLayout> #include <QFormLayout>
...@@ -462,6 +464,13 @@ QMap<QString, QString> CustomWizardFieldPage::replacementMap(const QWizard *w, ...@@ -462,6 +464,13 @@ QMap<QString, QString> CustomWizardFieldPage::replacementMap(const QWizard *w,
// Insert paths for generator scripts. // Insert paths for generator scripts.
fieldReplacementMap.insert(QLatin1String("Path"), QDir::toNativeSeparators(ctx->path)); fieldReplacementMap.insert(QLatin1String("Path"), QDir::toNativeSeparators(ctx->path));
fieldReplacementMap.insert(QLatin1String("TargetPath"), QDir::toNativeSeparators(ctx->targetPath)); 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; return fieldReplacementMap;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment