From 1d371d50543f53d1927fb7b542ed1378ce56d7c7 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 22 May 2020 15:55:21 -0400 Subject: [PATCH] simplify some objects that don't need qt references --- src/app/chat/messages.nim | 121 +++++----------------------------- src/app/onboarding/view.nim | 4 +- src/app/wallet/walletView.nim | 4 +- 3 files changed, 17 insertions(+), 112 deletions(-) diff --git a/src/app/chat/messages.nim b/src/app/chat/messages.nim index 6dd5da7ebe..bdb6df9189 100644 --- a/src/app/chat/messages.nim +++ b/src/app/chat/messages.nim @@ -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) - 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 +proc newChatMessage*(): ChatMessage = + result = ChatMessage() + result.userName = "" + result.message = "" + result.timestamp = "0" + result.identicon = "" + result.isCurrentUser = false diff --git a/src/app/onboarding/view.nim b/src/app/onboarding/view.nim index 9edcd2c724..526bd0c444 100644 --- a/src/app/onboarding/view.nim +++ b/src/app/onboarding/view.nim @@ -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 = diff --git a/src/app/wallet/walletView.nim b/src/app/wallet/walletView.nim index 53325f1f1e..d92d6e985f 100644 --- a/src/app/wallet/walletView.nim +++ b/src/app/wallet/walletView.nim @@ -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) =