mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-25 00:54:39 +03:00
Fix #34 New function Currency Format
This commit is contained in:
parent
b5a6baa78c
commit
575fc27563
@ -1214,24 +1214,12 @@ BaseDesignIntf* PageDesignIntf::findDestObject(BaseDesignIntf* item){
|
|||||||
void PageDesignIntf::paste()
|
void PageDesignIntf::paste()
|
||||||
{
|
{
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
if (!selectedItems().isEmpty()) {
|
if (!selectedItems().isEmpty()) {
|
||||||
BaseDesignIntf* destItem = findDestObject(dynamic_cast<BaseDesignIntf*>(selectedItems().at(0)));
|
BaseDesignIntf* destItem = findDestObject(dynamic_cast<BaseDesignIntf*>(selectedItems().at(0)));
|
||||||
if (destItem){
|
if (destItem){
|
||||||
CommandIf::Ptr command = PasteCommand::create(this, clipboard->text(), destItem);
|
CommandIf::Ptr command = PasteCommand::create(this, clipboard->text(), destItem);
|
||||||
saveCommand(command);
|
saveCommand(command);
|
||||||
}
|
}
|
||||||
// BandDesignIntf *band = dynamic_cast<BandDesignIntf *>(selectedItems().at(0));
|
|
||||||
// if (band) {
|
|
||||||
// CommandIf::Ptr command = PasteCommand::create(this, clipboard->text(), band);
|
|
||||||
// saveCommand(command);
|
|
||||||
// } else {
|
|
||||||
// PageItemDesignIntf* page = dynamic_cast<PageItemDesignIntf*>(selectedItems().at(0));
|
|
||||||
// if (page){
|
|
||||||
// CommandIf::Ptr command = PasteCommand::create(this, clipboard->text(), page);
|
|
||||||
// saveCommand(command);
|
|
||||||
// } else {}
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +213,12 @@ QScriptValue numberFormat(QScriptContext* pcontext, QScriptEngine* pengine){
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScriptValue currencyFormat(QScriptContext* pcontext, QScriptEngine* pengine){
|
||||||
|
QVariant value = pcontext->argument(0).toVariant();
|
||||||
|
QString locale = (pcontext->argumentCount()>1)?pcontext->argument(1).toString():QLocale::system().name();
|
||||||
|
return pengine->newVariant(QLocale(locale).toCurrencyString(value.toDouble()));
|
||||||
|
}
|
||||||
|
|
||||||
QScriptValue dateFormat(QScriptContext* pcontext, QScriptEngine* pengine){
|
QScriptValue dateFormat(QScriptContext* pcontext, QScriptEngine* pengine){
|
||||||
QVariant value = pcontext->argument(0).toVariant();
|
QVariant value = pcontext->argument(0).toVariant();
|
||||||
QString format = (pcontext->argumentCount()>1)?pcontext->argument(1).toString().toLatin1():"dd.MM.yyyy";
|
QString format = (pcontext->argumentCount()>1)?pcontext->argument(1).toString().toLatin1():"dd.MM.yyyy";
|
||||||
@ -374,6 +380,7 @@ ScriptEngineManager::ScriptEngineManager()
|
|||||||
addFunction("dateTimeFormat", dateTimeFormat, "DATE&TIME", "dateTimeFormat(\""+tr("Value")+"\",\""+tr("Format")+"\")");
|
addFunction("dateTimeFormat", dateTimeFormat, "DATE&TIME", "dateTimeFormat(\""+tr("Value")+"\",\""+tr("Format")+"\")");
|
||||||
addFunction("date",date,"DATE&TIME","date()");
|
addFunction("date",date,"DATE&TIME","date()");
|
||||||
addFunction("now",now,"DATE&TIME","now()");
|
addFunction("now",now,"DATE&TIME","now()");
|
||||||
|
addFunction("currencyFormat",currencyFormat,"NUMBER","currencyFormat(\""+tr("Value")+",\""+tr("Locale")+"\")");
|
||||||
|
|
||||||
QScriptValue colorCtor = m_scriptEngine->newFunction(constructColor);
|
QScriptValue colorCtor = m_scriptEngine->newFunction(constructColor);
|
||||||
m_scriptEngine->globalObject().setProperty("QColor", colorCtor);
|
m_scriptEngine->globalObject().setProperty("QColor", colorCtor);
|
||||||
|
Loading…
Reference in New Issue
Block a user