mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 07:59:29 -05:00
added context menu to networkview
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3770 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f7d5836a86
commit
ca45c73dc2
@ -226,7 +226,7 @@ void NetworkView::updateDisplay()
|
||||
|
||||
if(_node_ids.find(info.ssl_id) == _node_ids.end())
|
||||
{
|
||||
_node_ids[info.ssl_id] = ui.graphicsView->addNode(" "+detail.name +"("+detail.location+")", "("+detail.name+","+info.ssl_id+","+detail.gpg_id+")",type,auth);
|
||||
_node_ids[info.ssl_id] = ui.graphicsView->addNode(" "+detail.name +"("+detail.location+")", "("+detail.name+","+info.ssl_id+","+detail.gpg_id+")",type,auth,info.ssl_id,info.gpg_id);
|
||||
#ifdef DEBUG_NETWORKVIEW
|
||||
std::cerr << " inserted node " << info.ssl_id << ", type=" << type << ", auth=" << auth << std::endl ;
|
||||
std::cerr << " NetworkView::updateDisplay() Added Friend: " << info.ssl_id << std::endl;
|
||||
|
@ -123,11 +123,11 @@ void fourn(double data[],unsigned long nn[],unsigned long ndim,int isign)
|
||||
GraphWidget::GraphWidget(QWidget *)
|
||||
: timerId(0)
|
||||
{
|
||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||
QGraphicsScene *scene = new QGraphicsScene(QRectF(0,0,500,500),this);
|
||||
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
scene->clear() ;
|
||||
scene->setSceneRect(-200, -200, 1000, 1000);
|
||||
setScene(scene);
|
||||
scene->setSceneRect(0, 0, 500, 500);
|
||||
|
||||
setCacheMode(CacheBackground);
|
||||
setViewportUpdateMode(BoundingRectViewportUpdate);
|
||||
@ -138,8 +138,8 @@ GraphWidget::GraphWidget(QWidget *)
|
||||
|
||||
|
||||
scale(qreal(0.8), qreal(0.8));
|
||||
setMinimumSize(400, 400);
|
||||
setWindowTitle(tr("Elastic Nodes"));
|
||||
setMinimumSize(500, 500);
|
||||
//setWindowTitle(tr("Elastic Nodes"));
|
||||
}
|
||||
|
||||
void GraphWidget::clearGraph()
|
||||
@ -162,9 +162,9 @@ void GraphWidget::clearGraph()
|
||||
_nodes.clear();
|
||||
}
|
||||
|
||||
GraphWidget::NodeId GraphWidget::addNode(const std::string& node_short_string,const std::string& node_complete_string,NodeType type,AuthType auth)
|
||||
GraphWidget::NodeId GraphWidget::addNode(const std::string& node_short_string,const std::string& node_complete_string,NodeType type,AuthType auth,const std::string& ssl_id,const std::string& gpg_id)
|
||||
{
|
||||
Node *node = new Node(node_short_string,type,auth,this);
|
||||
Node *node = new Node(node_short_string,type,auth,this,ssl_id,gpg_id);
|
||||
node->setToolTip(QString::fromStdString(node_complete_string)) ;
|
||||
_nodes.push_back(node) ;
|
||||
scene()->addItem(node);
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
ELASTIC_NODE_AUTH_UNKNOWN = 0x0002
|
||||
} AuthType ;
|
||||
|
||||
NodeId addNode(const std::string& NodeShortText,const std::string& nodeCompleteText,NodeType type,AuthType auth) ;
|
||||
NodeId addNode(const std::string& NodeShortText,const std::string& nodeCompleteText,NodeType type,AuthType auth,const std::string& ssl_id,const std::string& gpg_id) ;
|
||||
EdgeId addEdge(NodeId n1,NodeId n2) ;
|
||||
|
||||
void clearGraph() ;
|
||||
|
@ -39,20 +39,31 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QStyleOption>
|
||||
#include <iostream>
|
||||
|
||||
#include <math.h>
|
||||
#include <gui/connect/ConfCertDialog.h>
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include "edge.h"
|
||||
#include "node.h"
|
||||
#include "graphwidget.h"
|
||||
|
||||
Node::Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget::AuthType auth,GraphWidget *graphWidget)
|
||||
: graph(graphWidget),_desc_string(node_string),_type(type),_auth(auth)
|
||||
#define IMAGE_AUTHED ":/images/accepted16.png"
|
||||
#define IMAGE_DENIED ":/images/denied16.png"
|
||||
#define IMAGE_TRUSTED ":/images/rs-2.png"
|
||||
#define IMAGE_MAKEFRIEND ":/images/user/add_user16.png"
|
||||
|
||||
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)
|
||||
{
|
||||
setFlag(ItemIsMovable);
|
||||
#if QT_VERSION >= 0x040600
|
||||
@ -280,8 +291,36 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
|
||||
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
update();
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
update();
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void Node::peerDetails()
|
||||
{
|
||||
std::cerr << "Calling peer details" << std::endl;
|
||||
ConfCertDialog::showIt(_ssl_id, ConfCertDialog::PageDetails);
|
||||
}
|
||||
void Node::makeFriend()
|
||||
{
|
||||
ConfCertDialog::showIt(_gpg_id, ConfCertDialog::PageTrust);
|
||||
}
|
||||
void Node::denyFriend()
|
||||
{
|
||||
ConfCertDialog::showIt(_gpg_id, ConfCertDialog::PageTrust);
|
||||
}
|
||||
|
||||
void Node::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
QMenu contextMnu ;
|
||||
|
||||
if(_type == GraphWidget::ELASTIC_NODE_TYPE_FRIEND)
|
||||
contextMnu.addAction(QIcon(IMAGE_DENIED), QObject::tr( "Deny friend" ), this, SLOT(denyFriend()) );
|
||||
else if(_type != GraphWidget::ELASTIC_NODE_TYPE_OWN)
|
||||
contextMnu.addAction(QIcon(IMAGE_MAKEFRIEND), QObject::tr( "Make friend" ), this, SLOT(makeFriend()) );
|
||||
|
||||
contextMnu.addAction(QIcon(IMAGE_MAKEFRIEND), QObject::tr( "Peer details" ), this, SLOT(peerDetails()) );
|
||||
|
||||
contextMnu.exec(event->screenPos());
|
||||
}
|
||||
|
||||
void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
@ -52,10 +52,12 @@ QT_BEGIN_NAMESPACE
|
||||
class QGraphicsSceneMouseEvent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class Node : public QGraphicsItem
|
||||
class Node : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget::AuthType auth,GraphWidget *graphWidget);
|
||||
Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget::AuthType auth,GraphWidget *graphWidget,const std::string& ssl_id,const std::string& gpg_id);
|
||||
|
||||
void addEdge(Edge *edge);
|
||||
const QList<Edge *>& edges() const;
|
||||
@ -75,7 +77,13 @@ protected:
|
||||
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *) ;
|
||||
|
||||
protected slots:
|
||||
void denyFriend() ;
|
||||
void makeFriend() ;
|
||||
void peerDetails() ;
|
||||
private:
|
||||
QList<Edge *> edgeList;
|
||||
QPointF newPos;
|
||||
@ -88,6 +96,9 @@ private:
|
||||
bool mDeterminedBB ;
|
||||
int mBBWidth ;
|
||||
|
||||
std::string _ssl_id ;
|
||||
std::string _gpg_id ;
|
||||
|
||||
static const float MASS_FACTOR = 10 ;
|
||||
static const float FRICTION_FACTOR = 6.8 ;
|
||||
static const float REPULSION_FACTOR = 4 ;
|
||||
|
Loading…
Reference in New Issue
Block a user