mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-19 21:04:32 -05:00
reengineered the network dialog insert connect method
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2492 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f362daea0b
commit
6c686496a9
@ -11,7 +11,7 @@ MOC_DIR = temp/moc
|
|||||||
|
|
||||||
#CONFIG += debug
|
#CONFIG += debug
|
||||||
debug {
|
debug {
|
||||||
DEFINES+*= PEERS_DEBUG
|
DEFINES += PEERS_DEBUG
|
||||||
QMAKE_CXXFLAGS *= -g
|
QMAKE_CXXFLAGS *= -g
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +99,8 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
|||||||
|
|
||||||
/* hide the Tree +/- */
|
/* hide the Tree +/- */
|
||||||
ui.connecttreeWidget -> setRootIsDecorated( false );
|
ui.connecttreeWidget -> setRootIsDecorated( false );
|
||||||
|
ui.connecttreeWidget->setColumnCount(5);
|
||||||
|
ui.unvalidGPGkeyWidget->setColumnCount(5);
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes */
|
/* Set header resize modes and initial section sizes */
|
||||||
QHeaderView * _header = ui.connecttreeWidget->header () ;
|
QHeaderView * _header = ui.connecttreeWidget->header () ;
|
||||||
@ -375,21 +377,36 @@ void NetworkDialog::insertConnect()
|
|||||||
|
|
||||||
/* get a link to the table */
|
/* get a link to the table */
|
||||||
QTreeWidget *connectWidget = ui.connecttreeWidget;
|
QTreeWidget *connectWidget = ui.connecttreeWidget;
|
||||||
QTreeWidgetItem *oldSelect = getCurrentNeighbour();
|
|
||||||
QTreeWidgetItem *newSelect = NULL;
|
|
||||||
std::string oldId;
|
|
||||||
if (oldSelect)
|
|
||||||
{
|
|
||||||
oldId = (oldSelect -> text(4)).toStdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
RsPeerDetails ownGPGDetails ;
|
//remove items
|
||||||
rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
|
int index = 0;
|
||||||
|
while (index < connectWidget->topLevelItemCount()) {
|
||||||
|
std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(4).toStdString();
|
||||||
|
RsPeerDetails detail;
|
||||||
|
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl < 3) {
|
||||||
|
connectWidget->takeTopLevelItem(index);
|
||||||
|
} else {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index = 0;
|
||||||
|
while (index < ui.unvalidGPGkeyWidget->topLevelItemCount()) {
|
||||||
|
std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(4).toStdString();
|
||||||
|
RsPeerDetails detail;
|
||||||
|
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= 3) {
|
||||||
|
ui.unvalidGPGkeyWidget->takeTopLevelItem(index);
|
||||||
|
} else {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<QTreeWidgetItem *> validItems;
|
QList<QTreeWidgetItem *> validItems;
|
||||||
QList<QTreeWidgetItem *> unvalidItems;
|
QList<QTreeWidgetItem *> unvalidItems;
|
||||||
for(it = neighs.begin(); it != neighs.end(); it++)
|
for(it = neighs.begin(); it != neighs.end(); it++)
|
||||||
{
|
{
|
||||||
|
#ifdef NET_DEBUG
|
||||||
|
std::cerr << "NetworkDialog::insertConnect() inserting gpg key : " << *it << std::endl;
|
||||||
|
#endif
|
||||||
if (*it == rsPeers->getGPGOwnId()) {
|
if (*it == rsPeers->getGPGOwnId()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -399,8 +416,25 @@ void NetworkDialog::insertConnect()
|
|||||||
{
|
{
|
||||||
continue; /* BAD */
|
continue; /* BAD */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make a widget per friend */
|
/* make a widget per friend */
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
QTreeWidgetItem *item;
|
||||||
|
QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 4);
|
||||||
|
if (list.size() == 1) {
|
||||||
|
item = list.front();
|
||||||
|
} else {
|
||||||
|
list = ui.unvalidGPGkeyWidget->findItems(QString::fromStdString(*it), Qt::MatchExactly, 4);
|
||||||
|
if (list.size() == 1) {
|
||||||
|
item = list.front();
|
||||||
|
} else {
|
||||||
|
//create new item
|
||||||
|
#ifdef NET_DEBUG
|
||||||
|
std::cerr << "NetworkDialog::insertConnect() creating new tree widget item : " << *it << std::endl;
|
||||||
|
#endif
|
||||||
|
item = new QTreeWidgetItem(0);
|
||||||
|
item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (0) Status Icon */
|
/* (0) Status Icon */
|
||||||
//item -> setText(0, "");
|
//item -> setText(0, "");
|
||||||
@ -424,13 +458,7 @@ void NetworkDialog::insertConnect()
|
|||||||
item -> setText(3, tr("Unknown"));
|
item -> setText(3, tr("Unknown"));
|
||||||
|
|
||||||
/* (4) key id */
|
/* (4) key id */
|
||||||
{
|
|
||||||
item -> setText(4, QString::fromStdString(detail.id));
|
item -> setText(4, QString::fromStdString(detail.id));
|
||||||
if ((oldSelect) && (oldId == detail.id))
|
|
||||||
{
|
|
||||||
newSelect = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -449,9 +477,7 @@ void NetworkDialog::insertConnect()
|
|||||||
item -> setIcon(0,(QIcon(IMAGE_AUTHED)));
|
item -> setIcon(0,(QIcon(IMAGE_AUTHED)));
|
||||||
backgrndcolor=QColor("#43C043");//light green
|
backgrndcolor=QColor("#43C043");//light green
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
item -> setText(0, "1");
|
item -> setText(0, "1");
|
||||||
if (detail.hasSignedMe)
|
if (detail.hasSignedMe)
|
||||||
{
|
{
|
||||||
@ -474,15 +500,26 @@ void NetworkDialog::insertConnect()
|
|||||||
|
|
||||||
/* add to the list */
|
/* add to the list */
|
||||||
if (detail.accept_connection || detail.validLvl >= 3) {
|
if (detail.accept_connection || detail.validLvl >= 3) {
|
||||||
validItems.append(item);
|
/* add gpg item to the list. If item is already in the list, it won't be duplicated thanks to Qt */
|
||||||
|
connectWidget->addTopLevelItem(item);
|
||||||
} else {
|
} else {
|
||||||
unvalidItems.append(item);
|
ui.unvalidGPGkeyWidget->addTopLevelItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add self to network.
|
// add self to network.
|
||||||
QTreeWidgetItem *self_item = new QTreeWidgetItem((QTreeWidget*)0);
|
RsPeerDetails ownGPGDetails;
|
||||||
|
rsPeers->getGPGDetails(rsPeers->getGPGOwnId(), ownGPGDetails);
|
||||||
|
/* make a widget per friend */
|
||||||
|
QTreeWidgetItem *self_item;
|
||||||
|
QList<QTreeWidgetItem *> list = connectWidget->findItems(QString::fromStdString(ownGPGDetails.gpg_id), Qt::MatchExactly, 4);
|
||||||
|
if (list.size() == 1) {
|
||||||
|
self_item = list.front();
|
||||||
|
} else {
|
||||||
|
self_item = new QTreeWidgetItem(0);
|
||||||
|
self_item->setChildIndicatorPolicy(QTreeWidgetItem::DontShowIndicatorWhenChildless);
|
||||||
|
}
|
||||||
self_item -> setText(0, "0");
|
self_item -> setText(0, "0");
|
||||||
self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
|
self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
|
||||||
self_item->setText(1,QString::fromStdString(ownGPGDetails.name) + " (yourself)") ;
|
self_item->setText(1,QString::fromStdString(ownGPGDetails.name) + " (yourself)") ;
|
||||||
@ -494,22 +531,7 @@ void NetworkDialog::insertConnect()
|
|||||||
{
|
{
|
||||||
self_item->setBackground(i,QBrush(QColor("#45ff45")));
|
self_item->setBackground(i,QBrush(QColor("#45ff45")));
|
||||||
}
|
}
|
||||||
validItems.append(self_item);
|
connectWidget->addTopLevelItem(self_item);
|
||||||
|
|
||||||
|
|
||||||
/* remove old items ??? */
|
|
||||||
connectWidget->clear();
|
|
||||||
connectWidget->setColumnCount(5);
|
|
||||||
ui.unvalidGPGkeyWidget->clear();
|
|
||||||
ui.unvalidGPGkeyWidget->setColumnCount(5);
|
|
||||||
|
|
||||||
/* add the items in! */
|
|
||||||
connectWidget->insertTopLevelItems(0, validItems);
|
|
||||||
ui.unvalidGPGkeyWidget->insertTopLevelItems(0, unvalidItems);
|
|
||||||
if (newSelect) {
|
|
||||||
connectWidget->setCurrentItem(newSelect);
|
|
||||||
ui.unvalidGPGkeyWidget->setCurrentItem(newSelect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ui.showUnvalidKeys->isChecked()) {
|
if (ui.showUnvalidKeys->isChecked()) {
|
||||||
ui.unvalidGPGkeyWidget->show();
|
ui.unvalidGPGkeyWidget->show();
|
||||||
|
@ -355,7 +355,7 @@ void PeersDialog::insertPeers()
|
|||||||
/* get a link to the table */
|
/* get a link to the table */
|
||||||
QTreeWidget *peertreeWidget = ui.peertreeWidget;
|
QTreeWidget *peertreeWidget = ui.peertreeWidget;
|
||||||
|
|
||||||
//remove items that are not fiends anymore
|
//remove items that are not friends anymore
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < peertreeWidget->topLevelItemCount()) {
|
while (index < peertreeWidget->topLevelItemCount()) {
|
||||||
std::string gpg_widget_id = (peertreeWidget->topLevelItem(index))->text(3).toStdString();
|
std::string gpg_widget_id = (peertreeWidget->topLevelItem(index))->text(3).toStdString();
|
||||||
|
Loading…
Reference in New Issue
Block a user