Commit 4579b7c5 authored by Tobias Hunger's avatar Tobias Hunger

MacroExpander: Add variables for date and time

The expander is used in the wizards, and being able to specify
timestamps is something many people requested at devdays.

Change-Id: If227f9c48d0b5f409d22233af8c43ae376f343f9
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent ac6b699e
......@@ -43,6 +43,7 @@
#include <coreplugin/find/findplugin.h>
#include <coreplugin/locator/locator.h>
#include <utils/macroexpander.h>
#include <utils/savefile.h>
#include <QtPlugin>
......@@ -113,6 +114,24 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_findPlugin->initialize(arguments, errorMessage);
m_locator->initialize(this, arguments, errorMessage);
Utils::MacroExpander *expander = Utils::globalMacroExpander();
expander->registerVariable("CurrentDate:ISO", tr("The current date (ISO)."),
[]() { return QDate::currentDate().toString(Qt::ISODate); });
expander->registerVariable("CurrentTime:ISO", tr("The current time (ISO)."),
[]() { return QTime::currentTime().toString(Qt::ISODate); });
expander->registerVariable("CurrentDate:RFC", tr("The current date (RFC2822)."),
[]() { return QDate::currentDate().toString(Qt::RFC2822Date); });
expander->registerVariable("CurrentTime:RFC", tr("The current time (RFC2822)."),
[]() { return QTime::currentTime().toString(Qt::RFC2822Date); });
expander->registerVariable("CurrentDate:Locale", tr("The current date (Locale)."),
[]() { return QDate::currentDate().toString(Qt::DefaultLocaleShortDate); });
expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."),
[]() { return QTime::currentTime().toString(Qt::DefaultLocaleShortDate); });
expander->registerPrefix("CurrentDate:", tr("The current date (QDate formatstring)"),
[](const QString &fmt) { return QDate::currentDate().toString(fmt); });
expander->registerPrefix("CurrentTime:", tr("The current time (QTime formatstring)"),
[](const QString &fmt) { return QTime::currentTime().toString(fmt); });
return success;
}
......
Markdown is supported
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