diff --git a/retroshare-gui/src/gui/NetworkView.cpp b/retroshare-gui/src/gui/NetworkView.cpp index b5a1ba081..3fbdb72bd 100644 --- a/retroshare-gui/src/gui/NetworkView.cpp +++ b/retroshare-gui/src/gui/NetworkView.cpp @@ -30,6 +30,8 @@ #include #include +#include "gui/elastic/node.h" + /** Constructor */ NetworkView::NetworkView(QWidget *parent) : MainPage(parent) @@ -154,11 +156,25 @@ void NetworkView::insertPeers() if (rsPeers->isFriend(*it)) { - type = 2; + type = ELASTIC_NODE_TYPE_FRIEND; } else { - type = 3; + RsPeerDetails detail; + rsPeers->getPeerDetails(*it, detail); + + if(detail.trustLvl > RS_TRUST_LVL_MARGINAL) + { + type = ELASTIC_NODE_TYPE_AUTHED; + } + else if (detail.trustLvl >= RS_TRUST_LVL_MARGINAL) + { + type = ELASTIC_NODE_TYPE_MARGINALAUTH; + } + else + { + type = ELASTIC_NODE_TYPE_FOF; + } } ui.graphicsView->addNode(type, *it, name); diff --git a/retroshare-gui/src/gui/elastic/node.cpp b/retroshare-gui/src/gui/elastic/node.cpp index fd2947a93..ba3cde2f8 100644 --- a/retroshare-gui/src/gui/elastic/node.cpp +++ b/retroshare-gui/src/gui/elastic/node.cpp @@ -38,11 +38,13 @@ #include #include #include +#include #include "edge.h" #include "node.h" #include "graphwidget.h" #include +#include "rsiface/rspeers.h" Node::Node(GraphWidget *graphWidget, uint32_t t, std::string id_in, std::string n) : graph(graphWidget), ntype(t), id(id_in), name(n), @@ -171,8 +173,22 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid } else if (ntype == ELASTIC_NODE_TYPE_FRIEND) { + col0 = QColor(Qt::green); + col1 = QColor(Qt::darkGreen); + } + else if (ntype == ELASTIC_NODE_TYPE_AUTHED) + { + //col0 = QColor(Qt::cyan); + //col1 = QColor(Qt::darkCyan); + //col0 = QColor(Qt::blue); + col0 = QColor(Qt::cyan); - col1 = QColor(Qt::blue); + col1 = QColor(Qt::darkBlue); + } + else if (ntype == ELASTIC_NODE_TYPE_MARGINALAUTH) + { + col0 = QColor(Qt::magenta); + col1 = QColor(Qt::darkMagenta); } else { @@ -229,3 +245,61 @@ void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) update(); QGraphicsItem::mouseReleaseEvent(event); } + +void Node::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + RsPeerDetails details; + if (!rsPeers->getPeerDetails(id, details)) + { + event->accept(); + return; + } + + /* no events for self */ + if (ntype == ELASTIC_NODE_TYPE_OWN) + { + event->accept(); + return; + } + + QString menuTitle = "Menu for "; + menuTitle += QString::fromStdString(details.name); + + QMenu menu; + QAction *titleAction = menu.addAction(menuTitle); + titleAction->setEnabled(false); + + switch(ntype) + { + case ELASTIC_NODE_TYPE_OWN: + { + break; + } + case ELASTIC_NODE_TYPE_FRIEND: + { + + //QAction *rmAction = menu.addAction("Remove Friend"); + //QAction *chatAction = menu.addAction("Chat"); + //QAction *msgAction = menu.addAction("Msg"); + break; + } + case ELASTIC_NODE_TYPE_AUTHED: + { + //QAction *addAction = menu.addAction("Add Friend"); + break; + } + case ELASTIC_NODE_TYPE_MARGINALAUTH: + { + //QAction *makeAction = menu.addAction("Make Friend"); + break; + } + default: + case ELASTIC_NODE_TYPE_FOF: + { + //QAction *makeAction = menu.addAction("Make Friend"); + break; + } + } + QAction *selectedAction = menu.exec(event->screenPos()); +} + diff --git a/retroshare-gui/src/gui/elastic/node.h b/retroshare-gui/src/gui/elastic/node.h index 7350572cd..4e3e2f262 100644 --- a/retroshare-gui/src/gui/elastic/node.h +++ b/retroshare-gui/src/gui/elastic/node.h @@ -45,7 +45,9 @@ #define ELASTIC_NODE_TYPE_OWN 1 #define ELASTIC_NODE_TYPE_FRIEND 2 -#define ELASTIC_NODE_TYPE_FOF 3 +#define ELASTIC_NODE_TYPE_AUTHED 3 +#define ELASTIC_NODE_TYPE_MARGINALAUTH 4 +#define ELASTIC_NODE_TYPE_FOF 5 class Edge; class GraphWidget; @@ -74,7 +76,8 @@ protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - + void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); + private: QList edgeList; QPointF newPos;