mirror of https://github.com/status-im/nimqml.git
34 lines
892 B
Nim
34 lines
892 B
Nim
|
import NimQml, ContactList
|
||
|
|
||
|
QtObject:
|
||
|
type ApplicationLogic* = ref object of QObject
|
||
|
contactList: ContactList
|
||
|
app: QApplication
|
||
|
|
||
|
proc delete*(self: ApplicationLogic) =
|
||
|
let qobject = self.QObject
|
||
|
qobject.delete
|
||
|
self.contactList.delete
|
||
|
|
||
|
proc newApplicationLogic*(app: QApplication): ApplicationLogic =
|
||
|
new(result)
|
||
|
result.contactList = newContactList()
|
||
|
result.app = app
|
||
|
result.create()
|
||
|
|
||
|
method getContactList(self: ApplicationLogic): QVariant {.slot.} =
|
||
|
return newQVariant(self.contactList)
|
||
|
|
||
|
method onLoadTriggered(self: ApplicationLogic) {.slot.} =
|
||
|
echo "Load Triggered"
|
||
|
self.contactList.add("John", "Doo")
|
||
|
|
||
|
method onSaveTriggered(self: ApplicationLogic) {.slot.} =
|
||
|
echo "Save Triggered"
|
||
|
|
||
|
method onExitTriggered(self: ApplicationLogic) {.slot.} =
|
||
|
self.app.quit
|
||
|
|
||
|
QtProperty[QVariant] contactList:
|
||
|
read = getContactList
|