mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
gui: network_view: add coloring edges for searched and selected nodes
didn't bother to check edges repaints every now and again commented out nevertheles
This commit is contained in:
parent
0d7174225f
commit
7d8f23259c
@ -96,6 +96,12 @@ QRectF Edge::boundingRect() const
|
|||||||
.adjusted(-extra, -extra, extra, extra);
|
.adjusted(-extra, -extra, extra, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Edge::setEdgeColor(QColor color)
|
||||||
|
{
|
||||||
|
edgeColor = color;
|
||||||
|
update(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||||
{
|
{
|
||||||
if (!source || !dest)
|
if (!source || !dest)
|
||||||
@ -103,7 +109,7 @@ void Edge::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
|||||||
|
|
||||||
// Draw the line itself
|
// Draw the line itself
|
||||||
QLineF line(sourcePoint, destPoint);
|
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);
|
painter->drawLine(line);
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
void setDestNode(Node *node);
|
void setDestNode(Node *node);
|
||||||
|
|
||||||
void adjust();
|
void adjust();
|
||||||
|
void setEdgeColor(QColor color);
|
||||||
|
|
||||||
enum { Type = UserType + 2 };
|
enum { Type = UserType + 2 };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
@ -54,6 +55,7 @@ private:
|
|||||||
QPointF sourcePoint;
|
QPointF sourcePoint;
|
||||||
QPointF destPoint;
|
QPointF destPoint;
|
||||||
qreal arrowSize;
|
qreal arrowSize;
|
||||||
|
QColor edgeColor = Qt::black;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -251,23 +251,48 @@ static QColor lightdark(const QColor& col,int l,int d)
|
|||||||
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
|
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) } ;
|
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 ;
|
QColor col0 ;
|
||||||
|
|
||||||
|
// selected_node = clicked on with left mouse button
|
||||||
if(_selected_node == NULL)
|
if(_selected_node == NULL)
|
||||||
|
{
|
||||||
col0 = type_color[_type] ;
|
col0 = type_color[_type] ;
|
||||||
|
|
||||||
|
/* if (sought_for) // this node
|
||||||
|
{
|
||||||
|
// repaint edge
|
||||||
|
for (QList<Edge*>::const_iterator it(edgeList.begin()); it != edgeList.end(); ++it)
|
||||||
|
(*it)->setEdgeColor(searched_node_edge);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (QList<Edge*>::const_iterator it(edgeList.begin()); it != edgeList.end(); ++it)
|
||||||
|
(*it)->setEdgeColor(default_edge);
|
||||||
|
} */
|
||||||
|
}
|
||||||
else if(_selected_node == this)
|
else if(_selected_node == this)
|
||||||
|
{
|
||||||
|
// for (QList<Edge*>::const_iterator it(edgeList.begin()); it != edgeList.end(); ++it)
|
||||||
|
// (*it)->setEdgeColor(selected_node_edge);
|
||||||
col0 = type_color[0] ;
|
col0 = type_color[0] ;
|
||||||
|
}
|
||||||
|
// selected_node = some_other_node
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool found = false ;
|
bool found = false ;
|
||||||
for(QList<Edge*>::const_iterator it(edgeList.begin());it!=edgeList.end();++it)
|
for (QList<Edge*>::const_iterator it(edgeList.begin()); it != edgeList.end(); ++it)
|
||||||
|
{
|
||||||
if( (*it)->sourceNode() == _selected_node || (*it)->destNode() == _selected_node)
|
if( (*it)->sourceNode() == _selected_node || (*it)->destNode() == _selected_node)
|
||||||
{
|
{
|
||||||
col0 = type_color[1] ;
|
col0 = type_color[1] ;
|
||||||
found = true ;
|
found = true ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!found)
|
if(!found)
|
||||||
col0= type_color[2] ;
|
col0= type_color[2] ;
|
||||||
|
@ -65,7 +65,7 @@ public:
|
|||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
QPainterPath shape() 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;}
|
int getNodeDrawSize(){return mNodeDrawSize;}
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
@ -95,6 +95,7 @@ private:
|
|||||||
bool mDeterminedBB ;
|
bool mDeterminedBB ;
|
||||||
int mBBWidth ;
|
int mBBWidth ;
|
||||||
int mNodeDrawSize;
|
int mNodeDrawSize;
|
||||||
|
bool sought_for = false;
|
||||||
|
|
||||||
static Node *_selected_node ;
|
static Node *_selected_node ;
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ void GraphWidget::setNameSearch(QString s)
|
|||||||
|
|
||||||
if (s.length() == 0){
|
if (s.length() == 0){
|
||||||
for(uint32_t i=0;i<_nodes.size();++i)
|
for(uint32_t i=0;i<_nodes.size();++i)
|
||||||
_nodes[i]->setNodeDrawSize(12 * f);
|
_nodes[i]->setNodeDrawSize(12 * f, false);
|
||||||
forceRedraw();
|
forceRedraw();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -309,10 +309,10 @@ void GraphWidget::setNameSearch(QString s)
|
|||||||
|
|
||||||
if (ns.find(qs) != std::string::npos) {
|
if (ns.find(qs) != std::string::npos) {
|
||||||
//std::cout << "found!" << '\n';
|
//std::cout << "found!" << '\n';
|
||||||
ni->setNodeDrawSize(22 * f);
|
ni->setNodeDrawSize(22 * f, true);
|
||||||
//std::cout << ni->getNodeDrawSize() << '\n';
|
//std::cout << ni->getNodeDrawSize() << '\n';
|
||||||
} else {
|
} else {
|
||||||
ni->setNodeDrawSize(12 * f);
|
ni->setNodeDrawSize(12 * f, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user