2016-06-14 21:41:50 +00:00
|
|
|
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) =
|
2016-03-22 22:06:31 +00:00
|
|
|
self.QObject.delete
|
2015-09-14 21:38:02 +00:00
|
|
|
self.contactList.delete
|
|
|
|
|
2016-03-22 22:06:31 +00:00
|
|
|
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
|
2016-03-22 22:06:31 +00:00
|
|
|
result.setup()
|
2015-09-14 21:38:02 +00:00
|
|
|
|
2016-03-22 22:06:31 +00:00
|
|
|
proc getContactList(self: ApplicationLogic): QVariant {.slot.} =
|
2015-09-14 21:38:02 +00:00
|
|
|
return newQVariant(self.contactList)
|
|
|
|
|
2016-03-22 22:06:31 +00:00
|
|
|
proc onLoadTriggered(self: ApplicationLogic) {.slot.} =
|
2015-09-14 21:38:02 +00:00
|
|
|
echo "Load Triggered"
|
|
|
|
self.contactList.add("John", "Doo")
|
|
|
|
|
2016-03-22 22:06:31 +00:00
|
|
|
proc onSaveTriggered(self: ApplicationLogic) {.slot.} =
|
2015-09-14 21:38:02 +00:00
|
|
|
echo "Save Triggered"
|
|
|
|
|
2016-03-22 22:06:31 +00:00
|
|
|
proc onExitTriggered(self: ApplicationLogic) {.slot.} =
|
2015-09-14 21:38:02 +00:00
|
|
|
self.app.quit
|
|
|
|
|
|
|
|
QtProperty[QVariant] contactList:
|
|
|
|
read = getContactList
|