mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-25 01:10:19 -05:00
Added More alternative colours to NetworkView.
* Yellow - yourself. * Green - your friends. * Blue - other Authed People. * Magenta - partially Authed People. * Red - unknown people. Added Context Menu. This is empty now (as we are heading for a release). The code to add specific menu items to rm/add friends is there - just commented out. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1225 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b212f65f69
commit
e71d289e0e
@ -30,6 +30,8 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#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);
|
||||
|
@ -38,11 +38,13 @@
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include <QMenu>
|
||||
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
#include "graphwidget.h"
|
||||
#include <math.h>
|
||||
#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());
|
||||
}
|
||||
|
||||
|
@ -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<Edge *> edgeList;
|
||||
QPointF newPos;
|
||||
|
Loading…
x
Reference in New Issue
Block a user