mirror of
https://github.com/fralx/LimeReport.git
synced 2025-03-31 22:53:44 +03:00
Merge branch 'master' into develop
# Conflicts: # limereport/lrscriptenginemanager.cpp
This commit is contained in:
commit
67aea4f1ff
@ -649,6 +649,23 @@ bool ScriptEngineManager::createDateTimeFormatFunction(){
|
|||||||
return addFunction(fd);
|
return addFunction(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptEngineManager::createSectotimeFormatFunction()
|
||||||
|
{
|
||||||
|
JSFunctionDesc fd;
|
||||||
|
|
||||||
|
fd.setManager(m_functionManager);
|
||||||
|
fd.setManagerName(LimeReport::Const::FUNCTION_MANAGER_NAME);
|
||||||
|
fd.setCategory(tr("DATE&TIME"));
|
||||||
|
fd.setName("sectotimeFormat");
|
||||||
|
fd.setDescription("sectotimeFormat(\""+tr("Value")+"\",\""+tr("Format")+"\")");
|
||||||
|
fd.setScriptWrapper(QString("function sectotimeFormat(value, format){"
|
||||||
|
" if(typeof(format)==='undefined') format = \"hh:mm:ss\"; "
|
||||||
|
"return %1.sectotimeFormat(value,format);}"
|
||||||
|
).arg(LimeReport::Const::FUNCTION_MANAGER_NAME)
|
||||||
|
);
|
||||||
|
return addFunction(fd);
|
||||||
|
}
|
||||||
|
|
||||||
bool ScriptEngineManager::createDateFunction(){
|
bool ScriptEngineManager::createDateFunction(){
|
||||||
// addFunction("date",date,"DATE&TIME","date()");
|
// addFunction("date",date,"DATE&TIME","date()");
|
||||||
JSFunctionDesc fd;
|
JSFunctionDesc fd;
|
||||||
@ -842,6 +859,7 @@ ScriptEngineManager::ScriptEngineManager()
|
|||||||
createDateFormatFunction();
|
createDateFormatFunction();
|
||||||
createTimeFormatFunction();
|
createTimeFormatFunction();
|
||||||
createDateTimeFormatFunction();
|
createDateTimeFormatFunction();
|
||||||
|
createSectotimeFormatFunction();
|
||||||
createDateFunction();
|
createDateFunction();
|
||||||
createNowFunction();
|
createNowFunction();
|
||||||
#if QT_VERSION>0x040800
|
#if QT_VERSION>0x040800
|
||||||
@ -1476,6 +1494,23 @@ QVariant ScriptFunctionsManager::dateTimeFormat(QVariant value, const QString &f
|
|||||||
return QLocale().toString(value.toDateTime(),format);
|
return QLocale().toString(value.toDateTime(),format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant ScriptFunctionsManager::sectotimeFormat(QVariant value, const QString &format)
|
||||||
|
{
|
||||||
|
int seconds = value.toInt();
|
||||||
|
int minutes = seconds / 60;
|
||||||
|
int hours = minutes / 60;
|
||||||
|
|
||||||
|
QString result = format;
|
||||||
|
bool hasHour = format.contains("h");
|
||||||
|
bool hasMinute = format.contains("m");
|
||||||
|
for(int len = 2; len; len--) {
|
||||||
|
if(hasHour) result.replace(QString('h').repeated(len), QString::number(hours).rightJustified(len, '0'));
|
||||||
|
if(hasMinute) result.replace(QString('m').repeated(len), QString::number(hasHour ? minutes % 60 : minutes).rightJustified(len, '0'));
|
||||||
|
result.replace(QString('s').repeated(len), QString::number(hasMinute ? seconds % 60 : seconds).rightJustified(len, '0'));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant ScriptFunctionsManager::date()
|
QVariant ScriptFunctionsManager::date()
|
||||||
{
|
{
|
||||||
return QDate::currentDate();
|
return QDate::currentDate();
|
||||||
|
@ -311,6 +311,7 @@ public:
|
|||||||
Q_INVOKABLE QVariant dateFormat(QVariant value, const QString& format);
|
Q_INVOKABLE QVariant dateFormat(QVariant value, const QString& format);
|
||||||
Q_INVOKABLE QVariant timeFormat(QVariant value, const QString& format);
|
Q_INVOKABLE QVariant timeFormat(QVariant value, const QString& format);
|
||||||
Q_INVOKABLE QVariant dateTimeFormat(QVariant value, const QString& format);
|
Q_INVOKABLE QVariant dateTimeFormat(QVariant value, const QString& format);
|
||||||
|
Q_INVOKABLE QVariant sectotimeFormat(QVariant value, const QString& format);
|
||||||
Q_INVOKABLE QVariant date();
|
Q_INVOKABLE QVariant date();
|
||||||
Q_INVOKABLE QVariant now();
|
Q_INVOKABLE QVariant now();
|
||||||
Q_INVOKABLE QVariant currencyFormat(QVariant value, const QString& locale);
|
Q_INVOKABLE QVariant currencyFormat(QVariant value, const QString& locale);
|
||||||
@ -385,6 +386,7 @@ private:
|
|||||||
bool createDateFormatFunction();
|
bool createDateFormatFunction();
|
||||||
bool createTimeFormatFunction();
|
bool createTimeFormatFunction();
|
||||||
bool createDateTimeFormatFunction();
|
bool createDateTimeFormatFunction();
|
||||||
|
bool createSectotimeFormatFunction();
|
||||||
bool createDateFunction();
|
bool createDateFunction();
|
||||||
bool createNowFunction();
|
bool createNowFunction();
|
||||||
bool createCurrencyFormatFunction();
|
bool createCurrencyFormatFunction();
|
||||||
|
Loading…
Reference in New Issue
Block a user