summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2017-06-14 16:23:33 +0200
committerAleix Pol <[email protected]>2017-06-14 16:23:33 +0200
commit770616d2522a97ec97b0f03f4db2b161a6da41d8 (patch)
tree523166714bdecad79a4949d19bb4610470399cce
parent239812a93246b07715428ed760cff0ce72b48c8d (diff)
Adapt to changes in analitza
-rw-r--r--mobile/kalgebramobile.cpp5
-rw-r--r--mobile/kalgebramobile.h7
-rw-r--r--mobile/plugins/Console.qml24
-rw-r--r--src/consolemodel.cpp5
-rw-r--r--src/consolemodel.h5
-rw-r--r--src/dictionary.cpp3
-rw-r--r--src/dictionary.h2
-rw-r--r--src/functionedit.cpp2
-rw-r--r--src/functionedit.h6
-rw-r--r--src/varedit.h2
10 files changed, 38 insertions, 23 deletions
diff --git a/mobile/kalgebramobile.cpp b/mobile/kalgebramobile.cpp
index 153bff2..20a3165 100644
--- a/mobile/kalgebramobile.cpp
+++ b/mobile/kalgebramobile.cpp
@@ -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; }
diff --git a/mobile/kalgebramobile.h b/mobile/kalgebramobile.h
index d3cc7dd..df23a27 100644
--- a/mobile/kalgebramobile.h
+++ b/mobile/kalgebramobile.h
@@ -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
diff --git a/mobile/plugins/Console.qml b/mobile/plugins/Console.qml
index a12e301..b9d059a 100644
--- a/mobile/plugins/Console.qml
+++ b/mobile/plugins/Console.qml
@@ -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 {
diff --git a/src/consolemodel.cpp b/src/consolemodel.cpp
index e260af1..f30e89b 100644
--- a/src/consolemodel.cpp
+++ b/src/consolemodel.cpp
@@ -112,3 +112,8 @@ void ConsoleModel::setMode(ConsoleMode mode)
}
}
+void ConsoleModel::setVariables(const QSharedPointer<Analitza::Variables>& vars)
+{
+ qDebug() << "fuuuuuuuu";
+ a.setVariables(vars);
+}
diff --git a/src/consolemodel.h b/src/consolemodel.h
index 468550b..0188750 100644
--- a/src/consolemodel.h
+++ b/src/consolemodel.h
@@ -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:
diff --git a/src/dictionary.cpp b/src/dictionary.cpp
index a345959..0f2dc7c 100644
--- a/src/dictionary.cpp
+++ b/src/dictionary.cpp
@@ -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)
diff --git a/src/dictionary.h b/src/dictionary.h
index d95fd03..a42717e 100644
--- a/src/dictionary.h
+++ b/src/dictionary.h
@@ -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;
};
diff --git a/src/functionedit.cpp b/src/functionedit.cpp
index be9285e..c8a22ce 100644
--- a/src/functionedit.cpp
+++ b/src/functionedit.cpp
@@ -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);
diff --git a/src/functionedit.h b/src/functionedit.h
index f64dc4d..2402c15 100644
--- a/src/functionedit.h
+++ b/src/functionedit.h
@@ -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;
diff --git a/src/varedit.h b/src/varedit.h
index f100dc4..113c370 100644
--- a/src/varedit.h
+++ b/src/varedit.h
@@ -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;