[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdereview/kalgebra/src
From: Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date: 2007-05-17 0:12:15
Message-ID: 1179360735.334952.13266.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 665446 by apol:
NEW. New tab to help people use KAlgebra with all the function names.
M +1 -0 CMakeLists.txt
M +7 -0 algebra.cpp
A dictionary.cpp [License: GPL (v2+)]
A dictionary.h [License: GPL (v2+)]
M +1 -1 object.h
M +3 -3 operator.cpp
M +247 -7 operatorsmodel.cpp
M +7 -2 operatorsmodel.h
--- trunk/kdereview/kalgebra/src/CMakeLists.txt #665445:665446
@@ -20,6 +20,7 @@
variables.cpp
graph2d.cpp
operatorsmodel.cpp
+ dictionary.cpp
)
kde4_automoc( ${kalgebra_SRCS} )
--- trunk/kdereview/kalgebra/src/algebra.cpp #665445:665446
@@ -24,6 +24,7 @@
#include "graph2d.h"
#include "graph3d.h"
#include "variables.h"
+#include "dictionary.h"
#include <QVBoxLayout>
#include <QLayout>
@@ -189,6 +190,11 @@
////////////
//////EO3D Graph
+
+ //Dictionary tab
+ Dictionary *dic = new Dictionary(tabs);
+ tabs->addTab(dic, i18n("&Dictionary"));
+ //EODictionary
//Ego's reminder
menuBar()->addMenu(helpMenu());
@@ -365,6 +371,7 @@
case 2:
t_exp->setFocus();
break;
+ case 3:
default:
break;
}
--- trunk/kdereview/kalgebra/src/object.h #665445:665446
@@ -71,7 +71,7 @@
sinh, cosh, tanh,
sech, csch, coth,
arcsin, arccos, arctan,
- arccot, arcoth,
+ arccot, arccoth,
arccosh, arccsc, arccsch,
arcsec, arcsech, arcsinh, arctanh,
exp, ln, log,
--- trunk/kdereview/kalgebra/src/operator.cpp #665445:665446
@@ -22,7 +22,7 @@
"onone",
"plus", "times", "minus", "divide", "quotient",
"power", "root", "factorial",
- "_and", "_or", "_xor", "_not",
+ "and", "or", "xor", "not",
"gcd", "lcm", "rem", "factorof",
"max", "min",
"lt", "gt", "eq", "neq", "leq", "geq", "implies",
@@ -103,7 +103,7 @@
else if(e=="arctan") ret=arctan;
else if(e=="arccos") ret=arccos;
else if(e=="arccot") ret=arccot;
- else if(e=="arcoth") ret=arcoth;
+ else if(e=="arccoth") ret=arccoth;
else if(e=="arccosh") ret=arccosh;
else if(e=="arccsc" ) ret=arccsc;
else if(e=="arccsch") ret=arccsch;
@@ -196,7 +196,7 @@
case arccos:
case arctan:
case arccot:
- case arcoth:
+ case arccoth:
case arccosh:
case arccsc:
case arccsch:
--- trunk/kdereview/kalgebra/src/operatorsmodel.cpp #665445:665446
@@ -1,16 +1,256 @@
+/*************************************************************************************
+ * Copyright (C) 2007 by Aleix Pol <aleixpol@gmail.com> \
* + * \
* + * This program is free software; you can redistribute it and/or \
* + * modify it under the terms of the GNU General Public License \
* + * as published by the Free Software Foundation; either version 2 \
* + * of the License, or (at your option) any later version. \
* + * \
* + * This program is distributed in the hope that it will be useful, \
* + * but WITHOUT ANY WARRANTY; without even the implied warranty of \
* + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \
* + * GNU General Public License for more details. \
* + * \
* + * You should have received a copy of the GNU General Public License \
* + * along with this program; if not, write to the Free Software \
* + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA \
* + *************************************************************************************/
+
#include "operatorsmodel.h"
-
#include "operator.h"
+#include <KLocale>
-#define KEYWORDNUM 200
-OperatorsModel::OperatorsModel(int num, QObject *parent) : QStandardItemModel(num, \
4, parent), m_count(Object::nOfOps) +OperatorsModel::OperatorsModel(int num, QObject \
*parent) : QStandardItemModel(num, 3, parent), m_count(Object::nOfOps) {
- for (int i=0; i<m_count; ++i) {
- setData(index(i, 0), Operator::m_words[i]);
+ setHeaderData(0, Qt::Horizontal, i18n("Name"));
+ setHeaderData(1, Qt::Horizontal, i18n("Description"));
+ setHeaderData(2, Qt::Horizontal, i18n("Parameters"));
+
+ for (int i=1; i<m_count; ++i) {
+ setData(index(i-1, 0), Operator::m_words[i]);
+ setData(index(i-1, 1), description((Object::OperatorType) i));
+ setData(index(i-1, 2), example((Object::OperatorType) i));
}
}
+QString OperatorsModel::example(Object::OperatorType o)
+{
+ int op = Operator::nparams(o);
+ QString funcname=Operator::m_words[o];
+ if(op == -1) {
+ return QString("%1(..., parameters, ...)").arg(funcname);
+ } else {
+ QString sample = QString("%1(").arg(funcname);
+ for(int i=0; i<op; ++i) {
+ sample += QString("par%1").arg(i+1);
+ if(i<op-1)
+ sample += ", ";
+ }
+ return sample+')';
+ }
+}
+
+QString OperatorsModel::description(Object::OperatorType o)
+{
+ QString s;
+ switch(o) {
+ case Object::plus:
+ s = i18n("Addition");
+ break;
+ case Object::times:
+ s = i18n("Multiplication");
+ break;
+ case Object::divide:
+ s = i18n("Division");
+ break;
+ case Object::minus:
+ s = i18n("Subtraction");
+ break;
+ case Object::power:
+ s = i18n("Power");
+ break;
+ case Object::rem:
+ s = i18n("Reminder");
+ break;
+ case Object::quotient:
+ s = i18n("Quotient");
+ break;
+ case Object::factorof:
+ s = i18n("The factor of");
+ break;
+ case Object::factorial:
+ s = i18n("Factorial. factorial(n)=n!");
+ break;
+ case Object::sin:
+ s = i18n("Sine");
+ break;
+ case Object::cos:
+ s = i18n("Cosine");
+ break;
+ case Object::tan:
+ s = i18n("Tangent");
+ break;
+ case Object::sec:
+ s = i18n("Secant");
+ break;
+ case Object::csc:
+ s = i18n("Cosecant");
+ break;
+ case Object::cot:
+ s = i18n("Cotangent");
+ break;
+ case Object::sinh:
+ s = i18n("Hyperbolic sinus");
+ break;
+ case Object::cosh:
+ s = i18n("Hyperbolic sinus");
+ break;
+ case Object::tanh:
+ s = i18n("Hyperbolic tangent");
+ break;
+ case Object::sech:
+ s = i18n("Hyperbolic secant");
+ break;
+ case Object::csch:
+ s = i18n("Hyperbolic cosecant");
+ break;
+ case Object::coth:
+ s = i18n("Hyperbolic cotangent");
+ break;
+ case Object::arcsin:
+ s = i18n("Arc sine");
+ break;
+ case Object::arccos:
+ s = i18n("Arc cosine");
+ break;
+ case Object::arctan:
+ s = i18n("Arc tangent");
+ break;
+ case Object::arccot:
+ s = i18n("Arc cotangent");
+ break;
+ case Object::arccoth:
+ s = i18n("Hyperbolic arc cotangent");
+ break;
+ case Object::arctanh:
+ s = i18n("Hyperbolic arc tangent");
+ break;
+ case Object::sum:
+ s = i18n("Summatory");
+ break;
+ case Object::product:
+ s = i18n("Productory");
+ break;
+ case Object::diff:
+ s = i18n("Differentiation");
+ break;
+ case Object::arcsinh:
+ s = i18n("Hyperbolic arc sine");
+ break;
+ case Object::arccosh:
+ s = i18n("Hyperbolic arc cosine");
+ break;
+ case Object::arccsc:
+ s = i18n("Arc cosecant");
+ break;
+ case Object::arccsch:
+ s = i18n("Hyperbolic arc cosecant");
+ break;
+ case Object::arcsec:
+ s = i18n("Arc secant");
+ break;
+ case Object::arcsech:
+ s = i18n("Hyperbolic arc secant");
+ break;
+ case Object::exp:
+ s = i18n("Exponent (e^x)");
+ break;
+ case Object::ln:
+ s = i18n("Base-e logarithm");
+ break;
+ case Object::log:
+ s = i18n("Base-10 logarithm");
+ break;
+ case Object::abs:
+ s = i18n("Absolute value. abs(n)=|n|");
+ break;
+ case Object::conjugate:
+ s = i18n("Conjugate");
+ break;
+ case Object::arg:
+ s = "---";//i18n("Arg?");
+ break;
+ case Object::real:
+ s = i18n("Real");
+ break;
+ case Object::imaginary:
+ s = i18n("Imaginary");
+ break;
+ case Object::floor:
+ s = i18n("Floor value. floor(n)=⌊n⌋");
+ break;
+ case Object::ceiling:
+ s = i18n("Ceil value. abs(n)=⌈n⌉");
+ break;
+ case Object::min:
+ s = i18n("Minimum");
+ break;
+ case Object::max:
+ s = i18n("Maximum");
+ break;
+ case Object::gt:
+ s = i18n("Greater than. gt(a,b)=a>b");
+ break;
+ case Object::lt:
+ s = i18n("Less than. lt(a,b)=a<b");
+ break;
+ case Object::eq:
+ s = i18n("Equal. eq(a,b) = a=b");
+ break;
+ case Object::approx:
+ s = i18n("Approximation approx(a)=a ±n");
+ break;
+ case Object::neq:
+ s = i18n("Greater than. neq(a,b)=a≠b");
+ break;
+ case Object::geq:
+ s = i18n("Greater or equal. gt(a,b)=a>b");
+ break;
+ case Object::leq:
+ s = i18n("Less or equal. gt(a,b)=a>b");
+ break;
+ case Object::_and:
+ s = i18n("Boolean and");
+ break;
+ case Object::_not:
+ s = i18n("Boolean not");
+ break;
+ case Object::_or:
+ s = i18n("Boolean or");
+ break;
+ case Object::_xor:
+ s = i18n("Boolean xor");
+ break;
+ case Object::implies:
+ s = i18n("Boolean implication");
+ break;
+ case Object::gcd:
+ s = i18n("Greatest common divisor");
+ break;
+ case Object::lcm:
+ s = i18n("Least common multiple");
+ break;
+ case Object::root:
+ s = i18n("Root");
+ break;
+ default:
+ break;
+ }
+ return s;
+}
+
+
/*QString OperatorsModel::operToString(const Operator& op) const
{
QStandardItem *it;
@@ -19,7 +259,7 @@
it=item(i,2);
if(it!=NULL && it->data(Qt::EditRole).toInt()==op.operatorType()) {
return item(i,0)->data(Qt::EditRole).toString();
- }
- }
+}
+}
return QString();
}*/
--- trunk/kdereview/kalgebra/src/operatorsmodel.h #665445:665446
@@ -20,9 +20,8 @@
#define OPERATORSMODEL_H
#include <QStandardItemModel>
+#include "object.h"
-class Operator;
-
/** Operators model is a model class that has a relation of all operators string \
with their OperatorType. */ class OperatorsModel : public QStandardItemModel
{
@@ -32,6 +31,12 @@
/** Returns how many operators we have. */
int count() const { return m_count; }
+
+ /** Returns the description of the @p o operator. */
+ static QString description(Object::OperatorType o);
+
+ /** Returns the description of the @p o operator. */
+ static QString example(Object::OperatorType o);
private:
int m_count;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic