Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping QVariantList behavior #41

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/nimqml/private/dotherside.nim
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ proc dos_qvariant_assign(leftValue: DosQVariant, rightValue: DosQVariant) {.cdec
proc dos_qvariant_setFloat(variant: DosQVariant, value: float) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setDouble(variant: DosQVariant, value: cdouble) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setQObject(variant: DosQVariant, value: DosQObject) {.cdecl, dynlib: dynLibName, importc.}
proc dos_qvariant_setArray(variant: DosQVariant, size: cint, array: ptr DosQVariantArray) {.cdecl, dynlib: dynLibName, importc.}

# QObject
proc dos_qobject_qmetaobject(): DosQMetaObject {.cdecl, dynlib: dynLibName, importc.}
Expand Down
8 changes: 8 additions & 0 deletions src/nimqml/private/qvariant.nim
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ proc toQVariantSequence(a: ptr DosQVariantArray, length: cint, takeOwnership: Ow
for i in 0..<length:
result.add(newQVariant(a[i], takeOwnership))

proc toQVariant*(sequence: openArray[QVariant]): QVariant =
result = newQVariant()
var arr = newSeqOfCap[DosQVariant](sequence.len)
for e in sequence:
arr.add e.vptr
dos_qvariant_setArray(result.vptr, sequence.len.cint, cast[ptr DosQVariantArray](arr[0].unsafeAddr))
return result

proc delete(a: openarray[QVariant]) =
## Delete an array of QVariants
for x in a:
Expand Down