diff --git a/retroshare-gui/src/gui/elastic/edge.cpp b/retroshare-gui/src/gui/elastic/edge.cpp index 0fd8707d2..8e72d416a 100644 --- a/retroshare-gui/src/gui/elastic/edge.cpp +++ b/retroshare-gui/src/gui/elastic/edge.cpp @@ -96,6 +96,12 @@ QRectF Edge::boundingRect() const .adjusted(-extra, -extra, extra, extra); } +void Edge::setEdgeColor(QColor color) +{ + edgeColor = color; + update(boundingRect()); +} + void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { if (!source || !dest) @@ -103,7 +109,7 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) // Draw the line itself QLineF line(sourcePoint, destPoint); - painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + painter->setPen(QPen(edgeColor, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter->drawLine(line); return ; diff --git a/retroshare-gui/src/gui/elastic/edge.h b/retroshare-gui/src/gui/elastic/edge.h index dbf8b7d4c..4a2ab25ba 100644 --- a/retroshare-gui/src/gui/elastic/edge.h +++ b/retroshare-gui/src/gui/elastic/edge.h @@ -40,6 +40,7 @@ public: void setDestNode(Node *node); void adjust(); + void setEdgeColor(QColor color); enum { Type = UserType + 2 }; int type() const { return Type; } @@ -54,6 +55,7 @@ private: QPointF sourcePoint; QPointF destPoint; qreal arrowSize; + QColor edgeColor = Qt::black; }; #endif diff --git a/retroshare-gui/src/gui/elastic/elnode.cpp b/retroshare-gui/src/gui/elastic/elnode.cpp index 86bb4e31e..c822587f3 100644 --- a/retroshare-gui/src/gui/elastic/elnode.cpp +++ b/retroshare-gui/src/gui/elastic/elnode.cpp @@ -251,23 +251,48 @@ static QColor lightdark(const QColor& col,int l,int d) void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) { static QColor type_color[4] = { QColor(Qt::yellow), QColor(Qt::green), QColor(Qt::cyan), QColor(Qt::black) } ; + // QColor default_edge = Qt::black; + // QColor searched_node_edge = Qt::magenta; + // QColor selected_node_edge = Qt::green; QColor col0 ; + // selected_node = clicked on with left mouse button if(_selected_node == NULL) + { col0 = type_color[_type] ; + + /* if (sought_for) // this node + { + // repaint edge + for (QList::const_iterator it(edgeList.begin()); it != edgeList.end(); ++it) + (*it)->setEdgeColor(searched_node_edge); + } + else + { + for (QList::const_iterator it(edgeList.begin()); it != edgeList.end(); ++it) + (*it)->setEdgeColor(default_edge); + } */ + } else if(_selected_node == this) + { + // for (QList::const_iterator it(edgeList.begin()); it != edgeList.end(); ++it) + // (*it)->setEdgeColor(selected_node_edge); col0 = type_color[0] ; + } + // selected_node = some_other_node else { bool found = false ; - for(QList::const_iterator it(edgeList.begin());it!=edgeList.end();++it) + for (QList::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] ; diff --git a/retroshare-gui/src/gui/elastic/elnode.h b/retroshare-gui/src/gui/elastic/elnode.h index 33043ddab..6cbb1e030 100644 --- a/retroshare-gui/src/gui/elastic/elnode.h +++ b/retroshare-gui/src/gui/elastic/elnode.h @@ -65,7 +65,7 @@ public: QRectF boundingRect() const; QPainterPath shape() const; - void setNodeDrawSize(int nds){mNodeDrawSize = nds;} + void setNodeDrawSize(int nds, bool repaint_edges) {mNodeDrawSize = nds; sought_for=repaint_edges;} int getNodeDrawSize(){return mNodeDrawSize;} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); @@ -95,6 +95,7 @@ private: bool mDeterminedBB ; int mBBWidth ; int mNodeDrawSize; + bool sought_for = false; static Node *_selected_node ; diff --git a/retroshare-gui/src/gui/elastic/graphwidget.cpp b/retroshare-gui/src/gui/elastic/graphwidget.cpp index f4ce104af..34eb00240 100644 --- a/retroshare-gui/src/gui/elastic/graphwidget.cpp +++ b/retroshare-gui/src/gui/elastic/graphwidget.cpp @@ -297,7 +297,7 @@ void GraphWidget::setNameSearch(QString s) if (s.length() == 0){ for(uint32_t i=0;i<_nodes.size();++i) - _nodes[i]->setNodeDrawSize(12 * f); + _nodes[i]->setNodeDrawSize(12 * f, false); forceRedraw(); return; } @@ -309,10 +309,10 @@ void GraphWidget::setNameSearch(QString s) if (ns.find(qs) != std::string::npos) { //std::cout << "found!" << '\n'; - ni->setNodeDrawSize(22 * f); + ni->setNodeDrawSize(22 * f, true); //std::cout << ni->getNodeDrawSize() << '\n'; } else { - ni->setNodeDrawSize(12 * f); + ni->setNodeDrawSize(12 * f, false); } }