mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-23 14:41:04 -04:00
highlight peers in network graph according to friendship distance from selected node
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6765 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
027b9ba017
commit
1d0c7b2e2f
4 changed files with 38 additions and 3 deletions
|
@ -62,6 +62,8 @@
|
|||
#define IMAGE_TRUSTED ":/images/rs-2.png"
|
||||
#define IMAGE_MAKEFRIEND ":/images/user/add_user16.png"
|
||||
|
||||
Node *Node::_selected_node = NULL ;
|
||||
|
||||
Node::Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget::AuthType auth,GraphWidget *graphWidget,const std::string& ssl_id,const std::string& gpg_id)
|
||||
: graph(graphWidget),_desc_string(node_string),_type(type),_auth(auth),_ssl_id(ssl_id),_gpg_id(gpg_id)
|
||||
{
|
||||
|
@ -259,7 +261,26 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
|||
{
|
||||
static QColor type_color[4] = { QColor(Qt::yellow), QColor(Qt::green), QColor(Qt::cyan), QColor(Qt::black) } ;
|
||||
|
||||
QColor col0(type_color[_type]) ;
|
||||
QColor col0 ;
|
||||
|
||||
if(_selected_node == NULL)
|
||||
col0 = type_color[_type] ;
|
||||
else if(_selected_node == this)
|
||||
col0 = type_color[0] ;
|
||||
else
|
||||
{
|
||||
bool found = false ;
|
||||
for(QList<Edge*>::const_iterator it(edgeList.begin());it!=edgeList.end();++it)
|
||||
if( (*it)->sourceNode() == _selected_node || (*it)->destNode() == _selected_node)
|
||||
{
|
||||
col0 = type_color[1] ;
|
||||
found = true ;
|
||||
break ;
|
||||
}
|
||||
|
||||
if(!found)
|
||||
col0= type_color[2] ;
|
||||
}
|
||||
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(Qt::darkGray);
|
||||
|
@ -318,6 +339,9 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
|
|||
|
||||
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
_selected_node = this ;
|
||||
graph->forceRedraw() ;
|
||||
|
||||
update();
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
@ -354,6 +378,10 @@ void Node::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
|
||||
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
_selected_node = NULL ;
|
||||
graph->forceRedraw() ;
|
||||
|
||||
update();
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue