dotherside/Nim/Examples/ContactApp/ApplicationLogic.nim
2015-01-12 22:30:10 +01:00

34 lines
913 B
Nim

import NimQml, NimQmlMacros, 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