2015-09-14 21:38:02 +00:00
|
|
|
import NimQml
|
|
|
|
|
2016-03-22 22:06:31 +00:00
|
|
|
QtObject:
|
|
|
|
type Contact* = ref object of QObject
|
|
|
|
m_name: string
|
|
|
|
|
|
|
|
proc delete*(self: Contact) =
|
|
|
|
self.QObject.delete
|
|
|
|
|
|
|
|
proc setup(self: Contact) =
|
|
|
|
self.QObject.setup
|
|
|
|
|
|
|
|
proc newContact*(): Contact =
|
|
|
|
new(result, delete)
|
|
|
|
result.m_name = "InitialName"
|
|
|
|
result.setup
|
|
|
|
|
|
|
|
proc getName*(self: Contact): string {.slot.} =
|
|
|
|
result = self.m_name
|
|
|
|
|
2016-09-25 15:46:03 +00:00
|
|
|
proc nameChanged*(self: Contact, name: string) {.signal.}
|
2016-03-22 22:06:31 +00:00
|
|
|
|
|
|
|
proc setName*(self: Contact, name: string) {.slot.} =
|
|
|
|
if self.m_name == name:
|
|
|
|
return
|
2015-09-14 21:38:02 +00:00
|
|
|
self.m_name = name
|
2016-09-25 15:46:03 +00:00
|
|
|
self.nameChanged(name)
|
2016-03-22 22:06:31 +00:00
|
|
|
|
|
|
|
QtProperty[string] name:
|
|
|
|
read = getName
|
|
|
|
write = setName
|
|
|
|
notify = nameChanged
|