3939const QStringList = QList{QString}
4040
4141# Make sure functions accepting a QString argument also accept a Julia string
42- CxxWrap. argument_overloads (:: Type{<:QString} ) = [QString,String]
42+ CxxWrap. argument_overloads (:: Type{<:QString} ) = [QString, String]
4343
4444@wrapfunctions
4545
4646# Protect items stored in a QML context from GC
47- global __context_gc_protection = Dict {ConstCxxPtr{QQmlContext}, Vector{Any}} ()
47+ global __context_gc_protection = Dict {ConstCxxPtr{QQmlContext},Vector{Any}} ()
4848
4949# Clear GC protection list when the context is destroyed
5050function on_context_destroyed (ctx)
@@ -89,7 +89,7 @@ Load a QML file, creating a [`QML.QQmlApplicationEngine`](@ref), and setting the
8989function loadqml (qmlfilename; kwargs... )
9090 qml_engine = init_qmlapplicationengine ()
9191 ctx = root_context (CxxRef (qml_engine))
92- for (key,value) in kwargs
92+ for (key, value) in kwargs
9393 set_context_property (ctx, String (key), value)
9494 end
9595 try
@@ -121,7 +121,7 @@ function watchqml(qview::CxxPtr{QQuickView}, qmlfile)
121121 QML. clearComponentCache (engine)
122122 set_source (qview, QUrlFromLocalFile (path))
123123 end
124-
124+
125125 watcher = QML. QFileSystemWatcher (engine)
126126 QML. addPath (watcher, qmlfile)
127127 QML. connect_file_changed_signal (watcher, clearcache)
172172function __init__ ()
173173 @initcxx
174174
175- @require GLMakie= " e9467ef8-e4e7-5192-8a1a-b1aee30e663a" include (joinpath (@__DIR__ , " makie_support.jl" ))
176-
177175 loadqmljll (jlqml_jll. Qt6Declarative_jll)
178- @require Qt65Compat_jll= " f5784262-74e5-52be-b835-f3e8a3cf8710" @eval loadqmljll (Qt65Compat_jll)
176+ @require Qt65Compat_jll = " f5784262-74e5-52be-b835-f3e8a3cf8710" @eval loadqmljll (Qt65Compat_jll)
179177
180178 global ARGV = ArgcArgv ([Base. julia_cmd ()[1 ], ARGS ... ])
181179 global APPLICATION = QGuiApplication (ARGV. argc, getargv (ARGV))
@@ -185,17 +183,17 @@ end
185183QString (s:: String ) = fromStdWString (StdWString (s))
186184Base. ncodeunits (s:: QString ):: Int = cppsize (s)
187185Base. codeunit (s:: QString ) = UInt16
188- Base. codeunit (s:: QString , i:: Integer ) = uint16char (s, i- 1 )
189- Base. isvalid (s:: QString , i:: Integer ) = isvalidindex (s, i- 1 )
186+ Base. codeunit (s:: QString , i:: Integer ) = uint16char (s, i - 1 )
187+ Base. isvalid (s:: QString , i:: Integer ) = isvalidindex (s, i - 1 )
190188function Base. iterate (s:: QString , i:: Integer = 1 )
191- if ! isvalid (s,i)
189+ if ! isvalid (s, i)
192190 return nothing
193191 end
194- (charcode, nexti) = get_iterate (s,i - 1 )
192+ (charcode, nexti) = get_iterate (s, i - 1 )
195193 if nexti == - 1
196194 return nothing
197195 end
198- return (Char (charcode),nexti+ 1 )
196+ return (Char (charcode), nexti + 1 )
199197end
200198Base. convert (:: Type{<:QString} , s:: String ) = QString (s)
201199QString (u:: QUrl ) = toString (u)
@@ -210,11 +208,11 @@ const QVariantList = QList{QVariant}
210208const QVariantMap = QMap{QString,QVariant}
211209
212210# Conversion to the strongly-typed QVariant interface
213- @inline QVariant (x) = QVariant (Any,x)
211+ @inline QVariant (x) = QVariant (Any, x)
214212@inline QVariant (x:: T ) where {T<: Union{Number,Ref,CxxWrap.SafeCFunction,QVariantMap,Nothing} } = QVariant (T, x)
215- @inline QVariant (x:: AbstractString ) = QVariant (QString,QString (x))
216- @inline QVariant (x:: QString ) = QVariant (QString,x)
217- @inline QVariant (x:: QObject ) = QVariant (CxxPtr{QObject},CxxPtr (x))
213+ @inline QVariant (x:: AbstractString ) = QVariant (QString, QString (x))
214+ @inline QVariant (x:: QString ) = QVariant (QString, x)
215+ @inline QVariant (x:: QObject ) = QVariant (CxxPtr{QObject}, CxxPtr (x))
218216@inline QVariant (x:: QVariant ) = x
219217
220218QVariant (:: Type{Bool} , b:: Bool ) = QVariant (CxxBool, CxxBool (b))
231229@inline @cxxdereference setValue (v:: QVariant , x:: T ) where {T} = setValue (T, v, x)
232230QVariant (:: Type{Nothing} , :: Nothing ) = QVariant ()
233231@cxxdereference value (:: Type{Nothing} , :: QML.QVariant ) = nothing
234- @cxxdereference value (v:: QVariant ) = CxxWrap. dereference_argument (value (type (v),v))
232+ @cxxdereference value (v:: QVariant ) = CxxWrap. dereference_argument (value (type (v), v))
235233Base. convert (:: Type{QVariant} , x:: T ) where {T} = QVariant (x)
236- Base. convert (:: Type{T} , x:: QVariant ) where {T} = convert (T,value (x))
234+ Base. convert (:: Type{T} , x:: QVariant ) where {T} = convert (T, value (x))
237235Base. convert (:: Type{Any} , x:: QVariant ) = x
238236Base. convert (:: Type{<:QVariant} , x:: QVariant ) = x
239237
@@ -242,29 +240,29 @@ Base.convert(::Type{<:QVariant}, x::QVariant) = x
242240# QList
243241Base. IndexStyle (:: Type{<:QList} ) = IndexLinear ()
244242Base. size (v:: QList ) = (Int (cppsize (v)),)
245- Base. getindex (v:: QList , i:: Int ) = cppgetindex (v,i - 1 )[]
246- Base. setindex! (v:: QList{T} , val, i:: Int ) where {T} = cppsetindex! (v, convert (T,val), i- 1 )
243+ Base. getindex (v:: QList , i:: Int ) = cppgetindex (v, i - 1 )[]
244+ Base. setindex! (v:: QList{T} , val, i:: Int ) where {T} = cppsetindex! (v, convert (T, val), i - 1 )
247245function Base. push! (v:: QList{T} , x) where {T}
248- push_back (v, convert (T,x))
246+ push_back (v, convert (T, x))
249247 return v
250248end
251249Base. empty! (l:: QList ) = clear (l)
252- Base. deleteat! (l:: QList , i:: Integer ) = removeAt (l, i- 1 )
250+ Base. deleteat! (l:: QList , i:: Integer ) = removeAt (l, i - 1 )
253251
254252# QHash
255253Base. isempty (h:: QHash ) = empty (h)
256254Base. length (h:: QHash ) = Int (cppsize (h))
257255Base. haskey (h:: QHash , key) = QML. contains (h, key)
258256function Base. getindex (h:: QHash{K,V} , key) where {K,V}
259- if ! haskey (h,key)
257+ if ! haskey (h, key)
260258 throw (KeyError (key))
261259 end
262- return cppgetindex (h, convert (K,key))[]
260+ return cppgetindex (h, convert (K, key))[]
263261end
264- Base. setindex! (h:: QHash{K,V} , val, key) where {K,V} = cppsetindex! (h, convert (V,val), convert (K,key))
262+ Base. setindex! (h:: QHash{K,V} , val, key) where {K,V} = cppsetindex! (h, convert (V, val), convert (K, key))
265263Base. empty! (h:: QHash ) = clear (h)
266- Base. delete! (h:: QHash{K,V} , key) where {K,V} = remove (h, convert (K,key))
267- Base.:(== )(a:: QHashIterator , b:: QHashIterator ) = iteratorisequal (a,b)
264+ Base. delete! (h:: QHash{K,V} , key) where {K,V} = remove (h, convert (K, key))
265+ Base.:(== )(a:: QHashIterator , b:: QHashIterator ) = iteratorisequal (a, b)
268266function _qhash_iteration_tuple (h:: QHash , state:: QHashIterator )
269267 if state == iteratorend (h)
270268 return nothing
@@ -281,15 +279,15 @@ Base.isempty(h::QMap) = empty(h)
281279Base. length (h:: QMap ) = Int (cppsize (h))
282280Base. haskey (h:: QMap , key) = QML. contains (h, key)
283281function Base. getindex (h:: QMap{K,V} , key) where {K,V}
284- if ! haskey (h,key)
282+ if ! haskey (h, key)
285283 throw (KeyError (key))
286284 end
287- return cppgetindex (h, convert (K,key))[]
285+ return cppgetindex (h, convert (K, key))[]
288286end
289- Base. setindex! (h:: QMap{K,V} , val, key) where {K,V} = cppsetindex! (h, convert (V,val), convert (K,key))
287+ Base. setindex! (h:: QMap{K,V} , val, key) where {K,V} = cppsetindex! (h, convert (V, val), convert (K, key))
290288Base. empty! (h:: QMap ) = clear (h)
291- Base. delete! (h:: QMap{K,V} , key) where {K,V} = remove (h, convert (K,key))
292- Base.:(== )(a:: QMapIterator , b:: QMapIterator ) = iteratorisequal (a,b)
289+ Base. delete! (h:: QMap{K,V} , key) where {K,V} = remove (h, convert (K, key))
290+ Base.:(== )(a:: QMapIterator , b:: QMapIterator ) = iteratorisequal (a, b)
293291function _qmap_iteration_tuple (h:: QMap , state:: QMapIterator )
294292 if state == iteratorend (h)
295293 return nothing
@@ -309,7 +307,7 @@ function julia_call(f, argptr::Ptr{Cvoid})
309307end
310308
311309function get_julia_call ()
312- return @cfunction (julia_call, Ptr{Cvoid}, (Any,Ptr{Cvoid}))
310+ return @cfunction (julia_call, Ptr{Cvoid}, (Any, Ptr{Cvoid}))
313311end
314312
315313# QQmlPropertyMap indexing interface
@@ -322,10 +320,10 @@ function on_value_changed end
322320
323321mutable struct JuliaPropertyMap <: AbstractDict{String,Any}
324322 propertymap:: _JuliaPropertyMap
325- dict:: Dict{String, Any}
323+ dict:: Dict{String,Any}
326324
327325 function JuliaPropertyMap ()
328- result = new (_JuliaPropertyMap (), Dict {String, Any} ())
326+ result = new (_JuliaPropertyMap (), Dict {String,Any} ())
329327 set_julia_value (result. propertymap, result)
330328 connect_value_changed (result. propertymap, result, on_value_changed)
331329 finalizer (result) do jpm
@@ -379,7 +377,7 @@ julia> mktempdir() do folder
379377"""
380378function JuliaPropertyMap (pairs:: Pair{<:AbstractString,<:Any} ...)
381379 result = JuliaPropertyMap ()
382- for (k,v) in pairs
380+ for (k, v) in pairs
383381 result[k] = v
384382 end
385383 return result
@@ -404,7 +402,7 @@ function (updater::QmlPropertyUpdater)(x)
404402 updater. propertymap[updater. key] = x
405403end
406404
407- setactive! (:: Any ,:: Bool ) = nothing
405+ setactive! (:: Any , :: Bool ) = nothing
408406setactive! (updater:: QmlPropertyUpdater , active:: Bool ) = (updater. active = active)
409407
410408Base. getindex (jpm:: JuliaPropertyMap , k:: AbstractString ) = jpm. dict[k]
@@ -413,7 +411,7 @@ Base.get(jpm::JuliaPropertyMap, k::AbstractString, def) = get(jpm.dict, k, def)
413411function Base. delete! (jpm:: JuliaPropertyMap , k:: AbstractString )
414412 storedvalue = jpm. dict[k]
415413 if storedvalue isa Observable
416- for (_,observer) in filter (x -> x[2 ] isa QmlPropertyUpdater, Observables. listeners (storedvalue))
414+ for (_, observer) in filter (x -> x[2 ] isa QmlPropertyUpdater, Observables. listeners (storedvalue))
417415 if observer. propertymap == jpm. propertymap
418416 off (storedvalue, observer)
419417 end
@@ -600,16 +598,16 @@ function Base.display(d::JuliaDisplay, x)
600598 supported_types = (MIME " image/svg+xml" (), MIME " image/png" ())
601599 write_methods = (load_svg, load_png)
602600 written = false
603- for (t,write_method) in zip (supported_types, write_methods)
604- if showable (t,x)
601+ for (t, write_method) in zip (supported_types, write_methods)
602+ if showable (t, x)
605603 Base. show (buf, t, x)
606604 write_method (d, take! (buf))
607605 written = true
608606 break
609607 end
610608 end
611609 if ! written
612- throw (MethodError (display, (d,x)))
610+ throw (MethodError (display, (d, x)))
613611 end
614612
615613end
@@ -626,14 +624,14 @@ include("itemmodel.jl")
626624global _async_timer
627625
628626function exec_async ()
629- newrepl = @async Base. run_main_repl (true ,true ,true ,true ,true )
627+ newrepl = @async Base. run_main_repl (true , true , true , true , true )
630628 while ! istaskdone (newrepl)
631- for (updater, x) in _queued_properties
632- updater. propertymap[updater. key] = x
633- end
634- empty! (_queued_properties)
635- process_events ()
636- sleep (0.015 )
629+ for (updater, x) in _queued_properties
630+ updater. propertymap[updater. key] = x
631+ end
632+ empty! (_queued_properties)
633+ process_events ()
634+ sleep (0.015 )
637635 end
638636 QML. quit (QML. get_qmlengine ())
639637 QML. quit ()
0 commit comments