Fixed built-in functions.
--HG-- branch : develop
This commit is contained in:
parent
730ed3006d
commit
a9c496e065
|
@ -164,6 +164,11 @@ void Calculator::InitVariables(const VContainer *data, const QMap<int, QString>
|
|||
}
|
||||
}
|
||||
|
||||
if (builInFunctions.contains(i.value()))
|
||||
{// We found built-in function
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found == false)
|
||||
{
|
||||
throw qmu::QmuParserError (ecUNASSIGNABLE_TOKEN, i.value(), formula, i.key());
|
||||
|
|
|
@ -414,7 +414,7 @@ const QMap<QString, QSharedPointer<VLineAngle> > VContainer::DataAngleLines() co
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VContainer::IsUnique(const QString &name)
|
||||
{
|
||||
return !uniqueNames.contains(name);
|
||||
return (!uniqueNames.contains(name) && !builInFunctions.contains(name));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -544,7 +544,7 @@ void DialogIncrements::clickedToolButtonAdd()
|
|||
{
|
||||
name = QString(tr("Name_%1")).arg(num);
|
||||
num++;
|
||||
} while (data->VariableExist(name));
|
||||
} while (data->IsUnique(name)==false);
|
||||
|
||||
const quint32 id = data->getNextId();
|
||||
const QString description(tr("Description"));
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "options.h"
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
//Same regexp in pattern.xsd shema file. Don't forget synchronize.
|
||||
const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,]){1,1}([^-*/^+=\\s\\(\\)%:;!.,]){0,}$");
|
||||
|
@ -212,6 +213,9 @@ const QString max_F = QStringLiteral("max");
|
|||
const QString sum_F = QStringLiteral("sum");
|
||||
const QString avg_F = QStringLiteral("avg");
|
||||
|
||||
const QStringList builInFunctions{sin_F, cos_F, tan_F, asin_F, acos_F, atan_F, sinh_F, cosh_F, tanh_F, asinh_F, acosh_F,
|
||||
atanh_F, log2_F, log10_F, log_F, ln_F, exp_F, sqrt_F, sign_F, rint_F, abs_F, min_F, max_F, sum_F, avg_F};
|
||||
|
||||
// Postfix operators
|
||||
const QString cm_Oprt = QStringLiteral("cm");
|
||||
const QString mm_Oprt = QStringLiteral("mm");
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <QtGlobal>
|
||||
|
||||
class QString;
|
||||
class QStringList;
|
||||
|
||||
static const quint32 null_id = 0;
|
||||
|
||||
|
@ -304,6 +305,8 @@ extern const QString max_F;
|
|||
extern const QString sum_F;
|
||||
extern const QString avg_F;
|
||||
|
||||
extern const QStringList builInFunctions;
|
||||
|
||||
// Postfix operators
|
||||
extern const QString cm_Oprt;
|
||||
extern const QString mm_Oprt;
|
||||
|
|
|
@ -79,7 +79,7 @@ void TextDelegate::setEditorData(QWidget *editor, const QModelIndex &index) cons
|
|||
SCASSERT(lineEdit != nullptr);
|
||||
if ( lastText != text && text.isEmpty() == false)
|
||||
{
|
||||
//Here need save text, but method is const, so, we use signal instead.
|
||||
//Here need save text, but this method is const, so, we use signal instead.
|
||||
emit SaveText(text);
|
||||
}
|
||||
lineEdit->setText(text);
|
||||
|
@ -129,7 +129,7 @@ void TextDelegate::commitAndCloseEditor()
|
|||
QLineEdit *lineEdit = qobject_cast<QLineEdit*>(sender());
|
||||
SCASSERT(lineEdit != nullptr);
|
||||
QString text = lineEdit->text();
|
||||
if ( lastText != text && text.isEmpty() == false && data->VariableExist(text) == false)
|
||||
if ( lastText != text && text.isEmpty() == false && data->IsUnique(text))
|
||||
{
|
||||
lastText = text;
|
||||
emit commitData(lineEdit);
|
||||
|
|
|
@ -53,6 +53,7 @@ signals:
|
|||
void SaveText(const QString &text) const;
|
||||
public slots:
|
||||
void commitAndCloseEditor();
|
||||
private slots:
|
||||
void InitText(const QString &text);
|
||||
private:
|
||||
Q_DISABLE_COPY(TextDelegate)
|
||||
|
|
Loading…
Reference in New Issue
Block a user