From 8c6a45d9e402bc6bad6dc9780abb8bd654080610 Mon Sep 17 00:00:00 2001 From: polos Date: Thu, 1 Apr 2021 11:28:05 +0200 Subject: [PATCH] adapt '(qml)' for Sailfish --- lib/qml-ui-vars.lisp | 64 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/lib/qml-ui-vars.lisp b/lib/qml-ui-vars.lisp index 448cb36..fb74c50 100644 --- a/lib/qml-ui-vars.lisp +++ b/lib/qml-ui-vars.lisp @@ -16,8 +16,8 @@ (in-package :qml-ui-variables) -(defparameter *qml-items* (qfind-children #+sailfish (qml:root-item) - #-sailfish qml:*quick-view*)) +(defparameter *qml-items* #+sailfish (cons (qml:root-item) (qfind-children (qml:root-item))) + #-sailfish (qfind-children qml:*quick-view*)) (defun class-name* (item) (let ((name (|className| (|metaObject| item)))) @@ -43,16 +43,58 @@ :test 'string=))) list)) -(defun grep (name) - (flet ((one-space (s) - (x:join (remove-if 'x:empty-string (x:split s))))) - (let ((s (ext:run-program "grep" (list "-rn" - #-sailfish "--include" #-sailfish "*.qml" - (format nil "objectName:[[:space:]]*~S" name) - "qml/")))) - (loop :for line = (read-line s nil nil) - :while line :collect (one-space line))))) +(defun one-space (string) + (x:join (remove-if 'x:empty-string (x:split string)))) +#+sailfish +(defun grep (name) + (ext:run-program "sh" (list "-c" + (format nil "find qml/ -name *.qml -print0 | xargs -0 grep -rn \"objectName:[[:space:]]*\\\"~A\\\"\"" + name)))) + +#-sailfish +(defun grep (name) + (let ((s (ext:run-program "grep" (list "-rn" "--include" "*.qml" + (format nil "objectName:[[:space:]]*~S" + name) + "qml/")))) + (loop :for line = (read-line s nil nil) + :while line :collect (one-space line)))) + +#+sailfish +(defun collect () + (setf *qml-items* + (sort* (sort* (filter *qml-items*) + '|objectName| t) + 'class-name*)) + (let ((max-name 0) + (max-class 0) + collected not-unique grepped) + (dolist (item *qml-items*) + (let* ((name (|objectName| item)) + (class* (class-name* item)) + (grep (ignore-errors (read-line (grep name))))) + (when (and grep + (search ".qml:" grep) + (not (find grep grepped :test 'string=))) + (push (list (substitute #\- #\_ name) + name + class* + (subseq grep 0 (position #\: grep))) + collected) + (setf max-name (max (length name) max-name) + max-class (max (length class*) max-class)) + (when (and (find name not-unique :test 'string=) + (not (find grep grepped :test 'string=))) + (print (format nil "QML: not unique:
~A
" + (one-space (read-line (grep name)))))) + (pushnew grep grepped :test 'string=) + (pushnew name not-unique :test 'string=)))) + (values (setf collected (nreverse collected)) + max-name + max-class))) + +#-sailfish (defun collect () (setf *qml-items* (sort* (sort* (filter *qml-items*)