* minor changes required to get the gui working with PGP,

* improved NetworkView to show signatures, and friends.

I expect these will be cleaned up later - these were purely functional so i could test pgp.

Enable using RS_USE_PGPSSL in rsiface/rsinit.h
   


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1266 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2009-05-23 15:13:01 +00:00
parent 5f28f76b07
commit 100cf75439
19 changed files with 695 additions and 208 deletions

View file

@ -0,0 +1,139 @@
/****************************************************************************
**
** Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.
**
** This file is part of the example classes of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.0, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** In addition, as a special exception, Trolltech, as the sole copyright
** holder for Qt Designer, grants users of the Qt/Eclipse Integration
** plug-in the right for the Qt/Eclipse Integration to link to
** functionality provided by Qt Designer and its related libraries.
**
** Trolltech reserves all rights not expressly granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include <QPainter>
#include "arrow.h"
#include "node.h"
#include <math.h>
static const double Pi = 3.14159265358979323846264338327950288419717;
static double TwoPi = 2.0 * Pi;
Arrow::Arrow(Node *sourceNode, Node *destNode)
: arrowSize(10)
{
setAcceptedMouseButtons(0);
source = sourceNode;
dest = destNode;
source->addArrow(this);
dest->addArrow(this);
adjust();
}
Arrow::~Arrow()
{
}
Node *Arrow::sourceNode() const
{
return source;
}
void Arrow::setSourceNode(Node *node)
{
source = node;
adjust();
}
Node *Arrow::destNode() const
{
return dest;
}
void Arrow::setDestNode(Node *node)
{
dest = node;
adjust();
}
void Arrow::adjust()
{
if (!source || !dest)
return;
QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0));
qreal length = line.length();
QPointF edgeOffset((line.dx() * 10) / length, (line.dy() * 10) / length);
prepareGeometryChange();
sourcePoint = line.p1() + edgeOffset;
destPoint = line.p2() - edgeOffset;
}
QRectF Arrow::boundingRect() const
{
if (!source || !dest)
return QRectF();
qreal penWidth = 1;
qreal extra = (penWidth + arrowSize) / 2.0;
return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(),
destPoint.y() - sourcePoint.y()))
.normalized()
.adjusted(-extra, -extra, extra, extra);
}
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
if (!source || !dest)
return;
// Draw the line itself
QLineF line(sourcePoint, destPoint);
painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter->drawLine(line);
// Draw the arrows if there's enough room
double angle = ::acos(line.dx() / line.length());
if (line.dy() >= 0)
angle = TwoPi - angle;
QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize,
cos(angle + Pi / 3) * arrowSize);
QPointF sourceArrowP2 = sourcePoint + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
cos(angle + Pi - Pi / 3) * arrowSize);
QPointF destArrowP1 = destPoint + QPointF(sin(angle - Pi / 3) * arrowSize,
cos(angle - Pi / 3) * arrowSize);
QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize,
cos(angle - Pi + Pi / 3) * arrowSize);
painter->setBrush(Qt::black);
painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2);
painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
}

View file

@ -0,0 +1,73 @@
/****************************************************************************
**
** Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.
**
** This file is part of the example classes of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.0, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** In addition, as a special exception, Trolltech, as the sole copyright
** holder for Qt Designer, grants users of the Qt/Eclipse Integration
** plug-in the right for the Qt/Eclipse Integration to link to
** functionality provided by Qt Designer and its related libraries.
**
** Trolltech reserves all rights not expressly granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#ifndef ARROW_H
#define ARROW_H
#include <QGraphicsItem>
class Node;
class Arrow : public QGraphicsItem
{
public:
Arrow(Node *sourceNode, Node *destNode);
~Arrow();
Node *sourceNode() const;
void setSourceNode(Node *node);
Node *destNode() const;
void setDestNode(Node *node);
void adjust();
enum { Type = UserType + 2 };
int type() const { return Type; }
protected:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
Node *source, *dest;
QPointF sourcePoint;
QPointF destPoint;
qreal arrowSize;
};
#endif

View file

@ -36,6 +36,7 @@
#include "graphwidget.h"
#include "edge.h"
#include "arrow.h"
#include "node.h"
#include <QDebug>
@ -96,26 +97,10 @@ bool GraphWidget::clearGraph()
delete oldscene;
}
if (oldcenterNode)
{
//delete oldcenterNode;
}
nodeMap.clear();
edgeList.clear();
std::list<Edge *>::iterator eit;
std::map<std::string, Node *>::iterator it;
for(eit = edgeList.begin(); eit != edgeList.end(); eit++)
{
//delete(*eit);
}
for(it = nodeMap.begin(); it != nodeMap.end(); it++)
{
//delete(it->second);
}
nodeMap.clear();
edgeList.clear();
return true;
return true;
}
void GraphWidget::addNode(uint32_t type, std::string id, std::string name)
@ -161,10 +146,43 @@ void GraphWidget::addEdge(std::string id1, std::string id2)
}
}
void GraphWidget::addArrow(std::string id1, std::string id2)
{
std::map<std::string, Node *>::iterator it;
Node *n1 = NULL;
Node *n2 = NULL;
if (id1 == "")
{
n1 = centerNode;
}
else
{
it = nodeMap.find(id1);
if (it != nodeMap.end())
{
n1 = it->second;
}
}
it = nodeMap.find(id2);
if (it != nodeMap.end())
{
n2 = it->second;
}
if ((n1) && (n2))
{
Arrow *arrow = new Arrow(n1, n2);
scene()->addItem(arrow);
arrowList.push_back(arrow);
}
}
void GraphWidget::itemMoved()
{
if (!timerId)
timerId = startTimer(1000 / 25);
timerId = startTimer(1000 / 10);
}
void GraphWidget::keyPressEvent(QKeyEvent *event)

View file

@ -44,6 +44,7 @@
class Node;
class Edge;
class Arrow;
class GraphWidget : public QGraphicsView
{
@ -57,6 +58,7 @@ public:
bool clearGraph();
void addNode(uint32_t type, std::string id, std::string name);
void addEdge(std::string id1, std::string id2);
void addArrow(std::string id1, std::string id2);
protected:
void keyPressEvent(QKeyEvent *event);
@ -72,6 +74,7 @@ private:
std::map<std::string, Node *> nodeMap;
std::list<Edge *> edgeList;
std::list<Arrow *> arrowList;
};
#endif

View file

@ -41,6 +41,7 @@
#include <QMenu>
#include "edge.h"
#include "arrow.h"
#include "node.h"
#include "graphwidget.h"
#include <math.h>
@ -65,6 +66,17 @@ QList<Edge *> Node::edges() const
return edgeList;
}
void Node::addArrow(Arrow *arrow)
{
arrowList << arrow;
arrow->adjust();
}
QList<Arrow *> Node::arrows() const
{
return arrowList;
}
void Node::calculateForces()
{
if (!scene() || scene()->mouseGrabberItem() == this) {
@ -103,6 +115,20 @@ void Node::calculateForces()
yvel += pos.y() / weight;
}
// Now subtract all forces pulling items together
// alternative weight??
weight = sqrt(arrowList.size() + 1) * 10;
foreach (Arrow *arrow, arrowList) {
QPointF pos;
if (arrow->sourceNode() == this)
pos = mapFromItem(arrow->destNode(), 0, 0);
else
pos = mapFromItem(arrow->sourceNode(), 0, 0);
xvel += pos.x() / weight;
yvel += pos.y() / weight;
}
// push away from edges too.
QRectF sceneRect = scene()->sceneRect();
int mid_x = (sceneRect.left() + sceneRect.right()) / 2;

View file

@ -50,6 +50,7 @@
#define ELASTIC_NODE_TYPE_FOF 5
class Edge;
class Arrow;
class GraphWidget;
class QGraphicsSceneMouseEvent;
@ -61,6 +62,9 @@ public:
void addEdge(Edge *edge);
QList<Edge *> edges() const;
void addArrow(Arrow *arrow);
QList<Arrow *> arrows() const;
enum { Type = UserType + 1 };
int type() const { return Type; }
@ -80,6 +84,7 @@ protected:
private:
QList<Edge *> edgeList;
QList<Arrow *> arrowList;
QPointF newPos;
GraphWidget *graph;