Commit 85328440 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Simplify code

parent 4f7ed76f
...@@ -15,26 +15,6 @@ KAlgebraPage ...@@ -15,26 +15,6 @@ KAlgebraPage
anchors.fill: parent anchors.fill: parent
spacing: 10 spacing: 10
Rectangle {
color: 'white'
Layout.fillWidth: true
Layout.fillHeight: true
Graph2D {
id: view
anchors {
fill: parent
}
model: app.functionsModel()
Component.onCompleted: {
chosebox.updateGraph();
}
}
}
OperatorsModel {
id: operators
}
Controls.ComboBox { Controls.ComboBox {
anchors { anchors {
left: parent.left left: parent.left
...@@ -43,22 +23,18 @@ KAlgebraPage ...@@ -43,22 +23,18 @@ KAlgebraPage
id: chosebox id: chosebox
currentIndex: 29 currentIndex: 29
activeFocusOnPress: true activeFocusOnPress: true
textRole: "display"
model: ListModel { model: OperatorsModel {
id: cbItems id: operators
Component.onCompleted: {
for (var i=0; i<operators.rowCount(); i++)
cbItems.append( { text: operators.data(operators.index(i,0)) } );
}
} }
function updateGraph() { function updateGraph() {
if(examplelabel!=null) app.functionsModel().clear();
{ view.resetViewport();
app.functionsModel().clear(); view.addFunction(operators.data(operators.index(chosebox.currentIndex,3)), app.variables);
view.resetViewport();
view.addFunction(examplelabel.text,app.variables); console.log("falala", operators.itemData(operators.index(chosebox.currentIndex,3)))
}
} }
onCurrentIndexChanged: { onCurrentIndexChanged: {
...@@ -71,10 +47,31 @@ KAlgebraPage ...@@ -71,10 +47,31 @@ KAlgebraPage
columns: 2 columns: 2
Layout.fillWidth: true Layout.fillWidth: true
Label { text: operators.headerData(0,Qt.Horizontal) } Label { id: namelabel; text: operators.data(operators.index(chosebox.currentIndex,0)) } Label { text: operators.headerData(0,Qt.Horizontal) }
Label { text: operators.headerData(1,Qt.Horizontal) } Label { id: desclabel; text: operators.data(operators.index(chosebox.currentIndex,1)) } Label { text: operators.data(operators.index(chosebox.currentIndex,0)) }
Label { text: operators.headerData(2,Qt.Horizontal) } Label { id: paramslabel; text: operators.data(operators.index(chosebox.currentIndex,2)) } Label { text: operators.headerData(1,Qt.Horizontal) }
Label { text: operators.headerData(3,Qt.Horizontal) } Label { id: examplelabel; text: operators.data(operators.index(chosebox.currentIndex,3)) } Label { text: operators.data(operators.index(chosebox.currentIndex,1)) }
Label { text: operators.headerData(2,Qt.Horizontal) }
Label { text: operators.data(operators.index(chosebox.currentIndex,2)) }
Label { text: operators.headerData(3,Qt.Horizontal) }
Label { text: operators.data(operators.index(chosebox.currentIndex,3)) }
}
Rectangle {
color: 'white'
Layout.fillWidth: true
Layout.fillHeight: true
Graph2D {
id: view
anchors {
fill: parent
}
model: app.functionsModel()
Component.onCompleted: {
chosebox.updateGraph();
}
}
} }
} }
} }
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