mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-23 13:51:12 -05: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
@ -136,8 +136,6 @@ GraphWidget::GraphWidget(QWidget *)
|
||||
setResizeAnchor(AnchorViewCenter);
|
||||
_friction_factor = 1.0f ;
|
||||
|
||||
|
||||
|
||||
scale(qreal(0.8), qreal(0.8));
|
||||
}
|
||||
|
||||
@ -384,6 +382,11 @@ void GraphWidget::setEdgeLength(uint32_t l)
|
||||
}
|
||||
}
|
||||
|
||||
void GraphWidget::forceRedraw()
|
||||
{
|
||||
for(uint32_t i=0;i<_nodes.size();++i)
|
||||
_nodes[i]->update(_nodes[i]->boundingRect()) ;
|
||||
}
|
||||
void GraphWidget::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
scaleView(pow((double)2, -event->delta() / 240.0));
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
void setEdgeLength(uint32_t l) ;
|
||||
uint32_t edgeLength() const { return _edge_length ; }
|
||||
|
||||
void forceRedraw() ;
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void timerEvent(QTimerEvent *event);
|
||||
@ -102,6 +103,7 @@ private:
|
||||
|
||||
uint32_t _edge_length ;
|
||||
float _friction_factor ;
|
||||
NodeId _current_node ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,8 @@ private:
|
||||
bool mDeterminedBB ;
|
||||
int mBBWidth ;
|
||||
|
||||
static Node *_selected_node ;
|
||||
|
||||
std::string _ssl_id ;
|
||||
std::string _gpg_id ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user