From 21cf471f6c4f9f143295b08a2e76410709833a45 Mon Sep 17 00:00:00 2001 From: notdefine Date: Sun, 21 Sep 2008 22:04:49 +0000 Subject: [PATCH] Show a readable Date, no Timestamp in Network Tab. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@734 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/NetworkDialog.cpp | 84 +++++++++++++----------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 6ffec87ca..e0bdd2c03 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -294,7 +294,22 @@ void NetworkDialog::insertConnect() /* (3) Last Connect */ { std::ostringstream out; - out << detail.lastConnect; + // Show anouncement if a friend never was connected. + if (detail.lastConnect==0 ) { + if(detail.state & RS_PEER_STATE_FRIEND) { + out << "Friend never seen"; + } else { + out << "0"; // Is zero + } + } else { + // Dont Show a timestamp in RS calculate the day + time_t seconds; + seconds=detail.lastConnect; + struct tm *tmnow= localtime(&seconds); + out << setfill ("0"); + out << tmnow->tm_hour << ":" << tmnow->tm_min << ":" << tmnow->tm_sec << " "; + out << tmnow->tm_mday << "." << tmnow->tm_mon + 1 << "." << tmnow->tm_year + 1900; + } item -> setText(3, QString::fromStdString(out.str())); } @@ -328,55 +343,44 @@ void NetworkDialog::insertConnect() /* change background */ int i; - if (detail.state & RS_PEER_STATE_FRIEND) + + // I dont know why the setBackground and Icon functions called 10 times, + // but this loop dont needed to be implemented in every single switch. + for(i = 1; i <10; i++) { - if (detail.lastConnect < 10000) /* 3 hours? */ + if (detail.state & RS_PEER_STATE_FRIEND) { - /* bright green */ - for(i = 1; i <10; i++) + if (detail.lastConnect < 10000) /* 3 hours? */ { - item -> setBackground(i,QBrush(Qt::darkGreen)); - item -> setIcon(0,(QIcon(IMAGE_AUTHED))); + /* bright green */ + item -> setBackground(i,QBrush(Qt::darkGreen)); + item -> setIcon(0,(QIcon(IMAGE_AUTHED))); + } + else + { + item -> setBackground(i,QBrush(Qt::darkGreen)); + item -> setIcon(0,(QIcon(IMAGE_AUTHED))); } } else { - for(i = 1; i < 10; i++) + if (detail.trustLvl > RS_TRUST_LVL_MARGINAL) { - item -> setBackground(i,QBrush(Qt::darkGreen)); - item -> setIcon(0,(QIcon(IMAGE_AUTHED))); + item -> setBackground(i,QBrush(Qt::cyan)); + item -> setIcon(0,(QIcon(IMAGE_DENIED))); } - } + else if (detail.lastConnect < 10000) /* 3 hours? */ + { + item -> setBackground(i,QBrush(Qt::yellow)); + item -> setIcon(0,(QIcon(IMAGE_DENIED))); + } + else + { + item -> setBackground(i,QBrush(Qt::gray)); + item -> setIcon(0,(QIcon(IMAGE_DENIED))); + } + } } - else - { - if (detail.trustLvl > RS_TRUST_LVL_MARGINAL) - { - for(i = 1; i < 10; i++) - { - item -> setBackground(i,QBrush(Qt::cyan)); - item -> setIcon(0,(QIcon(IMAGE_DENIED))); - } - } - else if (detail.lastConnect < 10000) /* 3 hours? */ - { - for(i = 1; i < 10; i++) - { - item -> setBackground(i,QBrush(Qt::yellow)); - item -> setIcon(0,(QIcon(IMAGE_DENIED))); - } - } - else - { - for(i = 1; i < 10; i++) - { - item -> setBackground(i,QBrush(Qt::gray)); - item -> setIcon(0,(QIcon(IMAGE_DENIED))); - } - } - } - - /* add to the list */ items.append(item); }