nimqml/examples/contactapp/applicationlogic.nim

34 lines
892 B
Nim
Raw Normal View History

2015-09-14 21:38:02 +00:00
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