mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-19 04:44:21 -05:00
Teaked the TrustView and NetworkView so that they only update when visible. Doing so, the CPU overload is only present when strictly needed.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1571 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d31bc2055f
commit
c35a48feb7
@ -35,6 +35,11 @@ TrustView::TrustView()
|
||||
update() ;
|
||||
}
|
||||
|
||||
void TrustView::showEvent(QShowEvent *e)
|
||||
{
|
||||
QWidget::showEvent(e) ;
|
||||
update() ;
|
||||
}
|
||||
void TrustView::wheelEvent(QWheelEvent *e)
|
||||
{
|
||||
if(e->modifiers() & Qt::ShiftModifier)
|
||||
@ -98,14 +103,14 @@ void TrustView::updateZoom(int z)
|
||||
// cout << "updated zoom" << endl;
|
||||
}
|
||||
|
||||
int TrustView::getRowColId(const string& name)
|
||||
int TrustView::getRowColId(const string& peerid)
|
||||
{
|
||||
static map<string,int> nameToRow ;
|
||||
static map<string,int> peeridToRow ;
|
||||
|
||||
map<string,int>::const_iterator itpr(nameToRow.find( name )) ;
|
||||
map<string,int>::const_iterator itpr(peeridToRow.find( peerid )) ;
|
||||
int i ;
|
||||
|
||||
if(itpr == nameToRow.end())
|
||||
if(itpr == peeridToRow.end())
|
||||
{
|
||||
i = trustTableTW->columnCount() ;
|
||||
// cout << " -> peer not in table. Creating entry # " << i << endl ;
|
||||
@ -113,7 +118,9 @@ int TrustView::getRowColId(const string& name)
|
||||
trustTableTW->insertColumn(i) ;
|
||||
trustTableTW->insertRow(i) ;
|
||||
|
||||
nameToRow[name] = i ;
|
||||
peeridToRow[peerid] = i ;
|
||||
|
||||
std::string name = rsPeers->getPeerName(peerid) ;
|
||||
|
||||
trustTableTW->setHorizontalHeaderItem(i,new QTableWidgetItem(QString(name.c_str()))) ;
|
||||
trustTableTW->setVerticalHeaderItem(i,new QTableWidgetItem(QString(name.c_str()))) ;
|
||||
@ -131,6 +138,9 @@ void TrustView::update()
|
||||
{
|
||||
// collect info.
|
||||
|
||||
if(!isVisible())
|
||||
return ;
|
||||
|
||||
std::list<std::string> neighs;
|
||||
|
||||
if(!rsPeers->getOthersList(neighs))
|
||||
@ -150,11 +160,11 @@ void TrustView::update()
|
||||
|
||||
// cout << "treating neigh = " << details.name << endl ;
|
||||
// cout << " signers = " ;
|
||||
int i = getRowColId(details.name) ;
|
||||
int i = getRowColId(details.id) ;
|
||||
|
||||
for(list<string>::const_iterator it2(details.signers.begin());it2!=details.signers.end();++it2)
|
||||
{
|
||||
// cout << *it2 << " " ;
|
||||
cout << *it2 << " " ;
|
||||
// Signers are identified by there name, so if we have twice the same signers, this gets crappy.
|
||||
|
||||
int j = getRowColId(*it2) ;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "ui_TrustView.h"
|
||||
|
||||
class QWheelEvent ;
|
||||
class QShowEvent ;
|
||||
|
||||
class TrustView: public QWidget, public Ui::TrustView
|
||||
{
|
||||
@ -11,6 +12,7 @@ class TrustView: public QWidget, public Ui::TrustView
|
||||
|
||||
protected:
|
||||
virtual void wheelEvent(QWheelEvent *) ;
|
||||
virtual void showEvent(QShowEvent *) ;
|
||||
|
||||
public slots:
|
||||
void update() ;
|
||||
|
@ -221,7 +221,8 @@ void GraphWidget::keyPressEvent(QKeyEvent *event)
|
||||
|
||||
void GraphWidget::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
if(!isVisible())
|
||||
return;
|
||||
|
||||
QList<Node *> nodes;
|
||||
foreach (QGraphicsItem *item, scene()->items()) {
|
||||
|
Loading…
Reference in New Issue
Block a user