mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 16:39:43 -05: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
@ -58,6 +58,7 @@ NetworkView::NetworkView(QWidget *parent)
|
||||
connect( ui.maxFriendLevelSB, SIGNAL(valueChanged(int)), this, SLOT(setMaxFriendLevel(int)));
|
||||
connect( ui.edgeLengthSB, SIGNAL(valueChanged(int)), this, SLOT(setEdgeLength(int)));
|
||||
connect( ui.freezeCheckBox, SIGNAL(toggled(bool)), this, SLOT(setFreezeState(bool)));
|
||||
connect( ui.nameBox, SIGNAL(textChanged(QString)), this, SLOT(setNameSearch(QString)));
|
||||
|
||||
_should_update = true ;
|
||||
}
|
||||
@ -72,6 +73,10 @@ void NetworkView::setEdgeLength(int l)
|
||||
{
|
||||
ui.graphicsView->setEdgeLength(l);
|
||||
}
|
||||
void NetworkView::setNameSearch(QString s)
|
||||
{
|
||||
ui.graphicsView->setNameSearch(s);
|
||||
}
|
||||
void NetworkView::setMaxFriendLevel(int m)
|
||||
{
|
||||
ui.graphicsView->snapshotNodesPositions() ;
|
||||
|
@ -47,6 +47,7 @@ class NetworkView : public RsAutoUpdatePage
|
||||
|
||||
void setMaxFriendLevel(int) ;
|
||||
void setEdgeLength(int) ;
|
||||
void setNameSearch(QString) ;
|
||||
|
||||
void changedFoFCheckBox( );
|
||||
void redraw();
|
||||
|
@ -11,15 +11,24 @@
|
||||
</rect>
|
||||
</property>
|
||||
<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">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="GraphWidget" name="graphicsView"/>
|
||||
</item>
|
||||
@ -31,14 +40,21 @@
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="refreshButton">
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Redraw</string>
|
||||
<string>Edge length:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -84,17 +100,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="refreshButton">
|
||||
<property name="text">
|
||||
<string>Edge length:</string>
|
||||
<string>Redraw</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QCheckBox" name="freezeCheckBox">
|
||||
<property name="text">
|
||||
<string>Freeze</string>
|
||||
<item row="0" column="5">
|
||||
<widget class="QLineEdit" name="nameBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</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()
|
||||
{
|
||||
for(uint32_t i=0;i<_nodes.size();++i)
|
||||
|
@ -86,6 +86,7 @@ public:
|
||||
virtual void itemMoved();
|
||||
|
||||
void setEdgeLength(uint32_t l) ;
|
||||
void setNameSearch(QString) ;
|
||||
uint32_t edgeLength() const { return _edge_length ; }
|
||||
|
||||
void forceRedraw() ;
|
||||
|
@ -78,6 +78,7 @@ Node::Node(const std::string& node_string,GraphWidget::NodeType type,GraphWidget
|
||||
setZValue(1);
|
||||
mDeterminedBB = false ;
|
||||
mBBWidth = 0 ;
|
||||
mNodeDrawSize = 20;
|
||||
|
||||
_speedx=_speedy=0;
|
||||
_steps=0;
|
||||
@ -284,7 +285,7 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
||||
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(Qt::darkGray);
|
||||
painter->drawEllipse(-7, -7, 20, 20);
|
||||
painter->drawEllipse(-7, -7, mNodeDrawSize, mNodeDrawSize);
|
||||
|
||||
QRadialGradient gradient(-3, -3, 10);
|
||||
if (option->state & QStyle::State_Sunken)
|
||||
@ -311,7 +312,7 @@ void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
||||
}
|
||||
painter->setBrush(gradient);
|
||||
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()));
|
||||
|
||||
if (!mDeterminedBB)
|
||||
|
@ -72,14 +72,19 @@ public:
|
||||
void addEdge(Edge *edge);
|
||||
const QList<Edge *>& edges() const;
|
||||
|
||||
int type() const { return Type; }
|
||||
std::string idString() const { return _gpg_id.toStdString() ; }
|
||||
int type() const { return Type; }
|
||||
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);
|
||||
bool advance();
|
||||
|
||||
QRectF boundingRect() const;
|
||||
QPainterPath shape() const;
|
||||
|
||||
void setNodeDrawSize(int nds){mNodeDrawSize = nds;}
|
||||
int getNodeDrawSize(){return mNodeDrawSize;}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
int n_edges() const { return edgeList.size() ; }
|
||||
@ -106,6 +111,7 @@ private:
|
||||
GraphWidget::AuthType _auth ;
|
||||
bool mDeterminedBB ;
|
||||
int mBBWidth ;
|
||||
int mNodeDrawSize;
|
||||
|
||||
static Node *_selected_node ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user