|
@@ -3663,6 +3663,7 @@ QScriptValue setFont(QScriptContext *context, QScriptEngine *engine);
|
3663
|
3663
|
QScriptValue annotationFromRecord(QScriptContext *context,
|
3664
|
3664
|
QScriptEngine *engine);
|
3665
|
3665
|
QScriptValue setTabOrder(QScriptContext *context, QScriptEngine *engine);
|
|
3666
|
+QScriptValue saveFileFromDatabase(QScriptContext *context, QScriptEngine *engine);
|
3666
|
3667
|
|
3667
|
3668
|
@ These functions are passed to the scripting engine.
|
3668
|
3669
|
|
|
@@ -3676,6 +3677,8 @@ engine->globalObject().setProperty("annotationFromRecord",
|
3676
|
3677
|
engine->newFunction(annotationFromRecord));
|
3677
|
3678
|
engine->globalObject().setProperty("setTabOrder",
|
3678
|
3679
|
engine->newFunction(setTabOrder));
|
|
3680
|
+engine->globalObject().setProperty("saveFileFromDatabase",
|
|
3681
|
+ engine->newFunction(saveFileFromDatabase));
|
3679
|
3682
|
|
3680
|
3683
|
@ These functions are not part of an object. They expect a string specifying
|
3681
|
3684
|
the path to a file and return a string with either the name of the file without
|
|
@@ -3697,6 +3700,27 @@ QScriptValue dir(QScriptContext *context, QScriptEngine *engine)
|
3697
|
3700
|
return retval;
|
3698
|
3701
|
}
|
3699
|
3702
|
|
|
3703
|
+@ This function takes a file ID and a file name and copies file data stored in
|
|
3704
|
+the database out to the file system.
|
|
3705
|
+
|
|
3706
|
+@<Functions for scripting@>=
|
|
3707
|
+QScriptValue saveFileFromDatabase(QScriptContext *context, QScriptEngine *engine)
|
|
3708
|
+{
|
|
3709
|
+ SqlQueryConnection h;
|
|
3710
|
+ QSqlQuery *query = h.operator->();
|
|
3711
|
+ QString q = "SELECT file FROM files WHERE id = :file";
|
|
3712
|
+ query->prepare(q);
|
|
3713
|
+ query->bindValue(":file", argument<int>(0, context));
|
|
3714
|
+ query->exec();
|
|
3715
|
+ query->next();
|
|
3716
|
+ QByteArray array = query->value(0).toByteArray();
|
|
3717
|
+ QFile file(argument<QString>(1, context));
|
|
3718
|
+ file.open(QIODevice::WriteOnly);
|
|
3719
|
+ file.write(array);
|
|
3720
|
+ file.close();
|
|
3721
|
+ return QScriptValue();
|
|
3722
|
+}
|
|
3723
|
+
|
3700
|
3724
|
@ This function takes a string representing a SQL array and returns an array
|
3701
|
3725
|
value.
|
3702
|
3726
|
|