From 71e0cbcd18a1f941c02b7223a2d368705f5bfd70 Mon Sep 17 00:00:00 2001 From: Bart Janssens Date: Tue, 18 Jun 2024 10:52:34 +0200 Subject: [PATCH] Fix win32 test --- .gitignore | 1 + src/itemmodel.jl | 21 +++++++++++---------- test/containers.jl | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index f6b2b20..a1565c0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ CMakeLists.txt.user /Manifest.toml /docs/build +.vscode diff --git a/src/itemmodel.jl b/src/itemmodel.jl index ba290f2..8e1b368 100644 --- a/src/itemmodel.jl +++ b/src/itemmodel.jl @@ -8,6 +8,7 @@ Base.:+(a::QML.ItemDataRole, b::Integer) = convert(Int32,a) + b # Allow roles as keys in Dicts: Base.trailing_zeros(role::ItemDataRole) = Base.trailing_zeros(convert(Int32,role)) Base.:(>>)(a::ItemDataRole, b::Int64) = convert(Int32, a) >> b +Base.:(>>)(a::ItemDataRole, b::Int32) = convert(Int32, a) >> b mutable struct ItemModelData{DataT} values::Observable{DataT} roles::RoleNames @@ -78,7 +79,7 @@ setheadergetter!(itemmodel::JuliaItemModel, f::Function) = (get_julia_data(itemm return false end - try + # try if colcount(m) == 1 m.setters[role](m.values[], value(val), row) else @@ -86,15 +87,15 @@ setheadergetter!(itemmodel::JuliaItemModel, f::Function) = (get_julia_data(itemm end emit_data_changed(itemmodel, row, col, row, col) return true - catch e - rolename = rolenames(m)[role] - if e isa KeyError - @warn "No setter for role $rolename" - else - @warn "Error $e when setting value at row $row for role $rolename" - end - return false - end + # catch e + # rolename = rolenames(m)[role] + # if e isa KeyError + # @warn "No setter for role $rolename" + # else + # @warn "Error $e when setting value at row $row for role $rolename" + # end + # return false + # end end # By default, no header data is set diff --git a/test/containers.jl b/test/containers.jl index 9ee542b..2a3f386 100644 --- a/test/containers.jl +++ b/test/containers.jl @@ -44,12 +44,12 @@ let h = QML.QHash{Int32,QML.QByteArray}() @test isempty(h) end -let numbers = Int32[1,2,3,4], model = JuliaItemModel(numbers) +let numbers = [1,2,3,4], model = JuliaItemModel(numbers) modeldata = QML.get_julia_data(model) @test QML.rowcount(modeldata) == 4 @test QML.colcount(modeldata) == 1 @test QML.value(QML.data(modeldata, QML.DisplayRole,3,1)) == "3" - @test QML.setdata!(model, QVariant(Int32(5)), QML.EditRole, 3, 1) + @test QML.setdata!(model, QVariant(5), QML.EditRole, 3, 1) @test QML.value(QML.data(modeldata, QML.DisplayRole,3,1)) == "5" @test QML.value(QML.headerdata(modeldata, 2, QML.Vertical, QML.DisplayRole)) == 2 @test_logs (:warn,"Setting header data is not supported in this model") QML.setheaderdata!(model, 1, QML.Vertical, QML.EditRole, "One")