Added Peer Window

This commit is contained in:
Maran
2014-06-02 15:16:37 +02:00
parent 98811f11e5
commit a6f4eef1da
3 changed files with 64 additions and 2 deletions

View File

@@ -45,6 +45,13 @@ ApplicationWindow {
addPeerWin.visible = true
}
}
MenuItem {
text: "Show Peers"
shortcut: "Ctrl+e"
onTriggered: {
peerWindow.visible = true
}
}
}
Menu {
@@ -359,6 +366,10 @@ ApplicationWindow {
id: peerImage
anchors.right: parent.right
width: 10; height: 10
MouseArea {
onDoubleClicked: peerWindow.visible = true
anchors.fill: parent
}
source: ui.assetPath("network.png")
}
}
@@ -623,6 +634,20 @@ ApplicationWindow {
function setPeers(text) {
peerLabel.text = text
}
function addPeer(peer) {
// We could just append the whole peer object but it cries if you try to alter them
peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), version: peer.version})
}
function resetPeers(){
peerModel.clear()
}
function timeAgo(unixTs){
var lapsed = (Date.now() - new Date(unixTs*1000)) / 1000
return (lapsed + " seconds ago")
}
function convertToPretty(unixTs){
var a = new Date(unixTs*1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
@@ -635,6 +660,30 @@ ApplicationWindow {
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
return time;
}
// ******************************************
// Windows
// ******************************************
Window {
id: peerWindow
height: 200
width: 500
Rectangle {
anchors.fill: parent
property var peerModel: ListModel {
id: peerModel
}
TableView {
anchors.fill: parent
id: peerTable
model: peerModel
TableViewColumn{width: 120; role: "ip" ; title: "IP" }
TableViewColumn{width: 60; role: "port" ; title: "Port" }
TableViewColumn{width: 120; role: "lastResponse"; title: "Last event" }
TableViewColumn{width: 180; role: "version" ; title: "Version" }
}
}
}
// *******************************************
// Components
// *******************************************
@@ -810,7 +859,6 @@ ApplicationWindow {
}
}
}
// New Transaction component
Component {
id: newTransaction