diff --git a/retroshare-gui/src/gui/NetworkView.cpp b/retroshare-gui/src/gui/NetworkView.cpp index 44c99736d..b8ca55b76 100644 --- a/retroshare-gui/src/gui/NetworkView.cpp +++ b/retroshare-gui/src/gui/NetworkView.cpp @@ -48,19 +48,20 @@ NetworkView::NetworkView(QWidget *parent) ui.graphicsView->setScene(mScene); ui.graphicsView->setEdgeLength(ui.edgeLengthSB->value()) ; - setMaxFriendLevel(ui.maxFriendLevelSB->value()) ; + setMaxFriendLevel(1) ; /* add button */ connect( ui.refreshButton, SIGNAL( clicked( void ) ), this, SLOT( redraw( void ) ) ); connect( mScene, SIGNAL( changed ( const QList & ) ), this, SLOT ( changedScene( void ) ) ); /* Hide Settings frame */ - connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int))); + connect(ui.viewCB,SIGNAL(currentIndexChanged(int)),this,SLOT(setMaxFriendLevel(int))); connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int))); connect( ui.freezeCheckBox, SIGNAL(toggled(bool)), this, SLOT(setFreezeState(bool))); connect( ui.nameBox, SIGNAL(textChanged(QString)), this, SLOT(setNameSearch(QString))); - + _should_update = true ; + hideoffline = false; } NetworkView::~NetworkView() @@ -77,17 +78,29 @@ void NetworkView::setNameSearch(QString s) { ui.graphicsView->setNameSearch(s); } + void NetworkView::setMaxFriendLevel(int m) { ui.graphicsView->snapshotNodesPositions() ; clear() ; - _max_friend_level = m ; + switch(m) + { + case 0: // online + hideoffline = true; + _max_friend_level = 1 ; + break; + case 1: // all + hideoffline = false; + _max_friend_level = 1 ; + break; + case 2: // FoF + hideoffline = false; + _max_friend_level = 2 ; + break; + } updateDisplay() ; } -void NetworkView::changedFoFCheckBox( ) -{ - updateDisplay(); -} + void NetworkView::redraw() { ui.graphicsView->clearNodesPositions() ; @@ -169,8 +182,24 @@ void NetworkView::updateDisplay() RsPeerDetails detail ; if(!rsPeers->getGPGDetails(info.gpg_id, detail)) + { continue ; - + } + + bool gpg_connected = false; + std::list sslContacts; + rsPeers->getAssociatedSSLIds(detail.gpg_id, sslContacts); + for (std::list::iterator sslIt = sslContacts.begin(); sslIt != sslContacts.end(); ++sslIt) + { + RsPeerDetails sslDetail; + if (!rsPeers->getPeerDetails(*sslIt, sslDetail)) + continue; + if (sslDetail.state & RS_PEER_STATE_CONNECTED) + { gpg_connected = true; + break; + } + } + switch(detail.trustLvl) { case RS_TRUST_LVL_MARGINAL: auth = GraphWidget::ELASTIC_NODE_AUTH_MARGINAL ; break; @@ -184,6 +213,9 @@ void NetworkView::updateDisplay() if(info.friend_level <= _max_friend_level && _node_ids.find(info.gpg_id) == _node_ids.end()) { + if(hideoffline && !gpg_connected && detail.gpg_id != ownGPGId) + { } + else _node_ids[info.gpg_id] = ui.graphicsView->addNode(" "+detail.name, detail.name+"@"+detail.gpg_id.toStdString(),type,auth,RsPeerId(),info.gpg_id); #ifdef DEBUG_NETWORKVIEW std::cerr << " inserted node " << info.gpg_id << ", type=" << type << ", auth=" << auth << std::endl ; diff --git a/retroshare-gui/src/gui/NetworkView.h b/retroshare-gui/src/gui/NetworkView.h index 6ac5f8a5f..782efb4c7 100644 --- a/retroshare-gui/src/gui/NetworkView.h +++ b/retroshare-gui/src/gui/NetworkView.h @@ -49,7 +49,6 @@ class NetworkView : public RsAutoUpdatePage void setEdgeLength(int) ; void setNameSearch(QString) ; - void changedFoFCheckBox( ); void redraw(); void setFreezeState(bool); @@ -66,6 +65,7 @@ class NetworkView : public RsAutoUpdatePage std::map _node_ids ; bool _should_update ; + bool hideoffline; }; #endif diff --git a/retroshare-gui/src/gui/NetworkView.ui b/retroshare-gui/src/gui/NetworkView.ui index c62e05881..6b0024b0b 100644 --- a/retroshare-gui/src/gui/NetworkView.ui +++ b/retroshare-gui/src/gui/NetworkView.ui @@ -6,29 +6,20 @@ 0 0 - 616 + 631 499 - - 0 - - - 0 - - - 0 - - - 0 - 6 2 + + 0 + @@ -40,21 +31,43 @@ 6 - + + + + 1 + + + + Show online friends only + + + + + Show all friends + + + + + Friends + friends of friends + + + + + Edge length: - + Freeze - + Qt::Horizontal @@ -67,27 +80,7 @@ - - - - 0 - - - 2 - - - 1 - - - - - - - Friendship level: - - - - + 10 @@ -107,7 +100,7 @@ - +