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

Simplify code

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