fix function QPROPERTIES*; update docu; extend "gui/properties.lisp" for QML; fix QAPROPOS inverse sorting;
This commit is contained in:
parent
3282071ecc
commit
2c288a5f31
11 changed files with 73 additions and 27 deletions
|
|
@ -419,7 +419,7 @@ Prints all current properties of <code>object</code>, searching both all Qt prop
|
|||
<br><br>
|
||||
<b>QPROPERTIES* (object)</b>
|
||||
<br><br>
|
||||
Similar to <code>qproperties</code>, but listing the custom properties of the passed <code>object</code> instance only.<br>This is only useful for e.g. <code>QQuickItem</code>, in order to list all QML user defined properties of the passed item.
|
||||
Similar to <code>qproperties</code>, but listing all properties (including user defined ones) of the passed <code>object</code> instance.<br>This is only useful for e.g. <code>QQuickItem</code> derived classes, which don't have a corresponding C++ class, in order to list all QML properties.
|
||||
<br>
|
||||
<pre>
|
||||
(qproperties* (qml:find-quick-item "myItem"))
|
||||
|
|
|
|||
|
|
@ -32,8 +32,11 @@ Examples:
|
|||
HELP
|
||||
====
|
||||
|
||||
Use function QPROPERTIES* to list all user defined QML properties of an item.
|
||||
Use function QPROPERTIES* to list all QML properties of an item instance,
|
||||
including user defined ones.
|
||||
|
||||
Example:
|
||||
Examples:
|
||||
|
||||
(qproperties* (qml:find-quick-item "left"))
|
||||
|
||||
(show-properties-dialog (qml:find-quick-item "left"))
|
||||
|
|
|
|||
|
|
@ -15,6 +15,18 @@
|
|||
|
||||
(use-package :qml)
|
||||
|
||||
;; properties
|
||||
|
||||
(defun sym (name package)
|
||||
(find-symbol (symbol-name name) package))
|
||||
|
||||
(defun show-properties-dialog (&optional (item (qml:root-item)))
|
||||
(unless (find-package :properties)
|
||||
(load (in-home "gui/properties")))
|
||||
(funcall (sym :show :properties) item))
|
||||
|
||||
;; clock
|
||||
|
||||
(defun clock ()
|
||||
;; will keep working even after reloading the QML file (see QML:RELOAD);
|
||||
;; if stored in a variable, this won't be true;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,19 @@ directly, or NIL if you want to use the root item.
|
|||
Please see also the documentation in "qml/example.qml".
|
||||
|
||||
|
||||
HELP (properties)
|
||||
====
|
||||
|
||||
Since many QML types have no corresponding C++ class, the specific properties
|
||||
can't be inspected using QPROPERTIES (only the generic ones).
|
||||
|
||||
To list all properties (including user defined ones), use QPROPERTIES* instead.
|
||||
|
||||
Example:
|
||||
|
||||
(qproperties* (qml:find-quick-item "label"))
|
||||
|
||||
|
||||
TIP
|
||||
===
|
||||
|
||||
|
|
|
|||
|
|
@ -9,18 +9,18 @@
|
|||
|
||||
(use-package :qml)
|
||||
|
||||
;; utils
|
||||
;; for example (5) in "qml/example.qml"
|
||||
|
||||
(defun sym (name package)
|
||||
(find-symbol (symbol-name name) package))
|
||||
|
||||
;; for example (5) in "qml/example.qml"
|
||||
|
||||
(defun show-properties-dialog ()
|
||||
(unless (find-package :properties)
|
||||
(load (in-home "gui/properties")))
|
||||
(funcall (sym :show :properties) qml:*caller*))
|
||||
|
||||
;; ini
|
||||
|
||||
(defun run ()
|
||||
;; *quick-view* can be either a QQuickView or a QQuickWidget
|
||||
(setf qml:*quick-view* (qnew "QQuickView"))
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
(defvar-ui *main*
|
||||
*view*
|
||||
*depth*
|
||||
*label*)
|
||||
*label*
|
||||
*instance-properties*)
|
||||
|
||||
(defvar *font* (format nil "font-family: ~A; font-size: ~Apt;"
|
||||
#+darwin "Monaco" #+darwin 12
|
||||
|
|
@ -27,7 +28,8 @@
|
|||
(! "setMinimum" *depth* 1)
|
||||
(! "resize" *main* '(650 500))
|
||||
(qset-color *view* |QPalette.Base| "lightyellow")
|
||||
(qconnect *depth* "valueChanged(int)" 'update))
|
||||
(qconnect *depth* "valueChanged(int)" 'update)
|
||||
(qconnect *instance-properties* "toggled(bool)" 'all-instance-properties))
|
||||
|
||||
(defun update (depth)
|
||||
(! "setText" *label*
|
||||
|
|
@ -40,6 +42,11 @@
|
|||
(princ name s)))))
|
||||
(show))
|
||||
|
||||
(defun all-instance-properties (checked)
|
||||
(dolist (w (list *depth* *label*))
|
||||
(|setEnabled| w (not checked)))
|
||||
(show))
|
||||
|
||||
(defun show (&optional object)
|
||||
(when object
|
||||
(setf *object* object)
|
||||
|
|
@ -55,7 +62,9 @@
|
|||
"<pre style='~A'>~A</pre>"
|
||||
*font*
|
||||
(qescape (with-output-to-string (*standard-output*)
|
||||
(qproperties *object* (! "value" *depth*))))))
|
||||
(if (! "isChecked" *instance-properties*)
|
||||
(qproperties* *object*)
|
||||
(qproperties *object* (! "value" *depth*)))))))
|
||||
(unless (! "isVisible" *main*)
|
||||
(! "show" *main*)))
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="instance_properties">
|
||||
<property name="text">
|
||||
<string>all instance properties (for QML)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ void iniCLFunctions() {
|
|||
DEFUN ("%make-qimage/dangerous", make_qimage_dangerous, 5)
|
||||
DEFUN ("no-qexec", no_qexec, 0)
|
||||
DEFUN ("qadd-event-filter", qadd_event_filter, 3)
|
||||
DEFUN ("%qapropos", qapropos2, 3)
|
||||
DEFUN ("%qapropos", qapropos2, 4)
|
||||
DEFUN ("qapp", qapp, 0)
|
||||
DEFUN ("qcall-default", qcall_default, 0)
|
||||
DEFUN ("qclear-event-filters", qclear_event_filters, 0)
|
||||
|
|
@ -1546,7 +1546,7 @@ static MetaArg retArg(const QByteArray& name) {
|
|||
// *** meta info ***
|
||||
|
||||
static StrList metaInfo(const QByteArray& type, const QByteArray& qclass, const QByteArray& search,
|
||||
bool non, const QMetaObject* mo) {
|
||||
bool non, const QMetaObject* mo, bool no_offset = false) {
|
||||
StrList info;
|
||||
if("methods" == type) {
|
||||
if(!mo) {
|
||||
|
|
@ -1590,7 +1590,8 @@ static StrList metaInfo(const QByteArray& type, const QByteArray& qclass, const
|
|||
mo = LObjects::staticMetaObject(qclass); }
|
||||
if(mo) {
|
||||
if("properties" == type) {
|
||||
for(int i = mo->propertyOffset(); i < mo->propertyCount(); ++i) {
|
||||
// 'no_offset' is for properties only (QML)
|
||||
for(int i = (no_offset ? 0 : mo->propertyOffset()); i < mo->propertyCount(); ++i) {
|
||||
QMetaProperty mp(mo->property(i));
|
||||
QString name = QString("%1 %2%3")
|
||||
.arg(mp.typeName())
|
||||
|
|
@ -1613,7 +1614,7 @@ static StrList metaInfo(const QByteArray& type, const QByteArray& qclass, const
|
|||
info << name.toLatin1(); }}}}}}}
|
||||
return info; }
|
||||
|
||||
static bool metaInfoLessThan(const QByteArray& s1, const QString& s2) {
|
||||
static bool metaInfoLessThan(const QByteArray& s1, const QByteArray& s2) {
|
||||
if(s1.contains('(')) {
|
||||
return s1.mid(1 + s1.lastIndexOf(' ', s1.indexOf('('))) <
|
||||
s2.mid(1 + s2.lastIndexOf(' ', s2.indexOf('('))); }
|
||||
|
|
@ -1621,9 +1622,9 @@ static bool metaInfoLessThan(const QByteArray& s1, const QString& s2) {
|
|||
s2.mid(1 + s2.indexOf(' ')); }
|
||||
|
||||
static cl_object collect_info(const QByteArray& type, const QByteArray& qclass, const QByteArray& qsearch,
|
||||
bool non, bool* found, const QMetaObject* mo) {
|
||||
bool non, bool* found, const QMetaObject* mo, bool no_offset = false) {
|
||||
cl_object l_info = Cnil;
|
||||
StrList info = metaInfo(type, qclass, qsearch, non, mo);
|
||||
StrList info = metaInfo(type, qclass, qsearch, non, mo, no_offset);
|
||||
qSort(info.begin(), info.end(), metaInfoLessThan);
|
||||
if(info.size()) {
|
||||
*found = true;
|
||||
|
|
@ -1632,7 +1633,7 @@ static cl_object collect_info(const QByteArray& type, const QByteArray& qclass,
|
|||
l_info = cl_nreverse(l_info);
|
||||
return l_info; }
|
||||
|
||||
cl_object qapropos2(cl_object l_search, cl_object l_class, cl_object l_type) {
|
||||
cl_object qapropos2(cl_object l_search, cl_object l_class, cl_object l_type, cl_object l_no_offset) {
|
||||
/// args: (&optional search-string class-name)
|
||||
/// Finds all occurrencies of the given search string in the given object's meta information.<br>Constructors are listed under "Methods".<br>To list the user defined functions of external C++ classes (see Qt_EQL), pass the object instead of the class name.
|
||||
/// (qapropos "html" "QTextEdit")
|
||||
|
|
@ -1646,6 +1647,7 @@ cl_object qapropos2(cl_object l_search, cl_object l_class, cl_object l_type) {
|
|||
search = toCString(l_search); }
|
||||
bool all = (Cnil == l_type);
|
||||
bool q = all ? false : (Ct == cl_eql(q_keyword(), l_type));
|
||||
bool no_offset = (Ct == l_no_offset);
|
||||
StrList classes;
|
||||
bool qt_eql = false;
|
||||
const QMetaObject* mo = 0;
|
||||
|
|
@ -1681,7 +1683,7 @@ cl_object qapropos2(cl_object l_search, cl_object l_class, cl_object l_type) {
|
|||
cl_object l_doc_sig = Cnil;
|
||||
cl_object l_doc_ovr = Cnil;
|
||||
if(!non) {
|
||||
l_doc_pro = collect_info("properties", cl, search, non, &found, mo); }
|
||||
l_doc_pro = collect_info("properties", cl, search, non, &found, mo, no_offset); }
|
||||
cl_object l_doc_met = collect_info("methods", cl, search, non, &found, mo);
|
||||
if(!non) {
|
||||
l_doc_slo = collect_info("slots", cl, search, non, &found, mo);
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ cl_object error_msg2 (cl_object, cl_object);
|
|||
cl_object make_qimage_dangerous (cl_object, cl_object, cl_object, cl_object, cl_object);
|
||||
cl_object no_qexec ();
|
||||
cl_object qadd_event_filter (cl_object, cl_object, cl_object);
|
||||
cl_object qapropos2 (cl_object, cl_object, cl_object);
|
||||
cl_object qapropos2 (cl_object, cl_object, cl_object, cl_object);
|
||||
cl_object qapp ();
|
||||
cl_object qcall_default ();
|
||||
cl_object qclear_event_filters ();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
|
||||
const char EQL::version[] = "17.2.5"; // Feb 2017
|
||||
const char EQL::version[] = "17.2.6"; // Feb 2017
|
||||
|
||||
extern "C" void ini_EQL(cl_object);
|
||||
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@
|
|||
'string< :key 'cdr)
|
||||
'string< :key 'car))))
|
||||
|
||||
(defun qproperties (object &optional (depth 1) of-instance)
|
||||
(defun qproperties (object &optional (depth 1) qml)
|
||||
"args: (object &optional (depth 1))
|
||||
Prints all current properties of <code>object</code>, searching both all Qt properties and all Qt methods which don't require arguments (marked with '<b>*</b>').<br>Optionally pass a <code>depth</code> indicating how many super-classes to include. Pass <code>T</code> to include all super-classes.
|
||||
(qproperties (|font.QApplication|))
|
||||
|
|
@ -246,13 +246,13 @@
|
|||
(let ((name (qt-object-name object*))
|
||||
documentations functions properties)
|
||||
(x:while (and name (not (eql 0 depth)))
|
||||
(push (first (qapropos* nil (if of-instance object* name)))
|
||||
(push (first (qapropos* nil (if qml object* name) nil qml))
|
||||
documentations)
|
||||
(setf name (qsuper-class-name name))
|
||||
(when (numberp depth)
|
||||
(decf depth)))
|
||||
(dolist (docu documentations)
|
||||
(dolist (type '("Properties:" "Methods:"))
|
||||
(dolist (type (if qml '("Properties:") '("Properties:" "Methods:")))
|
||||
(dolist (fun (rest (find type (rest docu) :key 'first :test 'string=)))
|
||||
(when (and (not (x:starts-with "void " fun))
|
||||
(not (x:starts-with "constructor " fun))
|
||||
|
|
@ -295,7 +295,7 @@
|
|||
|
||||
(defun qproperties* (object)
|
||||
"args: (object)
|
||||
Similar to <code>qproperties</code>, but listing the custom properties of the passed <code>object</code> instance only.<br>This is only useful for e.g. <code>QQuickItem</code>, in order to list all QML user defined properties of the passed item.
|
||||
Similar to <code>qproperties</code>, but listing all properties (including user defined ones) of the passed <code>object</code> instance.<br>This is only useful for e.g. <code>QQuickItem</code> derived classes, which don't have a corresponding C++ class, in order to list all QML properties.
|
||||
(qproperties* (qml:find-quick-item \"myItem\"))"
|
||||
(qproperties object 1 t))
|
||||
|
||||
|
|
@ -481,13 +481,13 @@
|
|||
(unless (member x '(t nil))
|
||||
(symbol-name x)))))
|
||||
|
||||
(defun qapropos (&optional name class type)
|
||||
(defun qapropos (&optional name class type offset)
|
||||
(let ((name* (%string-or-nil name)))
|
||||
(when (and (not name*)
|
||||
(not class)
|
||||
(not (y-or-n-p "Print documentation of all Qt classes?")))
|
||||
(return-from qapropos))
|
||||
(let ((main (%qapropos name* class type)))
|
||||
(let ((main (%qapropos name* class type offset)))
|
||||
(dolist (sub1 main)
|
||||
(format t "~%~%~A~%" (first sub1))
|
||||
(dolist (sub2 (rest sub1))
|
||||
|
|
@ -501,10 +501,10 @@
|
|||
(terpri)
|
||||
nil)
|
||||
|
||||
(defun qapropos* (&optional name class type)
|
||||
(defun qapropos* (&optional name class type offset)
|
||||
"args: (&optional search-string class-name)
|
||||
Similar to <code>qapropos</code>, returning the results as nested list."
|
||||
(%qapropos (%string-or-nil name) class type))
|
||||
(%qapropos (%string-or-nil name) class type offset))
|
||||
|
||||
(defun qnew-instance (name &rest arguments)
|
||||
(%qnew-instance name arguments))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue