nimqml/examples/contactapp/applicationlogic.nim

36 lines
920 B
Nim
Raw Normal View History

import NimQml, contactlist
2015-09-14 21:38:02 +00:00
QtObject:
type ApplicationLogic* = ref object of QObject
contactList: ContactList
app: QApplication
proc delete*(self: ApplicationLogic) =
self.QObject.delete
2015-09-14 21:38:02 +00:00
self.contactList.delete
proc setup(self: ApplicationLogic) =
self.QObject.setup
2015-09-14 21:38:02 +00:00
proc newApplicationLogic*(app: QApplication): ApplicationLogic =
new(result)
result.contactList = newContactList()
result.app = app
result.setup()
2015-09-14 21:38:02 +00:00
proc getContactList(self: ApplicationLogic): QVariant {.slot.} =
2015-09-14 21:38:02 +00:00
return newQVariant(self.contactList)
proc onLoadTriggered(self: ApplicationLogic) {.slot.} =
2015-09-14 21:38:02 +00:00
echo "Load Triggered"
self.contactList.add("John", "Doo")
proc onSaveTriggered(self: ApplicationLogic) {.slot.} =
2015-09-14 21:38:02 +00:00
echo "Save Triggered"
proc onExitTriggered(self: ApplicationLogic) {.slot.} =
2015-09-14 21:38:02 +00:00
self.app.quit
QtProperty[QVariant] contactList:
read = getContactList