[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kspread/plugins/scripting
From: Sebastian Sauer <mail () dipe ! org>
Date: 2007-06-22 19:57:53
Message-ID: 1182542273.635408.11975.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 679022 by sebsauer:
Added the yweather.py script that provides us the KSpread YWEATHER scripting \
function.
Those function does use the YAHOO! Weather web service to provide a scripting \
function that displays the current temperatur of a defined location.
So, once those script got executed we are able to;
=YWEATHER("GMXX0151";"c")
where the "GMXX0151" is a US zip code or a Location ID.
You are also able to reference a cell where those location is defined;
=YWEATHER("=C13";"c")
FEATURE
CC_MAIL:koffice-devel@kde.org
M +12 -3 ScriptingFunction.cpp
M +3 -0 ScriptingFunction.h
M +1 -0 scripts/CMakeLists.txt
M +8 -0 scripts/scripts.rc
AM scripts/yweather.py
--- trunk/koffice/kspread/plugins/scripting/ScriptingFunction.cpp #679021:679022
@@ -67,6 +67,7 @@
list.append( args[i].asString() );
}
+ funcimpl->m_function->setError( QString() );
funcimpl->m_function->setResult( QVariant() );
if( ! QMetaObject::invokeMethod(funcimpl->m_function, "called", \
QGenericReturnArgument(), Q_ARG(QVariantList, list)) ) { @@ -75,17 +76,22 @@
return err;
}
- //TODO
+ const QString error = funcimpl->m_function->error();
+ if( ! error.isEmpty() ) {
+ KSpread::Value err = KSpread::Value::errorVALUE(); //errorNAME();
+ err.setError( '#' + error );
+ return err;
+ }
+
QVariant result = funcimpl->m_function->result();
if( ! result.isValid() ) {
KSpread::Value err = KSpread::Value::errorVALUE(); //errorNAME();
err.setError( '#' + i18n("No return value.") );
return err;
}
+
kDebug() << "result=" << result.toString() << endl;
return KSpread::Value( result.toString() );
-
- //kDebug() << "result=" << result << endl;
//return KSpread::Value( result );
}
@@ -128,6 +134,7 @@
int maxparam;
QString comment;
QString syntax;
+ QString error;
QVariant result;
QDomDocument document;
@@ -164,6 +171,8 @@
void ScriptingFunction::setSyntax(const QString& syntax) { d->syntax = syntax; }
QVariant ScriptingFunction::result() const { return d->result; }
void ScriptingFunction::setResult(const QVariant& result) { d->result = result; }
+QString ScriptingFunction::error() const { return d->error; }
+void ScriptingFunction::setError(const QString& error) { d->error = error; }
void ScriptingFunction::addExample(const QString& example)
{
--- trunk/koffice/kspread/plugins/scripting/ScriptingFunction.h #679021:679022
@@ -41,6 +41,7 @@
Q_PROPERTY(int maxparam READ maxParam WRITE setMaxParam)
Q_PROPERTY(QString comment READ comment WRITE setComment)
Q_PROPERTY(QString syntax READ syntax WRITE setSyntax)
+ Q_PROPERTY(QString error READ error WRITE setError)
Q_PROPERTY(QVariant result READ result WRITE setResult)
public:
@@ -57,6 +58,8 @@
void setComment(const QString& comment);
QString syntax() const;
void setSyntax(const QString& syntax);
+ QString error() const;
+ void setError(const QString& error = QString());
QVariant result() const;
void setResult(const QVariant& result);
--- trunk/koffice/kspread/plugins/scripting/scripts/CMakeLists.txt #679021:679022
@@ -10,4 +10,5 @@
install(FILES
functions.py
+ yweather.py
DESTINATION ${DATA_INSTALL_DIR}/kspread/scripts/functions)
--- trunk/koffice/kspread/plugins/scripting/scripts/scripts.rc #679021:679022
@@ -27,4 +27,12 @@
interpreter="python"
file="extensions/odfpyexport.py" />
</collection>
+ <collection name="functions" text="Functions" comment="Scripting formula \
functions"> + <script
+ name="yweather"
+ text="Y! Weather"
+ comment="YAHOO! Weather formula function"
+ interpreter="python"
+ file="functions/yweather.py" />
+ </collection>
</KrossScripting>
** trunk/koffice/kspread/plugins/scripting/scripts/yweather.py #property \
svn:executable + *
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic