mirror of https://github.com/status-im/nimqml.git
Added support for QUrl
This commit is contained in:
parent
f876db7117
commit
fb70f5dcba
|
@ -18,6 +18,7 @@ include private/qvariant.nim
|
|||
include private/qobject.nim
|
||||
include private/qqmlapplicationengine.nim
|
||||
include private/qapplication.nim
|
||||
include private/qurl.nim
|
||||
#include private.nimqmltypes
|
||||
#var qobjectRegistry = initTable[ptr QObjectObj, bool]()
|
||||
#include private/qvariant.nim
|
||||
|
|
|
@ -8,6 +8,7 @@ type
|
|||
DosQVariantArray* {.unchecked.} = array[0..0, DosQVariant]
|
||||
DosQMetaType = cint
|
||||
DosQMetaTypeArray* {.unchecked.} = array[0..0, DosQMetaType]
|
||||
DosQUrl* = distinct pointer
|
||||
|
||||
DosSignalDefinition* = object
|
||||
name*: cstring
|
||||
|
@ -107,3 +108,8 @@ proc dos_qmetaobject_create*(vptr: var DosQmetaObject,
|
|||
slotDefinitions: DosSlotDefinitions,
|
||||
propertyDefinitions: DosPropertyDefinitions) {.cdecl, importc.}
|
||||
proc dos_qmetaobject_delete*(vptr: DosQmetaObject) {.cdecl, importc.}
|
||||
|
||||
# QUrl
|
||||
proc dos_qurl_create(vptr: var DosQUrl, url: cstring, parsingMode: cint) {.cdecl, importc.}
|
||||
proc dos_qurl_delete(vptr: DosQUrl) {.cdecl, importc.}
|
||||
proc dos_qurl_to_string(vptr: DosQUrl, str: var cstring) {.cdecl, importc.}
|
||||
|
|
|
@ -71,3 +71,10 @@ type
|
|||
signals: seq[SignalDefinition]
|
||||
slots: seq[SlotDefinition]
|
||||
properties: seq[PropertyDefinition]
|
||||
|
||||
QUrl* = ref object of RootObj
|
||||
vptr: DosQUrl
|
||||
|
||||
QUrlParsingMode {.pure.} = enum
|
||||
Tolerant = 0.cint
|
||||
Strict = 1.cint
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
proc setup*(self: QUrl, url: string, mode: QUrlParsingMode) =
|
||||
## Setup a new QUrl
|
||||
dos_qurl_create(self.vptr, url.cstring, mode.cint)
|
||||
|
||||
proc delete(self: QUrl) =
|
||||
## Delete a QUrl
|
||||
if self.vptr.isNil:
|
||||
return
|
||||
debugMsg("QUrl", "delete")
|
||||
dos_qurl_delete(self.vptr)
|
||||
self.vptr.resetToNil
|
||||
|
||||
proc newQUrl(url: string, mode: QUrlParsingMode = QUrlParsingMode.Tolerant): QUrl =
|
||||
## Create a new QUrl
|
||||
new(result, delete)
|
||||
result.setup(url, mode)
|
||||
|
||||
proc toString(self: QUrl): string =
|
||||
## Return the url string
|
||||
var str: cstring
|
||||
dos_qurl_to_string(self.vptr, str)
|
||||
result = $str
|
||||
dos_chararray_delete(str)
|
Loading…
Reference in New Issue