Fix #34 New function Currency Format

This commit is contained in:
Arin Alexander 2016-06-01 21:59:29 +04:00
parent b5a6baa78c
commit 575fc27563
2 changed files with 7 additions and 12 deletions

View File

@ -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 {}
// }
}
}

View File

@ -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);