-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
742f151
commit 3de5ef7
Showing
40 changed files
with
1,750 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
resources.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import | ||
std/[sequtils, tables], | ||
NimQml, | ||
../beacon_chain/spec/eth2_apis/rest_beacon_client, | ||
../beacon_chain/spec/[eth2_merkleization, helpers], | ||
./objecttablemodel, ./utils | ||
|
||
type | ||
AttestationInfo* = object | ||
slot*: int | ||
index*: int | ||
beacon_block_root*: string | ||
source_epoch*: int | ||
source_root*: string | ||
target_epoch*: int | ||
target_root*: string | ||
aggregation_bits*: string | ||
|
||
proc toAttestationInfo*(v: Attestation): AttestationInfo = | ||
AttestationInfo( | ||
slot: v.data.slot.int, | ||
index: v.data.index.int, | ||
beacon_block_root: toBlockLink(v.data.beacon_block_root), | ||
source_epoch: v.data.source.epoch.int, | ||
source_root: toBlockLink(v.data.source.root), | ||
target_epoch: v.data.target.epoch.int, | ||
target_root: toBlockLink(v.data.target.root), | ||
aggregation_bits: $v.aggregation_bits, | ||
) | ||
|
||
QtObject: | ||
type AttestationList* = ref object of QAbstractTableModel | ||
# TODO this could be a generic ObjectTableModel, except generics + method don't work.. | ||
data: ObjectTableModelImpl[AttestationInfo] | ||
|
||
proc setup(self: AttestationList) = self.QAbstractTableModel.setup | ||
|
||
proc delete(self: AttestationList) = | ||
self.QAbstractTableModel.delete | ||
|
||
proc newAttestationList*(data: seq[Attestation]): AttestationList = | ||
new(result, delete) | ||
result.data = ObjectTableModelImpl[AttestationInfo](items: data.mapIt(it.toAttestationInfo())) | ||
result.setup | ||
|
||
method rowCount(self: AttestationList, index: QModelIndex = nil): int = | ||
self.data.rowCount(index) | ||
|
||
method columnCount(self: AttestationList, index: QModelIndex = nil): int = | ||
self.data.columnCount(index) | ||
|
||
method headerData*(self: AttestationList, section: int, orientation: QtOrientation, role: int): QVariant = | ||
self.data.headerData(section, orientation, role) | ||
|
||
method data(self: AttestationList, index: QModelIndex, role: int): QVariant = | ||
self.data.data(index, role) | ||
|
||
method roleNames(self: AttestationList): Table[int, string] = | ||
self.data.roleNames() | ||
|
||
proc setNewData*(self: AttestationList, v: seq[Attestation]) = | ||
self.data.setNewData(self, v.mapIt(it.toAttestationInfo())) | ||
|
||
proc sort*(self: AttestationList, section: int) {.slot.} = | ||
self.data.sort(self, section) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import | ||
std/[sequtils, tables], | ||
NimQml, | ||
../beacon_chain/spec/eth2_apis/rest_beacon_client, | ||
../beacon_chain/spec/[helpers], | ||
./objecttablemodel, ./utils | ||
|
||
type | ||
AttesterSlashingInfo* = object | ||
info*: string | ||
|
||
proc toAttesterSlashingInfo*(v: AttesterSlashing): AttesterSlashingInfo = | ||
AttesterSlashingInfo( | ||
info: $v | ||
) | ||
|
||
QtObject: | ||
type AttesterSlashingList* = ref object of QAbstractTableModel | ||
# TODO this could be a generic ObjectTableModel, except generics + method don't work.. | ||
data: ObjectTableModelImpl[AttesterSlashingInfo] | ||
|
||
proc setup(self: AttesterSlashingList) = self.QAbstractTableModel.setup | ||
|
||
proc delete(self: AttesterSlashingList) = | ||
self.QAbstractTableModel.delete | ||
|
||
proc newAttesterSlashingList*(data: openArray[AttesterSlashing]): AttesterSlashingList = | ||
new(result, delete) | ||
result.data = ObjectTableModelImpl[AttesterSlashingInfo](items: data.mapIt(it.toAttesterSlashingInfo())) | ||
result.setup | ||
|
||
method rowCount(self: AttesterSlashingList, index: QModelIndex = nil): int = | ||
self.data.rowCount(index) | ||
|
||
method columnCount(self: AttesterSlashingList, index: QModelIndex = nil): int = | ||
self.data.columnCount(index) | ||
|
||
method headerData*(self: AttesterSlashingList, section: int, orientation: QtOrientation, role: int): QVariant = | ||
self.data.headerData(section, orientation, role) | ||
|
||
method data(self: AttesterSlashingList, index: QModelIndex, role: int): QVariant = | ||
self.data.data(index, role) | ||
|
||
method roleNames(self: AttesterSlashingList): Table[int, string] = | ||
self.data.roleNames() | ||
|
||
proc setNewData*(self: AttesterSlashingList, v: openArray[AttesterSlashing]) = | ||
self.data.setNewData(self, v.mapIt(it.toAttesterSlashingInfo())) | ||
|
||
proc sort*(self: AttesterSlashingList, section: int) {.slot.} = | ||
self.data.sort(self, section) |
Oops, something went wrong.