mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 08:34:38 +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()
|
||||
{
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
|
||||
if (!selectedItems().isEmpty()) {
|
||||
BaseDesignIntf* destItem = findDestObject(dynamic_cast<BaseDesignIntf*>(selectedItems().at(0)));
|
||||
if (destItem){
|
||||
CommandIf::Ptr command = PasteCommand::create(this, clipboard->text(), destItem);
|
||||
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;
|
||||
}
|
||||
|
||||
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){
|
||||
QVariant value = pcontext->argument(0).toVariant();
|
||||
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("date",date,"DATE&TIME","date()");
|
||||
addFunction("now",now,"DATE&TIME","now()");
|
||||
addFunction("currencyFormat",currencyFormat,"NUMBER","currencyFormat(\""+tr("Value")+",\""+tr("Locale")+"\")");
|
||||
|
||||
QScriptValue colorCtor = m_scriptEngine->newFunction(constructColor);
|
||||
m_scriptEngine->globalObject().setProperty("QColor", colorCtor);
|
||||
|
Loading…
Reference in New Issue
Block a user