mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-05 13:19:32 -04:00
added search and highlighting to network graph (patch from Chozabu)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8368 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
eb7a52a2a7
commit
9e1a368061
7 changed files with 78 additions and 18 deletions
|
@ -58,6 +58,7 @@ NetworkView::NetworkView(QWidget *parent)
|
||||||
connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int)));
|
connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int)));
|
||||||
connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int)));
|
connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int)));
|
||||||
connect( ui.freezeCheckBox, SIGNAL(toggled(bool)), this, SLOT(setFreezeState(bool)));
|
connect( ui.freezeCheckBox, SIGNAL(toggled(bool)), this, SLOT(setFreezeState(bool)));
|
||||||
|
connect( ui.nameBox, SIGNAL(textChanged(QString)), this, SLOT(setNameSearch(QString)));
|
||||||
|
|
||||||
_should_update = true ;
|
_should_update = true ;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +73,10 @@ void NetworkView::setEdgeLength(int l)
|
||||||
{
|
{
|
||||||
ui.graphicsView->setEdgeLength(l);
|
ui.graphicsView->setEdgeLength(l);
|
||||||
}
|
}
|
||||||
|
void NetworkView::setNameSearch(QString s)
|
||||||
|
{
|
||||||
|
ui.graphicsView->setNameSearch(s);
|
||||||
|
}
|
||||||
void NetworkView::setMaxFriendLevel(int m)
|
void NetworkView::setMaxFriendLevel(int m)
|
||||||
{
|
{
|
||||||
ui.graphicsView->snapshotNodesPositions() ;
|
ui.graphicsView->snapshotNodesPositions() ;
|
||||||
|
|
|
@ -47,6 +47,7 @@ class NetworkView : public RsAutoUpdatePage
|
||||||
|
|
||||||
void setMaxFriendLevel(int) ;
|
void setMaxFriendLevel(int) ;
|
||||||
void setEdgeLength(int) ;
|
void setEdgeLength(int) ;
|
||||||
|
void setNameSearch(QString) ;
|
||||||
|
|
||||||
void changedFoFCheckBox( );
|
void changedFoFCheckBox( );
|
||||||
void redraw();
|
void redraw();
|
||||||
|
|
|
@ -11,15 +11,24 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="horizontalSpacing">
|
<property name="horizontalSpacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="GraphWidget" name="graphicsView"/>
|
<widget class="GraphWidget" name="graphicsView"/>
|
||||||
</item>
|
</item>
|
||||||
|
@ -31,14 +40,21 @@
|
||||||
<property name="verticalSpacing">
|
<property name="verticalSpacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="3">
|
||||||
<widget class="QPushButton" name="refreshButton">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Redraw</string>
|
<string>Edge length:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5">
|
<item row="0" column="7">
|
||||||
|
<widget class="QCheckBox" name="freezeCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Freeze</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="6">
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -84,17 +100,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QPushButton" name="refreshButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Edge length:</string>
|
<string>Redraw</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="6">
|
<item row="0" column="5">
|
||||||
<widget class="QCheckBox" name="freezeCheckBox">
|
<widget class="QLineEdit" name="nameBox">
|
||||||
<property name="text">
|
<property name="minimumSize">
|
||||||
<string>Freeze</string>
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -388,6 +388,33 @@ void GraphWidget::setEdgeLength(uint32_t l)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GraphWidget::setNameSearch(QString s)
|
||||||
|
{
|
||||||
|
if (s.length() == 0){
|
||||||
|
for(uint32_t i=0;i<_nodes.size();++i)
|
||||||
|
_nodes[i]->setNodeDrawSize(20);
|
||||||
|
forceRedraw();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string qs = s.toLower().toStdString();
|
||||||
|
for(uint32_t i=0;i<_nodes.size();++i){
|
||||||
|
Node* ni = _nodes[i];
|
||||||
|
//std::cout << ni->descString() << std::endl;
|
||||||
|
std::string ns = QString::fromStdString(ni->descString()).toLower().toStdString();
|
||||||
|
|
||||||
|
if (ns.find(qs) != std::string::npos) {
|
||||||
|
std::cout << "found!" << '\n';
|
||||||
|
ni->setNodeDrawSize(22);
|
||||||
|
//std::cout << ni->getNodeDrawSize() << '\n';
|
||||||
|
} else {
|
||||||
|
ni->setNodeDrawSize(12);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
forceRedraw();
|
||||||
|
}
|
||||||
|
|
||||||
void GraphWidget::forceRedraw()
|
void GraphWidget::forceRedraw()
|
||||||
{
|
{
|
||||||
for(uint32_t i=0;i<_nodes.size();++i)
|
for(uint32_t i=0;i<_nodes.size();++i)
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
virtual void itemMoved();
|
virtual void itemMoved();
|
||||||
|
|
||||||
void setEdgeLength(uint32_t l) ;
|
void setEdgeLength(uint32_t l) ;
|
||||||
|
void setNameSearch(QString) ;
|
||||||
uint32_t edgeLength() const { return _edge_length ; }
|
uint32_t edgeLength() const { return _edge_length ; }
|
||||||
|
|
||||||
void forceRedraw() ;
|
void forceRedraw() ;
|
||||||
|
|
|
@ -78,6 +78,7 @@ Node::Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget
|
||||||
setZValue(1);
|
setZValue(1);
|
||||||
mDeterminedBB = false ;
|
mDeterminedBB = false ;
|
||||||
mBBWidth = 0 ;
|
mBBWidth = 0 ;
|
||||||
|
mNodeDrawSize = 20;
|
||||||
|
|
||||||
_speedx=_speedy=0;
|
_speedx=_speedy=0;
|
||||||
_steps=0;
|
_steps=0;
|
||||||
|
@ -284,7 +285,7 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
||||||
|
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(Qt::darkGray);
|
painter->setBrush(Qt::darkGray);
|
||||||
painter->drawEllipse(-7, -7, 20, 20);
|
painter->drawEllipse(-7, -7, mNodeDrawSize, mNodeDrawSize);
|
||||||
|
|
||||||
QRadialGradient gradient(-3, -3, 10);
|
QRadialGradient gradient(-3, -3, 10);
|
||||||
if (option->state & QStyle::State_Sunken)
|
if (option->state & QStyle::State_Sunken)
|
||||||
|
@ -311,7 +312,7 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
||||||
}
|
}
|
||||||
painter->setBrush(gradient);
|
painter->setBrush(gradient);
|
||||||
painter->setPen(QPen(Qt::black, 0));
|
painter->setPen(QPen(Qt::black, 0));
|
||||||
painter->drawEllipse(-10, -10, 20, 20);
|
painter->drawEllipse(-10, -10, mNodeDrawSize, mNodeDrawSize);
|
||||||
painter->drawText(-10, 0, QString::fromUtf8(_desc_string.c_str()));
|
painter->drawText(-10, 0, QString::fromUtf8(_desc_string.c_str()));
|
||||||
|
|
||||||
if (!mDeterminedBB)
|
if (!mDeterminedBB)
|
||||||
|
|
|
@ -74,12 +74,17 @@ public:
|
||||||
|
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
std::string idString() const { return _gpg_id.toStdString() ; }
|
std::string idString() const { return _gpg_id.toStdString() ; }
|
||||||
|
std::string descString() const { return _desc_string ; }
|
||||||
|
|
||||||
void calculateForces(const double *data,int width,int height,int W,int H,float x,float y,float speedf);
|
void calculateForces(const double *data,int width,int height,int W,int H,float x,float y,float speedf);
|
||||||
bool advance();
|
bool advance();
|
||||||
|
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
QPainterPath shape() const;
|
QPainterPath shape() const;
|
||||||
|
|
||||||
|
void setNodeDrawSize(int nds){mNodeDrawSize = nds;}
|
||||||
|
int getNodeDrawSize(){return mNodeDrawSize;}
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
int n_edges() const { return edgeList.size() ; }
|
int n_edges() const { return edgeList.size() ; }
|
||||||
|
@ -106,6 +111,7 @@ private:
|
||||||
GraphWidget::AuthType _auth ;
|
GraphWidget::AuthType _auth ;
|
||||||
bool mDeterminedBB ;
|
bool mDeterminedBB ;
|
||||||
int mBBWidth ;
|
int mBBWidth ;
|
||||||
|
int mNodeDrawSize;
|
||||||
|
|
||||||
static Node *_selected_node ;
|
static Node *_selected_node ;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue