Commit 770616d2 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Adapt to changes in analitza

parent 239812a9
......@@ -32,6 +32,8 @@ using namespace Analitza;
KAlgebraMobile* KAlgebraMobile::s_self=0;
KAlgebraMobile* KAlgebraMobile::self() { return s_self; }
Q_DECLARE_METATYPE(QSharedPointer<Analitza::Variables>)
KAlgebraMobile::KAlgebraMobile(QObject* parent)
: QObject(parent), m_functionsModel(0), m_vars(new Analitza::Variables)
{
......@@ -41,6 +43,7 @@ KAlgebraMobile::KAlgebraMobile(QObject* parent)
qmlRegisterType<PluginsModel>("org.kde.kalgebra.mobile", 1, 0, "PluginsModel");
qmlRegisterType<ConsoleModel>("org.kde.kalgebra.mobile", 1, 0, "ConsoleModel");
qmlRegisterType<QAbstractItemModel>();
qRegisterMetaType<QSharedPointer<Analitza::Variables>>("QSharedPointer<Analitza::Variables>");
qmlRegisterUncreatableType<Analitza::Expression>("org.kde.kalgebra.mobile", 1, 0, "Expression", "because");
}
......@@ -84,4 +87,4 @@ void KAlgebraMobile::functionModified(const QModelIndex& idxA, const QModelIndex
} //else TODO: figure out how to control a "rename"
}
Analitza::Variables* KAlgebraMobile::variables() const { return m_vars; }
QSharedPointer<Analitza::Variables> KAlgebraMobile::variables() const { return m_vars; }
......@@ -20,6 +20,7 @@
#define KALGEBRAMOBILE_H
#include <QObject>
#include <QSharedPointer>
class QModelIndex;
namespace Analitza {
......@@ -30,7 +31,7 @@ namespace Analitza {
class KAlgebraMobile : public QObject
{
Q_OBJECT
Q_PROPERTY(Analitza::Variables* variables READ variables NOTIFY variablesChanged)
Q_PROPERTY(QSharedPointer<Analitza::Variables> variables READ variables NOTIFY variablesChanged)
public:
explicit KAlgebraMobile(QObject* parent=0);
......@@ -39,7 +40,7 @@ class KAlgebraMobile : public QObject
public Q_SLOTS:
Analitza::PlotsModel* functionsModel();
Analitza::Variables* variables() const;
QSharedPointer<Analitza::Variables> variables() const;
private Q_SLOTS:
void functionRemoved(const QModelIndex& parent, int start, int end);
......@@ -53,7 +54,7 @@ class KAlgebraMobile : public QObject
static KAlgebraMobile* s_self;
Analitza::PlotsModel* m_functionsModel;
Analitza::Variables* m_vars;
QSharedPointer<Analitza::Variables> m_vars;
};
#endif // KALGEBRAMOBILE_H
......@@ -11,8 +11,12 @@ KAlgebraPage
ConsoleModel {
id: consoleModel
// variables: app.variables
mode: ConsoleModel.Evaluate
Component.onCompleted: {
for(var v in app)
console.log("lalala", v)
console.log("xxx", app.variables)
}
variables: app.variables
onErrorMessage: {
itemModel.insert(0, { result: error })
input.selectAll()
......@@ -33,22 +37,24 @@ KAlgebraPage
property var proceed
}
function proceedLoadScript() {
consoleModel.loadScript(fileDialog.fileUrl)
}
contextualActions: [
Action {
text: i18n("Load Script...")
onTriggered: {
fileDialog.title = text
fileDialog.proceed = page.proceedLoadScript
var v = fileDialog.open()
console.log("opened...", v)
fileDialog.proceed = function() { consoleModel.loadScript(fileDialog.fileUrl) }
fileDialog.nameFilters = [ i18n("Script (*.kal)") ]
fileDialog.open()
}
},
Action {
text: i18n("Save Script...")
onTriggered: {
fileDialog.title = text
fileDialog.proceed = function() { consoleModel.saveScript(fileDialog.fileUrl) }
fileDialog.nameFilters = [ i18n("Script (*.kal)") ]
fileDialog.open()
}
},
//TODO: Recent scripts
Action {
......
......@@ -112,3 +112,8 @@ void ConsoleModel::setMode(ConsoleMode mode)
}
}
void ConsoleModel::setVariables(const QSharedPointer<Analitza::Variables>& vars)
{
qDebug() << "fuuuuuuuu";
a.setVariables(vars);
}
......@@ -27,7 +27,7 @@ class ConsoleModel : public QObject
{
Q_OBJECT
Q_PROPERTY(ConsoleMode mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY(Analitza::Variables* variables READ variables)
Q_PROPERTY(QSharedPointer<Analitza::Variables> variables READ variables WRITE setVariables)
public:
ConsoleModel(QObject* parent = nullptr, bool preferString = true);
......@@ -48,7 +48,8 @@ public:
ConsoleMode mode() const { return m_mode; }
void setMode(ConsoleMode mode);
Analitza::Variables* variables() const { return a.variables(); }
QSharedPointer<Analitza::Variables> variables() const { return a.variables(); }
void setVariables(const QSharedPointer<Analitza::Variables> &vars);
Analitza::Analyzer* analyzer() { return &a; }
Q_SIGNALS:
......
......@@ -39,7 +39,7 @@ Dictionary::Dictionary(QWidget *p) : QWidget(p)
m_sortProxy->sort(2, Qt::AscendingOrder);
m_sortProxy->setFilterKeyColumn(2);
m_vars = new Analitza::Variables;
m_vars = QSharedPointer<Analitza::Variables>(new Analitza::Variables);
QGroupBox *descr=new QGroupBox(i18n("Information"), this);
descr->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
......@@ -79,7 +79,6 @@ Dictionary::Dictionary(QWidget *p) : QWidget(p)
Dictionary::~Dictionary()
{
delete m_vars;
}
void Dictionary::activated(const QModelIndex& idx, const QModelIndex& prev)
......
......@@ -58,7 +58,7 @@ Q_OBJECT
Analitza::PlotsView2D *m_graph;
Analitza::PlotsModel *m_funcs;
OperatorsModel *m_ops;
Analitza::Variables* m_vars;
QSharedPointer<Analitza::Variables> m_vars;
QSortFilterProxyModel *m_sortProxy;
};
......
......@@ -163,7 +163,7 @@ void FunctionEdit::colorChange(int)
setColor(m_color->color());
}
static double calcExp(const Analitza::Expression& exp, Analitza::Variables* v, bool* corr)
static double calcExp(const Analitza::Expression& exp, const QSharedPointer<Analitza::Variables>& v, bool* corr)
{
Q_ASSERT(exp.isCorrect());
Analitza::Analyzer d(v);
......
......@@ -79,9 +79,9 @@ public:
QString name() const { return m_name->text(); }
/** Sets the variables class to be used with the graph functions*/
void setVariables(Analitza::Variables* v) { m_vars=v; }
void setVariables(const QSharedPointer<Analitza::Variables> &v) { m_vars=v; }
Analitza::Variables* variables() const { return m_vars; }
QSharedPointer<Analitza::Variables> variables() const { return m_vars; }
void setOptionsShown(bool shown);
......@@ -119,7 +119,7 @@ private:
Analitza::PlotsView2D *m_graph;
KColorCombo *m_color;
Analitza::PlotsModel *m_funcsModel;
Analitza::Variables* m_vars = nullptr;
QSharedPointer<Analitza::Variables> m_vars;
bool m_modmode;
QTabWidget* m_viewTabs;
......
......@@ -58,7 +58,7 @@ class VarEdit : public QDialog
Analitza::ExpressionEdit *m_exp;
QLabel *m_valid;
Analitza::Variables *vars;
QSharedPointer<Analitza::Variables> vars;
bool m_correct;
QString m_var;
QDialogButtonBox* m_buttonBox;
......
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