simplify some objects that don't need qt references

This commit is contained in:
Iuri Matias 2020-05-22 15:55:21 -04:00
parent a1109ca52b
commit 1d371d5054
3 changed files with 17 additions and 112 deletions

View File

@ -1,109 +1,18 @@
import NimQml
QtObject:
type ChatMessage* = ref object of QObject
userName: string
message: string
timestamp: string
identicon: string
isCurrentUser: bool
type ChatMessage* = ref object
userName*: string
message*: string
timestamp*: string
identicon*: string
isCurrentUser*: bool
proc delete*(self: ChatMessage) =
self.QObject.delete
proc delete*(self: ChatMessage) =
discard
proc setup(self: ChatMessage) =
self.QObject.setup
proc newChatMessage*(): ChatMessage =
new(result)
proc newChatMessage*(): ChatMessage =
result = ChatMessage()
result.userName = ""
result.message = ""
result.timestamp = "0"
result.identicon = ""
result.isCurrentUser = false
result.setup
proc userName*(self: ChatMessage): string {.slot.} =
result = self.userName
proc userNameChanged*(self: ChatMessage, userName: string) {.signal.}
proc setUserName(self: ChatMessage, userName: string) {.slot.} =
if self.userName == userName: return
self.userName = userName
self.userNameChanged(userName)
proc `userName=`*(self: ChatMessage, userName: string) = self.setUserName(userName)
QtProperty[string] userName:
read = userName
write = setUserName
notify = userNameChanged
proc message*(self: ChatMessage): string {.slot.} =
result = self.message
proc messageChanged*(self: ChatMessage, message: string) {.signal.}
proc setMessage(self: ChatMessage, message: string) {.slot.} =
if self.message == message: return
self.message = message
self.messageChanged(message)
proc `message=`*(self: ChatMessage, message: string) = self.setMessage(message)
QtProperty[string] message:
read = message
write = setMessage
notify = messageChanged
proc timestamp*(self: ChatMessage): string {.slot.} =
result = self.timestamp
proc timestampChanged*(self: ChatMessage, timestamp: string) {.signal.}
proc setTimestamp(self: ChatMessage, timestamp: string) {.slot.} =
if self.timestamp == timestamp: return
self.timestamp = timestamp
self.timestampChanged(timestamp)
proc `timestamp=`*(self: ChatMessage, timestamp: string) = self.setTimestamp(timestamp)
QtProperty[string] timestamp:
read = timestamp
write = setTimestamp
notify = timestampChanged
proc identicon*(self: ChatMessage): string {.slot.} =
result = self.identicon
proc identiconChanged*(self: ChatMessage, identicon: string) {.signal.}
proc setIdenticon(self: ChatMessage, identicon: string) {.slot.} =
if self.identicon == identicon: return
self.identicon = identicon
self.identiconChanged(identicon)
proc `identicon=`*(self: ChatMessage, identicon: string) = self.setIdenticon(identicon)
QtProperty[string] identicon:
read = identicon
write = setIdenticons
notify = identiconsChanged
proc isCurrentUser*(self: ChatMessage): bool {.slot.} =
result = self.isCurrentUser
proc isCurrentUserChanged*(self: ChatMessage, isCurrentUser: bool) {.signal.}
proc setIsCurrentUser(self: ChatMessage, isCurrentUser: bool) {.slot.} =
if self.isCurrentUser == isCurrentUser: return
self.isCurrentUser = isCurrentUser
self.isCurrentUserChanged(isCurrentUser)
proc `isCurrentUser=`*(self: ChatMessage, isCurrentUser: bool) = self.setIsCurrentUser(isCurrentUser)
QtProperty[bool] isCurrentUser:
read = isCurrentUser
write = setIsCurrentUser
notify = isCurrentUserChanged

View File

@ -11,7 +11,7 @@ type
Key = UserRole + 3
type
Address* = ref object of QObject
Address* = ref object
username*, identicon*, key*: string
QtObject:
@ -24,8 +24,6 @@ QtObject:
proc delete*(self: OnboardingView) =
self.QAbstractListModel.delete
for address in self.addresses:
address.delete
self.addresses = @[]
proc newOnboardingView*(model: AccountModel): OnboardingView =

View File

@ -10,7 +10,7 @@ type
Image = UserRole + 5
type
Asset* = ref object of QObject
Asset* = ref object
name*, symbol*, value*, fiatValue*, image*: string
QtObject:
@ -23,8 +23,6 @@ QtObject:
proc delete(self: WalletView) =
self.QAbstractListModel.delete
for asset in self.assets:
asset.delete
self.assets = @[]
proc setup(self: WalletView) =