improve the peers display update

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1965 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
joss17 2010-01-02 21:45:46 +00:00
parent b83e894640
commit 32420790cb

View File

@ -84,7 +84,7 @@
/** Constructor */
PeersDialog::PeersDialog(QWidget *parent)
: RsAutoUpdatePage(1000,parent),
: RsAutoUpdatePage(1500,parent),
historyKeeper(Rshare::dataDirectory() + "/his1.xml")
{
/* Invoke the Qt Designer generated object setup routine */
@ -106,6 +106,13 @@ PeersDialog::PeersDialog(QWidget *parent)
ui.peertabWidget->addTab(new ProfileWidget(),QString(tr("Profile")));
ui.peertreeWidget->setColumnCount(8);
ui.peertreeWidget->setColumnHidden ( 3, true);
ui.peertreeWidget->setColumnHidden ( 4, true);
ui.peertreeWidget->setColumnHidden ( 5, true);
ui.peertreeWidget->setColumnHidden ( 6, true);
ui.peertreeWidget->setColumnHidden ( 7, true);
ui.peertreeWidget->sortItems( 2, Qt::AscendingOrder );
/* Set header resize modes and initial section sizes */
QHeaderView * _header = ui.peertreeWidget->header () ;
@ -115,8 +122,8 @@ PeersDialog::PeersDialog(QWidget *parent)
_header->resizeSection ( 0, 25 );
_header->resizeSection ( 1, 100 );
_header->resizeSection ( 2, 100 );
_header->resizeSection ( 1, 150 );
_header->resizeSection ( 2, 150 );
// set header text aligment
@ -174,8 +181,6 @@ PeersDialog::PeersDialog(QWidget *parent)
timer->connect(timer, SIGNAL(timeout()), this, SLOT(insertChat()));
timer->start(500); /* half a second */
ui.peertreeWidget->sortItems( 2, Qt::AscendingOrder );
QMenu *menu = new QMenu();
menu->addAction(ui.actionAdd_Friend);
menu->addSeparator();
@ -186,7 +191,6 @@ PeersDialog::PeersDialog(QWidget *parent)
updateAvatar();
loadmypersonalstatus();
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -281,6 +285,7 @@ void PeersDialog::insertPeers()
/* get a link to the table */
QTreeWidget *peerWidget = ui.peertreeWidget;
QTreeWidgetItem *oldSelect = getCurrentPeer();
QTreeWidgetItem *newSelect = NULL;
time_t now = time(NULL);
@ -291,10 +296,6 @@ void PeersDialog::insertPeers()
oldId = (oldSelect -> text(7)).toStdString();
}
/* remove old items ??? */
peerWidget->clear();
peerWidget->setColumnCount(3);
// add self nick and Avatar to Friends.
RsPeerDetails pd ;
@ -303,11 +304,9 @@ void PeersDialog::insertPeers()
QString titleStr("<span style=\"font-size:16pt; font-weight:500;"
"color:#32cd32;\">%1</span>");
ui.nicklabel->setText(titleStr.arg(QString::fromStdString(pd.name) + tr(" (me)"))) ;
}
QList<QTreeWidgetItem *> items;
for(it = peers.begin(); it != peers.end(); it++)
{
RsPeerDetails detail;
@ -317,7 +316,13 @@ void PeersDialog::insertPeers()
}
/* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
QTreeWidgetItem *item;
QList<QTreeWidgetItem *> list = peerWidget->findItems (QString::fromStdString(detail.id), Qt::MatchExactly, 7);
if (list.size() == 1) {
item = list.front();
} else {
item = new QTreeWidgetItem((QTreeWidget*)0);
}
/* add all the labels */
/* First 5 (1-5) Key Items */
@ -339,13 +344,16 @@ void PeersDialog::insertPeers()
item -> setTextAlignment(1, Qt::AlignCenter | Qt::AlignVCenter );
/* (1) Person */
if (rsMsgs->getCustomStateString(detail.id) != "") {
item -> setText( 2, QString::fromStdString(detail.name) + tr(" - ") +
QString::fromStdString(rsMsgs->getCustomStateString(detail.id)));
item -> setToolTip( 2, QString::fromStdString(detail.name) + tr(" - ") +
QString::fromStdString(rsMsgs->getCustomStateString(detail.id)));
} else {
item -> setText( 2, QString::fromStdString(detail.name));
item -> setToolTip( 2, QString::fromStdString(detail.name));
}
/* (2) Auto Connect */
//item -> setText(3, QString::fromStdString(detail.autoconnect));
item -> setText(3, status);
/* (3) Trust Level */
@ -379,7 +387,7 @@ void PeersDialog::insertPeers()
item -> setText(7, QString::fromStdString(detail.id));
if ((oldSelect) && (oldId == detail.id))
{
newSelect = item;
peerWidget->setCurrentItem(item);
}
}
@ -450,17 +458,8 @@ void PeersDialog::insertPeers()
}
/* add to the list */
items.append(item);
peerWidget->addTopLevelItem(item);
}
/* add the items in! */
peerWidget->insertTopLevelItems(0, items);
if (newSelect)
{
peerWidget->setCurrentItem(newSelect);
}
peerWidget->update(); /* update display */
}
/* Utility Fns */