mirror of
https://gitlab.com/eql/EQL5.git
synced 2025-12-28 04:41:34 -08:00
add new function QVARIANT-FROM-VALUE, needed in QML:QML-SET ("quick" examples)
This commit is contained in:
parent
881939b2d9
commit
b33a987248
10 changed files with 31 additions and 6 deletions
|
|
@ -596,6 +596,14 @@ Takes C++ code from a file generated by the <code>uic</code> user interface comp
|
|||
Converts a Unicode pathname to a simple ECL base string, using <code>QString::toUtf8()</code>.<br>Depending on the OS (namely OSX, Linux), this is necessary if you get a filename from Qt and want to use it in ECL.<br><br>See also <b>QLOCAL8BIT</b>.
|
||||
<br>
|
||||
<br><br>
|
||||
<b>QVARIANT-FROM-VALUE (value type-name)</b>
|
||||
<br><br>
|
||||
Constructs a new <code>QVariant</code>. This is needed for types that don't have a direct constructor, like <code>QPixmap</code>, or primitive types, like <code>QSize</code>.
|
||||
<br>
|
||||
<pre>
|
||||
(qvariant-from-value "red" "QColor")
|
||||
</pre>
|
||||
<br><br>
|
||||
<b>QVARIANT-VALUE (object)</b>
|
||||
<br><br>
|
||||
Returns the Lisp value of the <code>QVariant</code> object.
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@
|
|||
"qui-class"
|
||||
"qui-names"
|
||||
"qutf8"
|
||||
"qvariant-from-value"
|
||||
"qvariant-value"
|
||||
"qversion"
|
||||
"tr")
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@
|
|||
(find-qml-object object-name)
|
||||
property-name))
|
||||
(x:when-it (|propertyTypeName| property)
|
||||
(qlet ((variant (qnew (format nil "QVariant(~A)" x:it) value)))
|
||||
(qlet ((variant (qvariant-from-value value x:it)))
|
||||
(|write| property variant)))))
|
||||
|
||||
;;; JS
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
(require :qml-lisp "qml-lisp")
|
||||
|
||||
(defun run ()
|
||||
;; *quick-view* can be either a QQuickView or a QQuickWidget
|
||||
(setf qml:*quick-view* (qnew "QQuickView(QUrl)"
|
||||
(|fromLocalFile.QUrl| "qml/example.qml")))
|
||||
(|setResizeMode| qml:*quick-view* |QQuickView.SizeRootObjectToView|)
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@
|
|||
(find-qml-object object-name)
|
||||
property-name))
|
||||
(x:when-it (|propertyTypeName| property)
|
||||
(qlet ((variant (qnew (format nil "QVariant(~A)" x:it) value)))
|
||||
(qlet ((variant (qvariant-from-value value x:it)))
|
||||
(|write| property variant)))))
|
||||
|
||||
;;; JS
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ void iniCLFunctions() {
|
|||
DEFUN ("qui-names", qui_names, 1)
|
||||
DEFUN ("qutf8", qutf8, 1)
|
||||
DEFUN ("%qvariant-equal", qvariant_equal2, 2)
|
||||
DEFUN ("qvariant-from-value", qvariant_from_value, 2)
|
||||
DEFUN ("qvariant-value", qvariant_value, 1)
|
||||
DEFUN ("qversion", qversion, 0) }
|
||||
|
||||
|
|
@ -1881,17 +1882,28 @@ cl_object qset_property(cl_object l_obj, cl_object l_name, cl_object l_val) {
|
|||
cl_object qvariant_value(cl_object l_obj) {
|
||||
/// args: (object)
|
||||
/// Returns the Lisp value of the <code>QVariant</code> object.
|
||||
const cl_env_ptr l_env = ecl_process_env();
|
||||
l_env->nvalues = 1;
|
||||
ecl_process_env()->nvalues = 1;
|
||||
QtObject o = toQtObject(l_obj);
|
||||
if("QVariant" == o.className() && o.pointer) {
|
||||
QVariant* p = (QVariant*)o.pointer;
|
||||
cl_object l_ret = from_qvariant_value(*p);
|
||||
l_env->values[0] = l_ret;
|
||||
return l_ret; }
|
||||
error_msg("QVARIANT-VALUE", LIST1(l_obj));
|
||||
return Cnil; }
|
||||
|
||||
cl_object qvariant_from_value(cl_object l_val, cl_object l_type) {
|
||||
/// args: (value type-name)
|
||||
/// Constructs a new <code>QVariant</code>. This is needed for types that don't have a direct constructor, like <code>QPixmap</code>, or primitive types, like <code>QSize</code>.
|
||||
/// (qvariant-from-value "red" "QColor")
|
||||
ecl_process_env()->nvalues = 1;
|
||||
QByteArray typeName(toCString(l_type));
|
||||
if(!typeName.isEmpty()) {
|
||||
QVariant* v = new QVariant(toQVariant(l_val, typeName));
|
||||
cl_object l_ret = qt_object_from_name("QVariant", v);
|
||||
return l_ret; }
|
||||
error_msg("QVARIANT-FROM-VALUE", LIST2(l_val, l_type));
|
||||
return Cnil; }
|
||||
|
||||
cl_object qinvoke_method2(cl_object l_obj, cl_object l_cast, cl_object l_name, cl_object l_args) {
|
||||
/// args: (object function-name &rest arguments)
|
||||
/// alias: qfun
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ cl_object qui_class2 (cl_object, cl_object);
|
|||
cl_object qui_names (cl_object);
|
||||
cl_object qutf8 (cl_object);
|
||||
cl_object qvariant_equal2 (cl_object, cl_object);
|
||||
cl_object qvariant_from_value (cl_object, cl_object);
|
||||
cl_object qvariant_value (cl_object);
|
||||
cl_object qversion ();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
|
||||
const char EQL::version[] = "17.1.4"; // Jan 2017
|
||||
const char EQL::version[] = "17.1.5"; // Jan 2017
|
||||
|
||||
extern "C" void ini_EQL(cl_object);
|
||||
|
||||
|
|
|
|||
|
|
@ -837,6 +837,7 @@
|
|||
(cons 'qui-class '(file-name &optional object-name))
|
||||
(cons 'qui-names '(file-name))
|
||||
(cons 'qutf8 '(string))
|
||||
(cons 'qvariant-from-value '(value type-name))
|
||||
(cons 'qvariant-value '(object))
|
||||
(cons 'tr '(source &optional context plural-number))))
|
||||
(setf (get (car el) :function-lambda-list) (cdr el)))
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@
|
|||
#:qui-names
|
||||
#:qutf8
|
||||
#:qversion
|
||||
#:qvariant-from-value
|
||||
#:qvariant-value
|
||||
#:the-qt-object
|
||||
#:tr))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue