Commit f209635f authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Clean API

parent 63ac8b3c
......@@ -137,17 +137,17 @@ bool ConsoleHtml::addOperation(const Analitza::Expression& e, const QString& inp
ConsoleModel::ConsoleMode ConsoleHtml::mode() const
{
return m_model->m_mode;
return m_model->mode();
}
void ConsoleHtml::setMode(ConsoleModel::ConsoleMode newMode)
{
m_model->m_mode = newMode;
m_model->setMode(newMode);
}
Analitza::Analyzer* ConsoleHtml::analitza()
{
return &(m_model->a);
return m_model->analyzer();
}
bool ConsoleHtml::loadScript(const QUrl& path)
......@@ -194,7 +194,7 @@ void ConsoleHtml::updateView(const QString& newEntry, const Analitza::Expression
{
QString options;
if (res.isCorrect()) {
Analitza::Analyzer lambdifier(m_model->a.variables());
Analitza::Analyzer lambdifier(m_model->variables());
lambdifier.setExpression(res);
Analitza::Expression lambdaexp = lambdifier.dependenciesToLambda();
lambdifier.setExpression(lambdaexp);
......@@ -263,19 +263,19 @@ void ConsoleHtml::contextMenuEvent(QContextMenuEvent* ev)
void ConsoleHtml::clear()
{
m_model->m_script.clear();
m_model->clear();
m_htmlLog.clear();
updateView(QString(), {});
}
void ConsoleHtml::modifyVariable(const QString& name, const Analitza::Expression& exp)
{
m_model->a.variables()->modify(name, exp);
m_model->variables()->modify(name, exp);
}
void ConsoleHtml::removeVariable(const QString & name)
{
m_model->a.variables()->remove(name);
m_model->variables()->remove(name);
}
void ConsoleHtml::paste()
......
......@@ -26,23 +26,31 @@
class ConsoleModel : public QObject
{
Q_OBJECT
Q_PROPERTY(ConsoleMode mode READ mode WRITE setMode)
public:
/** This enumeration controles the way the console will calculate and show his results. */
enum ConsoleMode {
Evaluation, /**< Simplifies the expression, tries to simplify when sees a variable not defined. */
Calculation /**< Calculates everything, if it finds a not defined variable shows an error. */
};
Q_ENUM(ConsoleMode)
bool addOperation(const Analitza::Expression& e, const QString& input);
bool loadScript(const QString &path);
bool saveScript(const QString &path);
Analitza::Variables* variables() const { return a.variables(); }
ConsoleMode mode() const { return m_mode; }
void setMode(ConsoleMode mode) { m_mode = mode; }
void clear() { m_script.clear(); }
Analitza::Analyzer* analyzer() { return &a; }
Q_SIGNALS:
void errorMessage(const QString &error);
void updateView(const QString &newEntry, const Analitza::Expression &result = {});
public:
private:
Analitza::Analyzer a;
ConsoleMode m_mode = Evaluation;
QVector<Analitza::Expression> m_script;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment