kspread
ScriptingFunction Class Reference
The ScriptingFunction class provides access to the KSpread::Function functionality to deal with formula functions that are written in a scripting language like Python or Ruby. More...
#include <ScriptingFunction.h>

Public Slots | |
| void | addExample (const QString &example) |
| void | addParameter (const QString &typeName, const QString &comment) |
| bool | registerFunction () |
Signals | |
| void | called (QVariantList args) |
Public Member Functions | |
| ScriptingFunction (QObject *parent) | |
| virtual | ~ScriptingFunction () |
| QString | comment () const |
| QString | error () const |
| int | maxParam () const |
| int | minParam () const |
| QString | name () const |
| QVariant | result () const |
| void | setComment (const QString &comment) |
| void | setError (const QString &error=QString()) |
| void | setMaxParam (int maxparam) |
| void | setMinParam (int minparam) |
| void | setName (const QString &name) |
| void | setResult (const QVariant &result) |
| void | setSyntax (const QString &syntax) |
| void | setTypeName (const QString &typeName) |
| QString | syntax () const |
| QString | typeName () const |
Properties | |
| QString | comment |
| QString | error |
| int | maxparam |
| int | minparam |
| QString | name |
| QVariant | result |
| QString | syntax |
| QString | typeName |
Detailed Description
The ScriptingFunction class provides access to the KSpread::Function functionality to deal with formula functions that are written in a scripting language like Python or Ruby.
The following sample scripting formula function written in python displays the current datetime.
import time, Kross, KSpread func = KSpread.function("PYTIME") func.minparam = 0 func.maxparam = 1 func.comment = "The PYTIME() function displays the current datetime." func.syntax = "PYTIME(string)" func.addParameter("String", "The datetime format string.") func.addExample("PYTIME()") func.addExample("PYTIME(\"%Y-%M-%d %H:%M.%S\")") def update(args): try: func.result = time.strftime(args[0] or "%H:%M.%S") except: func.error = "Invalid format" func.connect("called(QVariantList)", update) func.registerFunction()
Definition at line 53 of file ScriptingFunction.h.
Constructor & Destructor Documentation
| ScriptingFunction::ScriptingFunction | ( | QObject * | parent | ) | [explicit] |
Definition at line 197 of file ScriptingFunction.cpp.
| ScriptingFunction::~ScriptingFunction | ( | ) | [virtual] |
Definition at line 207 of file ScriptingFunction.cpp.
Member Function Documentation
| void ScriptingFunction::addExample | ( | const QString & | example | ) | [slot] |
Add an example to demonstrate the usage of the function.
Definition at line 230 of file ScriptingFunction.cpp.
Add details about a parameter the function may expect.
Valid values for typeName are String, Int, Float, Double, Boolean, Date, Range or Any while the comment is a describing string.
Definition at line 237 of file ScriptingFunction.cpp.
| void ScriptingFunction::called | ( | QVariantList | args | ) | [signal] |
This signal is emitted if the function got called.
| QString ScriptingFunction::comment | ( | ) | const |
- Returns:
- the comment that describes what the function does.
| QString ScriptingFunction::error | ( | ) | const |
- Returns:
- the error-message if there was an error.
| int ScriptingFunction::maxParam | ( | ) | const |
- Returns:
- the maximum number of parameters the function expects.
Definition at line 219 of file ScriptingFunction.cpp.
| int ScriptingFunction::minParam | ( | ) | const |
- Returns:
- the minimum number of parameters the function expects.
Definition at line 217 of file ScriptingFunction.cpp.
| QString ScriptingFunction::name | ( | ) | const |
- Returns:
- the name the function has.
| bool ScriptingFunction::registerFunction | ( | ) | [slot] |
Register this function.
Definition at line 249 of file ScriptingFunction.cpp.
| QVariant ScriptingFunction::result | ( | ) | const |
- Returns:
- the result of the function call.
| void ScriptingFunction::setComment | ( | const QString & | comment | ) |
Set the comment that describes what the function does.
Definition at line 222 of file ScriptingFunction.cpp.
Set the error-message.
Definition at line 228 of file ScriptingFunction.cpp.
| void ScriptingFunction::setMaxParam | ( | int | maxparam | ) |
Set the maximum number of parameters the function expects.
Definition at line 220 of file ScriptingFunction.cpp.
| void ScriptingFunction::setMinParam | ( | int | minparam | ) |
Set the minimum number of parameters the function expects.
Definition at line 218 of file ScriptingFunction.cpp.
| void ScriptingFunction::setName | ( | const QString & | name | ) |
Set the name the function has.
Definition at line 214 of file ScriptingFunction.cpp.
| void ScriptingFunction::setResult | ( | const QVariant & | result | ) |
Set the result of the function call.
Definition at line 226 of file ScriptingFunction.cpp.
| void ScriptingFunction::setSyntax | ( | const QString & | syntax | ) |
Set the syntax string the function looks like.
Definition at line 224 of file ScriptingFunction.cpp.
| void ScriptingFunction::setTypeName | ( | const QString & | typeName | ) |
Set the name the function has.
Definition at line 216 of file ScriptingFunction.cpp.
| QString ScriptingFunction::syntax | ( | ) | const |
- Returns:
- the syntax string the function looks like.
| QString ScriptingFunction::typeName | ( | ) | const |
- Returns:
- the name the function has.
Property Documentation
QString ScriptingFunction::comment [read, write] |
The comment that describes what the function does.
Definition at line 80 of file ScriptingFunction.h.
QString ScriptingFunction::error [read, write] |
The error-message if there was an error.
Definition at line 90 of file ScriptingFunction.h.
int ScriptingFunction::maxparam [read, write] |
Maximum number of parameters the function expects.
Definition at line 75 of file ScriptingFunction.h.
int ScriptingFunction::minparam [read, write] |
Minimum number of parameters the function expects.
Definition at line 70 of file ScriptingFunction.h.
QString ScriptingFunction::name [read] |
The name the function has.
Definition at line 60 of file ScriptingFunction.h.
QVariant ScriptingFunction::result [read, write] |
The result of the function call.
Definition at line 95 of file ScriptingFunction.h.
QString ScriptingFunction::syntax [read, write] |
The syntax string the function looks like.
Definition at line 85 of file ScriptingFunction.h.
QString ScriptingFunction::typeName [read, write] |
Set the name of the return-type.
Could be e.g. "String", "int", "bool" or "float".
Definition at line 65 of file ScriptingFunction.h.
The documentation for this class was generated from the following files:
