• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kalgebra

  • sources
  • kde-4.14
  • kdeedu
  • kalgebra
  • mobile
  • plugins
Tables.qml
Go to the documentation of this file.
1 import QtQuick 1.0
2 import org.kde.analitza 1.0
3 import widgets 1.0
4 
5 KAlgebraPage
6 {
7  ListModel { id: resultsModel }
8  Analitza {
9  id: a
10  variables: app.variables
11  }
12 
13  function calculateTable() {
14  resultsModel.clear();
15 
16  var tmp = a.unusedVariableName()
17  var ret = a.insertVariable(tmp, a.dependenciesToLambda(input.text))
18  var ffrom=from.value, fto=to.value, fstep=step.value;
19 // console.log("chancho (" + ffrom + ", " + fto + " : " + fstep + ") " + ret);
20  if((fto-ffrom>0)!=(fstep>0)) {
21  fstep *= -1;
22  step = fstep
23  }
24 // console.log("chancho2 (" + ffrom + ", " + fto + " : " + fstep + ") " + ret);
25 
26  if(fstep==0) {
27  resultsModel.append( { element: "Errors: The step can't be 0" } );
28  } else if(!a.isCorrect) {
29  if(ret)
30  resultsModel.append( { element: "Errors: "+ret } );
31  else
32  resultsModel.append( { element: "Errors: "+a.errors } );
33  } else {
34  for (var i=ffrom; i<=fto && a.isCorrect; i+=fstep) {
35  var args = new Array();
36  args[0]=i;
37  // console.log("!!! " + i);
38  var expr = a.executeFunc(tmp, args);
39  resultsModel.append( { element: i +" = "+ expr.expression } );
40  }
41  }
42 
43  a.removeVariable(tmp);
44  }
45 
46  Column {
47  id: inputcol
48 
49  anchors {
50  top: parent.top
51  left: parent.left
52  right: parent.right
53  }
54  spacing: 10
55 
56  Grid {
57  id: ins
58  columns: 2
59  spacing: 5
60  width: parent.width
61 
62  Label { text: "Input:" } ExpressionInput { id: input; text: "sin x"; width: ins.width-input.x-5; onAccepted: calculateTable() }
63  Label { text: "From:" } RealInput { id: from; value: 0; width: ins.width-from.x-5; onAccepted: calculateTable() }
64  Label { text: "To:" } RealInput { id: to; value: 10; width: ins.width-to.x-5; onAccepted: calculateTable() }
65  Label { text: "Step:" } RealInput { id: step; value: 1; width: ins.width-step.x-5; onAccepted: calculateTable() }
66  }
67 
68  Button {
69  text: "Go!"
70 
71  onClicked: calculateTable()
72  }
73  }
74 
75  SimpleListView {
76  width: parent.width
77  anchors {
78  top: inputcol.bottom
79  bottom: parent.bottom
80  topMargin: 5
81  }
82  currentIndex: -1
83 
84  model: resultsModel
85  role: "element"
86  title: "Results:"
87  }
88 }
Button
Definition: desktop/Button.qml:2
Label
Definition: desktop/Label.qml:3
RealInput
Definition: desktop/RealInput.qml:2
SimpleListView
Definition: desktop/SimpleListView.qml:2
ExpressionInput
Definition: desktop/ExpressionInput.qml:2
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:11:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalgebra

Skip menu "kalgebra"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal