From 83153eff50cbf10afb99697b8469d9f976b45489 Mon Sep 17 00:00:00 2001 From: AntiD2ta Date: Thu, 28 Nov 2019 20:49:52 -0500 Subject: [PATCH] [explorer] refs #248 - Add modelExplorer.go. Include initial implementation of backend model for explorer view as a list of blocks --- src/models/modelExplorer.go | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/models/modelExplorer.go diff --git a/src/models/modelExplorer.go b/src/models/modelExplorer.go new file mode 100644 index 00000000..e6e57758 --- /dev/null +++ b/src/models/modelExplorer.go @@ -0,0 +1,85 @@ +package models + +import ( + "github.com/fibercrypto/FiberCryptoWallet/src/util/logging" + "github.com/therecipe/qt/core" + qtcore "github.com/therecipe/qt/core" +) + +// Properties: + +// For blocks: +// - Time +// - Block number +// - Transactions (number of Transactions) +// - Blockhash + +// For block's details: +// - Height +// - Timestamp +// - Size +// - Hash +// - Parent Hash +// - Total Amount + +// - Next block +// - Previous block + +// For Transactions: +// - Inputs: +// * Coins +// * Initial hours +// * Final hours + +// - Outputs: +// * Coins +// * Hours + +// - Transaction fee (in hours) + +// - Links for the transactions + +var logExplorer = logging.MustGetLogger("modelsExplorer") + +const ( + QBlocks = int(qtcore.Qt__UserRole) + iota + 1 +) + +// ModelBlocks List of Blocks to be show. +type ModelBlocks struct { + qtcore.QObject + _ func() `constructor:"init"` + + _ map[int]*core.QByteArray `property:"roles"` + _ []*QBlock `property:"outputs"` + + _ func([]*QBlock) `slot:"addBlocks"` + _ func([]*QBlock) `slot:"insertBlocks"` + _ func([]*QBlock) `slot:"loadModel"` + _ func() `slot:"cleanModel"` +} + +// QBlock Contains info about the block to be show. +type QBlock struct { + core.QObject + + _ string `property:"time"` + _ string `property:"blockNumber"` + _ string `property:"Transactions"` + _ string `property:"Blockhash"` +} + +func (m *ModelBlocks) init() { + m.SetRoles(map[int]*core.QByteArray{ + QBlocks: core.NewQByteArray2("qblocks", -1), + }) + + m.ConnectRowCount(m.rowCount) + m.ConnectRoleNames(m.roleNames) + m.ConnectData(m.data) + m.ConnectAddBlocks(m.addBlocks) + m.ConnectInsertBlocks(m.insertBlocks) + m.ConnectLoadModel(m.loadModel) + m.ConnectCleanModel(m.cleanModel) + +}