mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Small optimizations in MessengerWindow and PeersDialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3336 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6000233267
commit
cfd4eaad37
@ -434,8 +434,9 @@ void MessengerWindow::insertPeers()
|
|||||||
bool bSortState = ui.actionSort_by_State->isChecked();
|
bool bSortState = ui.actionSort_by_State->isChecked();
|
||||||
|
|
||||||
//remove items that are not fiends anymore
|
//remove items that are not fiends anymore
|
||||||
|
int itemCount = peertreeWidget->topLevelItemCount();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < peertreeWidget->topLevelItemCount()) {
|
while (index < itemCount) {
|
||||||
std::string gpg_widget_id = peertreeWidget->topLevelItem(index)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
std::string gpg_widget_id = peertreeWidget->topLevelItem(index)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||||
std::list<std::string>::iterator gpgfriendIt;
|
std::list<std::string>::iterator gpgfriendIt;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -447,6 +448,8 @@ void MessengerWindow::insertPeers()
|
|||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
delete (peertreeWidget->takeTopLevelItem(index));
|
delete (peertreeWidget->takeTopLevelItem(index));
|
||||||
|
// count again
|
||||||
|
itemCount = peertreeWidget->topLevelItemCount();
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@ -462,7 +465,8 @@ void MessengerWindow::insertPeers()
|
|||||||
QTreeWidgetItem *gpg_item = NULL;
|
QTreeWidgetItem *gpg_item = NULL;
|
||||||
QTreeWidgetItem *gpg_item_loop = NULL;
|
QTreeWidgetItem *gpg_item_loop = NULL;
|
||||||
QString gpgid = QString::fromStdString(*it);
|
QString gpgid = QString::fromStdString(*it);
|
||||||
for (int nIndex = 0; nIndex < peertreeWidget->topLevelItemCount(); nIndex++) {
|
itemCount = peertreeWidget->topLevelItemCount();
|
||||||
|
for (int nIndex = 0; nIndex < itemCount; nIndex++) {
|
||||||
gpg_item_loop = peertreeWidget->topLevelItem(nIndex);
|
gpg_item_loop = peertreeWidget->topLevelItem(nIndex);
|
||||||
if (gpg_item_loop->data(COLUMN_DATA, ROLE_ID).toString() == gpgid) {
|
if (gpg_item_loop->data(COLUMN_DATA, ROLE_ID).toString() == gpgid) {
|
||||||
gpg_item = gpg_item_loop;
|
gpg_item = gpg_item_loop;
|
||||||
@ -491,11 +495,14 @@ void MessengerWindow::insertPeers()
|
|||||||
gpg_item -> setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
|
gpg_item -> setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
|
||||||
|
|
||||||
//remove items that are not friends anymore
|
//remove items that are not friends anymore
|
||||||
|
int childCount = gpg_item->childCount();
|
||||||
int childIndex = 0;
|
int childIndex = 0;
|
||||||
while (childIndex < gpg_item->childCount()) {
|
while (childIndex < childCount) {
|
||||||
std::string ssl_id = gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
std::string ssl_id = gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||||
if (!rsPeers->isFriend(ssl_id)) {
|
if (!rsPeers->isFriend(ssl_id)) {
|
||||||
delete (gpg_item->takeChild(childIndex));
|
delete (gpg_item->takeChild(childIndex));
|
||||||
|
// count again
|
||||||
|
childCount = gpg_item->childCount();
|
||||||
} else {
|
} else {
|
||||||
childIndex++;
|
childIndex++;
|
||||||
}
|
}
|
||||||
@ -511,7 +518,8 @@ void MessengerWindow::insertPeers()
|
|||||||
|
|
||||||
//find the corresponding sslItem child item of the gpg item
|
//find the corresponding sslItem child item of the gpg item
|
||||||
bool newChild = true;
|
bool newChild = true;
|
||||||
for (int childIndex = 0; childIndex < gpg_item->childCount(); childIndex++) {
|
childCount = gpg_item->childCount();
|
||||||
|
for (int childIndex = 0; childIndex < childCount; childIndex++) {
|
||||||
if (gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString() == *sslIt) {
|
if (gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString() == *sslIt) {
|
||||||
sslItem = gpg_item->child(childIndex);
|
sslItem = gpg_item->child(childIndex);
|
||||||
newChild = false;
|
newChild = false;
|
||||||
@ -606,7 +614,6 @@ void MessengerWindow::insertPeers()
|
|||||||
|
|
||||||
std::list<StatusInfo>::iterator it = statusInfo.begin();
|
std::list<StatusInfo>::iterator it = statusInfo.begin();
|
||||||
|
|
||||||
|
|
||||||
for(; it != statusInfo.end() ; it++){
|
for(; it != statusInfo.end() ; it++){
|
||||||
|
|
||||||
std::list<std::string>::iterator cont_it = sslContacts.begin();
|
std::list<std::string>::iterator cont_it = sslContacts.begin();
|
||||||
@ -639,8 +646,9 @@ void MessengerWindow::insertPeers()
|
|||||||
} else {
|
} else {
|
||||||
gpg_item -> setIcon(COLUMN_STATE,(QIcon(":/images/no_avatar_70.png")));
|
gpg_item -> setIcon(COLUMN_STATE,(QIcon(":/images/no_avatar_70.png")));
|
||||||
}
|
}
|
||||||
if(it->status == RS_STATUS_INACTIVE)
|
|
||||||
{
|
switch (it->status) {
|
||||||
|
case RS_STATUS_INACTIVE:
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_INACTIVE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_INACTIVE)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
||||||
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_INACTIVE));
|
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_INACTIVE));
|
||||||
@ -649,9 +657,9 @@ void MessengerWindow::insertPeers()
|
|||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(it->status == RS_STATUS_ONLINE)
|
|
||||||
{
|
case RS_STATUS_ONLINE:
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
||||||
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_ONLINE));
|
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_ONLINE));
|
||||||
@ -660,9 +668,9 @@ void MessengerWindow::insertPeers()
|
|||||||
gpg_item -> setTextColor(i,(Qt::darkBlue));
|
gpg_item -> setTextColor(i,(Qt::darkBlue));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(it->status == RS_STATUS_AWAY)
|
|
||||||
{
|
case RS_STATUS_AWAY:
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AWAY)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AWAY)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
|
||||||
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_AWAY));
|
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_AWAY));
|
||||||
@ -671,9 +679,9 @@ void MessengerWindow::insertPeers()
|
|||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(it->status == RS_STATUS_BUSY)
|
|
||||||
{
|
case RS_STATUS_BUSY:
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_BUSY)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_BUSY)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
|
||||||
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_BUSY));
|
gpg_item->setData(COLUMN_NAME, ROLE_SORT, BuildStateSortString(bSortState, gpg_item->text(COLUMN_NAME), PEER_STATE_BUSY));
|
||||||
@ -682,6 +690,7 @@ void MessengerWindow::insertPeers()
|
|||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,6 @@ void PeersDialog::updateDisplay()
|
|||||||
ui.nicklabel->setText(titleStr.arg(QString::fromStdString(pd.name) + tr(" (me)") + QString::fromStdString(pd.location))) ;
|
ui.nicklabel->setText(titleStr.arg(QString::fromStdString(pd.name) + tr(" (me)") + QString::fromStdString(pd.location))) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
insertPeers() ;
|
insertPeers() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,6 +461,7 @@ void PeersDialog::insertPeers()
|
|||||||
#ifdef PEERS_DEBUG
|
#ifdef PEERS_DEBUG
|
||||||
std::cerr << "PeersDialog::insertPeers() called." << std::endl;
|
std::cerr << "PeersDialog::insertPeers() called." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::list<std::string> gpgFriends;
|
std::list<std::string> gpgFriends;
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
|
|
||||||
@ -490,8 +490,9 @@ void PeersDialog::insertPeers()
|
|||||||
QTreeWidget *peertreeWidget = ui.peertreeWidget;
|
QTreeWidget *peertreeWidget = ui.peertreeWidget;
|
||||||
|
|
||||||
//remove items that are not friends anymore
|
//remove items that are not friends anymore
|
||||||
|
int itemCount = peertreeWidget->topLevelItemCount();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < peertreeWidget->topLevelItemCount()) {
|
while (index < itemCount) {
|
||||||
std::string gpg_widget_id = (peertreeWidget->topLevelItem(index))->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
std::string gpg_widget_id = (peertreeWidget->topLevelItem(index))->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||||
std::list<std::string>::iterator gpgfriendIt;
|
std::list<std::string>::iterator gpgfriendIt;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@ -503,12 +504,13 @@ void PeersDialog::insertPeers()
|
|||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
delete (peertreeWidget->takeTopLevelItem(index));
|
delete (peertreeWidget->takeTopLevelItem(index));
|
||||||
|
// count again
|
||||||
|
itemCount = peertreeWidget->topLevelItemCount();
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//add the gpg friends
|
//add the gpg friends
|
||||||
for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) {
|
for(it = gpgFriends.begin(); it != gpgFriends.end(); it++) {
|
||||||
#ifdef PEERS_DEBUG
|
#ifdef PEERS_DEBUG
|
||||||
@ -519,7 +521,8 @@ void PeersDialog::insertPeers()
|
|||||||
QTreeWidgetItem *gpg_item = NULL;
|
QTreeWidgetItem *gpg_item = NULL;
|
||||||
QTreeWidgetItem *gpg_item_loop = NULL;
|
QTreeWidgetItem *gpg_item_loop = NULL;
|
||||||
QString gpgid = QString::fromStdString(*it);
|
QString gpgid = QString::fromStdString(*it);
|
||||||
for (int nIndex = 0; nIndex < peertreeWidget->topLevelItemCount(); nIndex++) {
|
itemCount = peertreeWidget->topLevelItemCount();
|
||||||
|
for (int nIndex = 0; nIndex < itemCount; nIndex++) {
|
||||||
gpg_item_loop = peertreeWidget->topLevelItem(nIndex);
|
gpg_item_loop = peertreeWidget->topLevelItem(nIndex);
|
||||||
if (gpg_item_loop->data(COLUMN_DATA, ROLE_ID).toString() == gpgid) {
|
if (gpg_item_loop->data(COLUMN_DATA, ROLE_ID).toString() == gpgid) {
|
||||||
gpg_item = gpg_item_loop;
|
gpg_item = gpg_item_loop;
|
||||||
@ -547,19 +550,20 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setText(COLUMN_NAME, QString::fromStdString(detail.name));
|
gpg_item -> setText(COLUMN_NAME, QString::fromStdString(detail.name));
|
||||||
gpg_item -> setSizeHint(COLUMN_NAME, QSize( 26,26 ) );
|
gpg_item -> setSizeHint(COLUMN_NAME, QSize( 26,26 ) );
|
||||||
|
|
||||||
|
|
||||||
gpg_item -> setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter );
|
gpg_item -> setTextAlignment(COLUMN_NAME, Qt::AlignLeft | Qt::AlignVCenter );
|
||||||
|
|
||||||
|
|
||||||
/* not displayed, used to find back the item */
|
/* not displayed, used to find back the item */
|
||||||
gpg_item -> setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
|
gpg_item -> setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id));
|
||||||
|
|
||||||
//remove items that are not friends anymore
|
//remove items that are not friends anymore
|
||||||
|
int childCount = gpg_item->childCount();
|
||||||
int childIndex = 0;
|
int childIndex = 0;
|
||||||
while (childIndex < gpg_item->childCount()) {
|
while (childIndex < childCount) {
|
||||||
std::string ssl_id = gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
std::string ssl_id = gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||||
if (!rsPeers->isFriend(ssl_id)) {
|
if (!rsPeers->isFriend(ssl_id)) {
|
||||||
delete (gpg_item->takeChild(childIndex));
|
delete (gpg_item->takeChild(childIndex));
|
||||||
|
// count again
|
||||||
|
childCount = gpg_item->childCount();
|
||||||
} else {
|
} else {
|
||||||
childIndex++;
|
childIndex++;
|
||||||
}
|
}
|
||||||
@ -575,7 +579,8 @@ void PeersDialog::insertPeers()
|
|||||||
|
|
||||||
//find the corresponding sslItem child item of the gpg item
|
//find the corresponding sslItem child item of the gpg item
|
||||||
bool newChild = true;
|
bool newChild = true;
|
||||||
for (int childIndex = 0; childIndex < gpg_item->childCount(); childIndex++) {
|
childCount = gpg_item->childCount();
|
||||||
|
for (int childIndex = 0; childIndex < childCount; childIndex++) {
|
||||||
if (gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString() == *sslIt) {
|
if (gpg_item->child(childIndex)->data(COLUMN_DATA, ROLE_ID).toString().toStdString() == *sslIt) {
|
||||||
sslItem = gpg_item->child(childIndex);
|
sslItem = gpg_item->child(childIndex);
|
||||||
newChild = false;
|
newChild = false;
|
||||||
@ -690,8 +695,8 @@ void PeersDialog::insertPeers()
|
|||||||
QFont font;
|
QFont font;
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
|
|
||||||
if(it->status == RS_STATUS_INACTIVE)
|
switch (it->status) {
|
||||||
{
|
case RS_STATUS_INACTIVE:
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_INACTIVE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_INACTIVE)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Idle"));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Idle"));
|
gpg_item -> setText(COLUMN_STATE, tr("Idle"));
|
||||||
@ -700,9 +705,9 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(it->status == RS_STATUS_ONLINE)
|
|
||||||
{
|
case RS_STATUS_ONLINE:
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_ONLINE)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Online"));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Online"));
|
gpg_item -> setText(COLUMN_STATE, tr("Online"));
|
||||||
@ -711,9 +716,9 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setTextColor(i,(Qt::darkBlue));
|
gpg_item -> setTextColor(i,(Qt::darkBlue));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(it->status == RS_STATUS_AWAY)
|
|
||||||
{
|
case RS_STATUS_AWAY:
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AWAY)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_AWAY)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Away"));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Away"));
|
gpg_item -> setText(COLUMN_STATE, tr("Away"));
|
||||||
@ -722,9 +727,9 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if(it->status == RS_STATUS_BUSY)
|
|
||||||
{
|
case RS_STATUS_BUSY:
|
||||||
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_BUSY)));
|
gpg_item -> setIcon(COLUMN_NAME,(QIcon(IMAGE_BUSY)));
|
||||||
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
|
gpg_item -> setToolTip(COLUMN_NAME, tr("Peer Busy"));
|
||||||
gpg_item -> setText(COLUMN_STATE, tr("Busy"));
|
gpg_item -> setText(COLUMN_STATE, tr("Busy"));
|
||||||
@ -733,6 +738,7 @@ void PeersDialog::insertPeers()
|
|||||||
gpg_item -> setTextColor(i,(Qt::gray));
|
gpg_item -> setTextColor(i,(Qt::gray));
|
||||||
gpg_item -> setFont(i,font);
|
gpg_item -> setFont(i,font);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user