Removed most of the usages of std::ostringstream in the gui.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5056 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-03-28 18:02:49 +00:00
parent 9ef7d08d2b
commit 4cb844c44d
38 changed files with 190 additions and 354 deletions

View File

@ -19,7 +19,6 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <sstream>
#include <time.h> #include <time.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <algorithm> #include <algorithm>

View File

@ -30,7 +30,6 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <iostream> #include <iostream>
#include <sstream>
#define URL_FAQ "http://retroshare.sourceforge.net/wiki/index.php/Frequently_Asked_Questions" #define URL_FAQ "http://retroshare.sourceforge.net/wiki/index.php/Frequently_Asked_Questions"
#define URL_FORUM "http://retroshare.sourceforge.net/forum/" #define URL_FORUM "http://retroshare.sourceforge.net/forum/"

View File

@ -25,7 +25,6 @@
#include <retroshare/rsdisc.h> #include <retroshare/rsdisc.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>

View File

@ -24,7 +24,6 @@
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>

View File

@ -93,7 +93,6 @@
#include "settings/rsharesettings.h" #include "settings/rsharesettings.h"
#include "common/StatusDefs.h" #include "common/StatusDefs.h"
#include <sstream>
#include <iomanip> #include <iomanip>
#include <unistd.h> #include <unistd.h>

View File

@ -49,7 +49,6 @@
#include "settings/rsharesettings.h" #include "settings/rsharesettings.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <algorithm> #include <algorithm>
#include <set> #include <set>

View File

@ -37,7 +37,6 @@
#include "util/misc.h" #include "util/misc.h"
#include <set> #include <set>
#include <sstream>
#include <algorithm> #include <algorithm>
/***** /*****
@ -1184,7 +1183,7 @@ void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std
QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) const QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) const
{ {
/* extract from each the member text */ /* extract from each the member text */
std::string text; QString text;
QModelIndexList::const_iterator it; QModelIndexList::const_iterator it;
std::map<std::string, uint64_t> drags; std::map<std::string, uint64_t> drags;
std::map<std::string, uint64_t>::iterator dit; std::map<std::string, uint64_t>::iterator dit;
@ -1235,17 +1234,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
drags[details.hash] = details.count; drags[details.hash] = details.count;
std::string line = details.name; QString line = QString("%1/%2/%3/").arg(QString::fromUtf8(details.name.c_str())).arg(QString::fromStdString(details.hash)).arg(details.count);
line += "/";
line += details.hash;
line += "/";
{
std::ostringstream out;
out << details.count;
line += out.str();
line += "/";
}
if (RemoteMode) if (RemoteMode)
{ {
@ -1269,11 +1258,9 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
#endif #endif
QMimeData *data = new QMimeData(); QMimeData *data = new QMimeData();
data->setData("application/x-rsfilelist", QByteArray(text.c_str())); data->setData("application/x-rsfilelist", QByteArray(text.toAscii()));
return data; return data;
} }
QStringList RetroshareDirModel::mimeTypes () const QStringList RetroshareDirModel::mimeTypes () const

View File

@ -1171,8 +1171,6 @@ void SearchDialog::resultsToTree(std::string txt,qulonglong searchId, const std:
ui.searchResultWidget->setSortingEnabled(false); ui.searchResultWidget->setSortingEnabled(false);
/* translate search results */ /* translate search results */
std::ostringstream out;
out << searchId;
std::list<DirDetails>::const_iterator it; std::list<DirDetails>::const_iterator it;
for(it = results.begin(); it != results.end(); it++) for(it = results.begin(); it != results.end(); it++)

View File

@ -1,5 +1,3 @@
#include <iostream>
#include <QTimer>
#include <QObject> #include <QObject>
#include <retroshare/rsturtle.h> #include <retroshare/rsturtle.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>

View File

@ -27,7 +27,6 @@
#include <retroshare-gui/RsAutoUpdatePage.h> #include <retroshare-gui/RsAutoUpdatePage.h>
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <sstream>
#include <iomanip> #include <iomanip>
#include <unistd.h> #include <unistd.h>

View File

@ -28,7 +28,6 @@
#include <QTime> #include <QTime>
#include <QDateTime> #include <QDateTime>
#include <sstream>
#include <list> #include <list>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -109,9 +108,7 @@ void ChannelDetails::loadChannel()
// Set Channel Popularity // Set Channel Popularity
{ {
std::ostringstream out; ui.popline -> setText(QString::number(ci.pop));
out << ci.pop;
ui.popline -> setText(QString::fromStdString(out.str()));
} }
// Set Last Channel Post Date // Set Last Channel Post Date

View File

@ -1331,15 +1331,14 @@ QTreeWidgetItem *FriendList::getCurrentPeer() const
} }
/* Display the columns of this item. */ /* Display the columns of this item. */
std::ostringstream out; QString out = "CurrentPeerItem: \n";
out << "CurrentPeerItem: " << std::endl;
for(int i = 1; i < COLUMN_COUNT; i++) for(int i = 1; i < COLUMN_COUNT; i++)
{ {
QString txt = item -> text(i); QString txt = item -> text(i);
out << "\t" << i << ":" << txt.toStdString() << std::endl; out += QString("\t%1:%2\n").arg(i).arg(txt);
} }
std::cerr << out.str(); std::cerr << out.toStdString();
#endif #endif
return item; return item;
} }

View File

@ -24,7 +24,6 @@
#include <QTimer> #include <QTimer>
#include <QDateTime> #include <QDateTime>
#include <sstream>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
@ -242,29 +241,29 @@ void DhtWindow::updateNetStatus()
uint32_t connect = rsConfig->getConnectModes(); uint32_t connect = rsConfig->getConnectModes();
label = ui->connectLabel; label = ui->connectLabel;
std::ostringstream connOut; QString connOut;
if (connect & RSNET_CONNECT_OUTGOING_TCP) if (connect & RSNET_CONNECT_OUTGOING_TCP)
{ {
connOut << "TCP_OUT "; connOut += "TCP_OUT ";
} }
if (connect & RSNET_CONNECT_ACCEPT_TCP) if (connect & RSNET_CONNECT_ACCEPT_TCP)
{ {
connOut << "TCP_IN "; connOut += "TCP_IN ";
} }
if (connect & RSNET_CONNECT_DIRECT_UDP) if (connect & RSNET_CONNECT_DIRECT_UDP)
{ {
connOut << "DIRECT_UDP "; connOut += "DIRECT_UDP ";
} }
if (connect & RSNET_CONNECT_PROXY_UDP) if (connect & RSNET_CONNECT_PROXY_UDP)
{ {
connOut << "PROXY_UDP "; connOut += "PROXY_UDP ";
} }
if (connect & RSNET_CONNECT_RELAY_UDP) if (connect & RSNET_CONNECT_RELAY_UDP)
{ {
connOut << "RELAY_UDP "; connOut += "RELAY_UDP ";
} }
label->setText(QString::fromStdString(connOut.str())); label->setText(connOut);
uint32_t netState = rsConfig->getNetState(); uint32_t netState = rsConfig->getNetState();
@ -306,8 +305,6 @@ void DhtWindow::updateNetStatus()
void DhtWindow::updateNetPeers() void DhtWindow::updateNetPeers()
{ {
QTreeWidget *peerTreeWidget = ui->peerTreeWidget; QTreeWidget *peerTreeWidget = ui->peerTreeWidget;
std::list<std::string> peerIds; std::list<std::string> peerIds;
@ -399,70 +396,68 @@ void DhtWindow::updateNetPeers()
peer_item -> setData(PTW_COL_RSNAME, Qt::DisplayRole, QString::fromStdString(name)); peer_item -> setData(PTW_COL_RSNAME, Qt::DisplayRole, QString::fromStdString(name));
peer_item -> setData(PTW_COL_RSID, Qt::DisplayRole, QString::fromStdString(status.mRsId)); peer_item -> setData(PTW_COL_RSID, Qt::DisplayRole, QString::fromStdString(status.mRsId));
std::ostringstream dhtstate; QString dhtstate;
switch(status.mDhtState) switch(status.mDhtState)
{ {
default: default:
case RSDHT_PEERDHT_NOT_ACTIVE: case RSDHT_PEERDHT_NOT_ACTIVE:
dhtstate << "Not Active (Maybe Connected!)"; dhtstate = "Not Active (Maybe Connected!)";
break; break;
case RSDHT_PEERDHT_SEARCHING: case RSDHT_PEERDHT_SEARCHING:
dhtstate << "Searching"; dhtstate = "Searching";
break; break;
case RSDHT_PEERDHT_FAILURE: case RSDHT_PEERDHT_FAILURE:
dhtstate << "Failed"; dhtstate = "Failed";
break; break;
case RSDHT_PEERDHT_OFFLINE: case RSDHT_PEERDHT_OFFLINE:
dhtstate << "offline"; dhtstate = "offline";
nOfflinePeers++; nOfflinePeers++;
break; break;
case RSDHT_PEERDHT_UNREACHABLE: case RSDHT_PEERDHT_UNREACHABLE:
dhtstate << "Unreachable"; dhtstate = "Unreachable";
nUnreachablePeers++; nUnreachablePeers++;
break; break;
case RSDHT_PEERDHT_ONLINE: case RSDHT_PEERDHT_ONLINE:
dhtstate << "ONLINE"; dhtstate = "ONLINE";
nOnlinePeers++; nOnlinePeers++;
break; break;
} }
peer_item -> setData(PTW_COL_DHT_STATUS, Qt::DisplayRole, QString::fromStdString(dhtstate.str())); peer_item -> setData(PTW_COL_DHT_STATUS, Qt::DisplayRole, dhtstate);
// NOW CONNECT STATE // NOW CONNECT STATE
std::ostringstream cpmstr; QString cpmstr;
switch(status.mPeerConnectMode) switch(status.mPeerConnectMode)
{ {
case RSDHT_TOU_MODE_DIRECT: case RSDHT_TOU_MODE_DIRECT:
cpmstr << "Direct"; cpmstr = "Direct";
break; break;
case RSDHT_TOU_MODE_PROXY: case RSDHT_TOU_MODE_PROXY:
cpmstr << "Proxy VIA "; cpmstr = "Proxy VIA " + QString::fromStdString(status.mPeerConnectProxyId);
cpmstr << status.mPeerConnectProxyId;
break; break;
case RSDHT_TOU_MODE_RELAY: case RSDHT_TOU_MODE_RELAY:
cpmstr << "Relay VIA "; cpmstr = "Relay VIA " + QString::fromStdString(status.mPeerConnectProxyId);
cpmstr << status.mPeerConnectProxyId;
break; break;
default: default:
cpmstr << "None"; cpmstr = "None";
break; break;
} }
std::ostringstream cpsstr; QString cpsstr;
switch(status.mPeerConnectState) switch(status.mPeerConnectState)
{ {
default: default:
case RSDHT_PEERCONN_DISCONNECTED: case RSDHT_PEERCONN_DISCONNECTED:
cpsstr << "Disconnected"; cpsstr = "Disconnected";
nDisconnPeers++; nDisconnPeers++;
break; break;
case RSDHT_PEERCONN_UDP_STARTED: case RSDHT_PEERCONN_UDP_STARTED:
cpsstr << "Udp Started"; cpsstr = "Udp Started";
break; break;
case RSDHT_PEERCONN_CONNECTED: case RSDHT_PEERCONN_CONNECTED:
{ {
cpsstr << "Connected"; cpsstr = "Connected";
break; break;
switch(status.mPeerConnectMode) switch(status.mPeerConnectMode)
{ {
@ -481,7 +476,7 @@ void DhtWindow::updateNetPeers()
break; break;
} }
peer_item -> setData(PTW_COL_PEER_CONNECT_STATUS, Qt::DisplayRole, QString::fromStdString(cpsstr.str())); peer_item -> setData(PTW_COL_PEER_CONNECT_STATUS, Qt::DisplayRole, cpsstr);
if (status.mPeerConnectState == RSDHT_PEERCONN_DISCONNECTED) if (status.mPeerConnectState == RSDHT_PEERCONN_DISCONNECTED)
{ {
@ -489,28 +484,28 @@ void DhtWindow::updateNetPeers()
} }
else else
{ {
peer_item -> setData(PTW_COL_PEER_CONNECT_MODE, Qt::DisplayRole, QString::fromStdString(cpmstr.str())); peer_item -> setData(PTW_COL_PEER_CONNECT_MODE, Qt::DisplayRole, cpmstr);
} }
// NOW REQ STATE. // NOW REQ STATE.
std::ostringstream reqstr; QString reqstr;
if (status.mExclusiveProxyLock) if (status.mExclusiveProxyLock)
{ {
reqstr << "(E) "; reqstr = "(E) ";
} }
switch(status.mPeerReqState) switch(status.mPeerReqState)
{ {
case RSDHT_PEERREQ_RUNNING: case RSDHT_PEERREQ_RUNNING:
reqstr << "Request Active"; reqstr += "Request Active";
break; break;
case RSDHT_PEERREQ_STOPPED: case RSDHT_PEERREQ_STOPPED:
reqstr << "No Request"; reqstr += "No Request";
break; break;
default: default:
reqstr << "Unknown"; reqstr += "Unknown";
break; break;
} }
peer_item -> setData(PTW_COL_PEER_REQ_STATUS, Qt::DisplayRole, QString::fromStdString(reqstr.str())); peer_item -> setData(PTW_COL_PEER_REQ_STATUS, Qt::DisplayRole, reqstr);
peer_item -> setData(PTW_COL_PEER_CB_MSG, Qt::DisplayRole, QString::fromStdString(status.mCbPeerMsg)); peer_item -> setData(PTW_COL_PEER_CB_MSG, Qt::DisplayRole, QString::fromStdString(status.mCbPeerMsg));
peer_item -> setData(PTW_COL_PEER_CONNECTLOGIC, Qt::DisplayRole, peer_item -> setData(PTW_COL_PEER_CONNECTLOGIC, Qt::DisplayRole,
@ -518,20 +513,18 @@ void DhtWindow::updateNetPeers()
} }
std::ostringstream connstr; QString connstr;
connstr << "#Peers: " << nPeers; connstr = "#Peers: " + QString::number(nPeers);
connstr << " DHT: (#off:" << nOfflinePeers; connstr += " DHT: (#off:" + QString::number(nOfflinePeers);
connstr << ",unreach:" << nUnreachablePeers; connstr += ",unreach:" + QString::number(nUnreachablePeers);
connstr << ",online:" << nOnlinePeers; connstr += ",online:" + QString::number(nOnlinePeers);
connstr << ") Connections: (#dis:" << nDisconnPeers; connstr += ") Connections: (#dis:" + QString::number(nDisconnPeers);
connstr << ",#dir:" << nDirectPeers; connstr += ",#dir:" + QString::number(nDirectPeers);
connstr << ",#proxy:" << nProxyPeers; connstr += ",#proxy:" + QString::number(nProxyPeers);
connstr << ",#relay:" << nRelayPeers; connstr += ",#relay:" + QString::number(nRelayPeers);
connstr << ")"; connstr += ")";
QLabel *label = ui->peerSummaryLabel;
label->setText(QString::fromStdString(connstr.str()));
ui->peerSummaryLabel->setText(connstr);
} }
@ -569,42 +562,26 @@ void DhtWindow::updateRelays()
QTreeWidgetItem *item = new QTreeWidgetItem(); QTreeWidgetItem *item = new QTreeWidgetItem();
relayTreeWidget->addTopLevelItem(item); relayTreeWidget->addTopLevelItem(item);
std::ostringstream typestr; QString typestr = "RELAY END";
typestr << "RELAY END"; QString srcstr = "Yourself";
QString proxystr = QString::fromStdString(reit->mProxyAddr);
std::ostringstream srcstr; QString deststr = QString::fromStdString(reit->mRemoteAddr);
srcstr << "Yourself"; QString agestr = "unknown";
QString lastsendstr = "unknown";
std::ostringstream proxystr; QString bandwidthstr = "unlimited";
proxystr << reit->mProxyAddr; QString classstr = "Own Relay";
std::ostringstream deststr;
deststr << reit->mRemoteAddr;
std::ostringstream agestr;
agestr << "unknown";
std::ostringstream lastsendstr;
lastsendstr << "unknown";
std::ostringstream bandwidthstr;
bandwidthstr << "unlimited";
std::ostringstream classstr;
classstr << "Own Relay";
//std::ostringstream dhtupdatestr; //std::ostringstream dhtupdatestr;
//dhtupdatestr << now - status.mDhtUpdateTS << " secs ago"; //dhtupdatestr << now - status.mDhtUpdateTS << " secs ago";
item -> setData(RTW_COL_TYPE, Qt::DisplayRole, typestr);
item -> setData(RTW_COL_TYPE, Qt::DisplayRole, QString::fromStdString(typestr.str())); item -> setData(RTW_COL_SRC, Qt::DisplayRole, srcstr);
item -> setData(RTW_COL_SRC, Qt::DisplayRole, QString::fromStdString(srcstr.str())); item -> setData(RTW_COL_PROXY, Qt::DisplayRole, proxystr);
item -> setData(RTW_COL_PROXY, Qt::DisplayRole, QString::fromStdString(proxystr.str())); item -> setData(RTW_COL_DEST, Qt::DisplayRole, deststr);
item -> setData(RTW_COL_DEST, Qt::DisplayRole, QString::fromStdString(deststr.str())); item -> setData(RTW_COL_CLASS, Qt::DisplayRole, classstr);
item -> setData(RTW_COL_CLASS, Qt::DisplayRole, QString::fromStdString(classstr.str())); item -> setData(RTW_COL_AGE, Qt::DisplayRole, agestr);
item -> setData(RTW_COL_AGE, Qt::DisplayRole, QString::fromStdString(agestr.str())); item -> setData(RTW_COL_LASTSEND, Qt::DisplayRole, lastsendstr);
item -> setData(RTW_COL_LASTSEND, Qt::DisplayRole, QString::fromStdString(lastsendstr.str())); item -> setData(RTW_COL_BANDWIDTH, Qt::DisplayRole, bandwidthstr);
item -> setData(RTW_COL_BANDWIDTH, Qt::DisplayRole, QString::fromStdString(bandwidthstr.str()));
} }
@ -615,38 +592,23 @@ void DhtWindow::updateRelays()
QTreeWidgetItem *item = new QTreeWidgetItem(); QTreeWidgetItem *item = new QTreeWidgetItem();
relayTreeWidget->addTopLevelItem(item); relayTreeWidget->addTopLevelItem(item);
std::ostringstream typestr; QString typestr = "RELAY PROXY";
typestr << "RELAY PROXY"; QString srcstr = QString::fromStdString(rpit->mSrcAddr);
QString proxystr = "Yourself";
QString deststr = QString::fromStdString(rpit->mDestAddr);
QString agestr = QString("%1 secs ago").arg(now - rpit->mCreateTS);
QString lastsendstr = QString("%1 secs ago").arg(now - rpit->mLastTS);
QString bandwidthstr = QString("%1B/s").arg(QString::number(rpit->mBandwidth));
QString classstr = QString::number(rpit->mRelayClass);
std::ostringstream srcstr; item -> setData(RTW_COL_TYPE, Qt::DisplayRole, typestr);
srcstr << rpit->mSrcAddr; item -> setData(RTW_COL_SRC, Qt::DisplayRole, srcstr);
item -> setData(RTW_COL_PROXY, Qt::DisplayRole, proxystr);
std::ostringstream proxystr; item -> setData(RTW_COL_DEST, Qt::DisplayRole, deststr);
proxystr << "Yourself"; item -> setData(RTW_COL_CLASS, Qt::DisplayRole, classstr);
item -> setData(RTW_COL_AGE, Qt::DisplayRole, agestr);
std::ostringstream deststr; item -> setData(RTW_COL_LASTSEND, Qt::DisplayRole, lastsendstr);
deststr << rpit->mDestAddr; item -> setData(RTW_COL_BANDWIDTH, Qt::DisplayRole, bandwidthstr);
std::ostringstream agestr;
agestr << now - rpit->mCreateTS << " secs ago";
std::ostringstream lastsendstr;
lastsendstr << now - rpit->mLastTS << " secs ago";
std::ostringstream bandwidthstr;
bandwidthstr << rpit->mBandwidth << "B/s";
std::ostringstream classstr;
classstr << rpit->mRelayClass;
item -> setData(RTW_COL_TYPE, Qt::DisplayRole, QString::fromStdString(typestr.str()));
item -> setData(RTW_COL_SRC, Qt::DisplayRole, QString::fromStdString(srcstr.str()));
item -> setData(RTW_COL_PROXY, Qt::DisplayRole, QString::fromStdString(proxystr.str()));
item -> setData(RTW_COL_DEST, Qt::DisplayRole, QString::fromStdString(deststr.str()));
item -> setData(RTW_COL_CLASS, Qt::DisplayRole, QString::fromStdString(classstr.str()));
item -> setData(RTW_COL_AGE, Qt::DisplayRole, QString::fromStdString(agestr.str()));
item -> setData(RTW_COL_LASTSEND, Qt::DisplayRole, QString::fromStdString(lastsendstr.str()));
item -> setData(RTW_COL_BANDWIDTH, Qt::DisplayRole, QString::fromStdString(bandwidthstr.str()));
} }
} }
@ -717,43 +679,32 @@ void DhtWindow::updateDhtPeers()
/* insert */ /* insert */
dht_item = new DhtTreeWidgetItem(); dht_item = new DhtTreeWidgetItem();
int dist = it->mBucket; QString buckstr = QString::number(it->mBucket);
std::ostringstream buckstr; QString ipstr = QString::fromStdString(it->mAddr);
buckstr << dist; QString idstr = QString::fromStdString(it->mDhtId);
QString flagsstr = QString("0x%1 EX:0x%2").arg(it->mPeerFlags, 0, 16, QChar('0')).arg(it->mExtraFlags, 0, 16, QChar('0'));
QString foundstr = QString("%1 secs ago").arg(now - it->mFoundTime);
std::ostringstream ipstr; QString lastsendstr;
ipstr << it->mAddr;
std::ostringstream idstr;
idstr << it->mDhtId;
std::ostringstream flagsstr;
flagsstr << "0x" << std::hex << std::setfill('0') << it->mPeerFlags;
flagsstr << " EX:0x" << std::hex << std::setfill('0') << it->mExtraFlags;
std::ostringstream foundstr;
foundstr << now - it->mFoundTime << " secs ago";
std::ostringstream lastsendstr;
if (it->mLastSendTime == 0) if (it->mLastSendTime == 0)
{ {
lastsendstr << "never"; lastsendstr = "never";
} }
else else
{ {
lastsendstr << now - it->mLastSendTime << " secs ago"; lastsendstr = QString ("%1 secs ago").arg(now - it->mLastSendTime);
} }
std::ostringstream lastrecvstr; QString lastrecvstr = QString ("%1 secs ago").arg(now - it->mLastRecvTime);
lastrecvstr << now - it->mLastRecvTime << " secs ago";
dht_item -> setData(DTW_COL_BUCKET, Qt::DisplayRole, QString::fromStdString(buckstr.str())); dht_item -> setData(DTW_COL_BUCKET, Qt::DisplayRole, buckstr);
dht_item -> setData(DTW_COL_IPADDR, Qt::DisplayRole, QString::fromStdString(ipstr.str())); dht_item -> setData(DTW_COL_IPADDR, Qt::DisplayRole, ipstr);
dht_item -> setData(DTW_COL_PEERID, Qt::DisplayRole, QString::fromStdString(idstr.str())); dht_item -> setData(DTW_COL_PEERID, Qt::DisplayRole, idstr);
dht_item -> setData(DTW_COL_FLAGS, Qt::DisplayRole, QString::fromStdString(flagsstr.str())); dht_item -> setData(DTW_COL_FLAGS, Qt::DisplayRole, flagsstr);
dht_item -> setData(DTW_COL_FOUND, Qt::DisplayRole, QString::fromStdString(foundstr.str())); dht_item -> setData(DTW_COL_FOUND, Qt::DisplayRole, foundstr);
dht_item -> setData(DTW_COL_SEND, Qt::DisplayRole, QString::fromStdString(lastsendstr.str())); dht_item -> setData(DTW_COL_SEND, Qt::DisplayRole, lastsendstr);
dht_item -> setData(DTW_COL_RECV, Qt::DisplayRole, QString::fromStdString(lastrecvstr.str())); dht_item -> setData(DTW_COL_RECV, Qt::DisplayRole, lastrecvstr);
dhtTreeWidget->addTopLevelItem(dht_item); dhtTreeWidget->addTopLevelItem(dht_item);
} }

View File

@ -33,9 +33,6 @@
#include <retroshare/rschannels.h> #include <retroshare/rschannels.h>
#include <sstream>
/**** /****
* #define DEBUG_ITEM 1 * #define DEBUG_ITEM 1
****/ ****/
@ -171,11 +168,7 @@ void ChanMsgItem::updateItemStatic()
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
datetimelabel->setText(timestamp); datetimelabel->setText(timestamp);
{ filelabel->setText(QString("(%1 %2) %3").arg(cmi.count).arg(tr("Files")).arg(misc::friendlyUnit(cmi.size)));
std::ostringstream out;
out << "(" << cmi.count << " Files)";
filelabel->setText(QString::fromStdString(out.str()) + " " + misc::friendlyUnit(cmi.size));
}
if (mFileItems.empty() == false) { if (mFileItems.empty() == false) {
std::list<SubFileItem *>::iterator it; std::list<SubFileItem *>::iterator it;

View File

@ -35,8 +35,6 @@
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <sstream>
/***** /*****
* #define DEBUG_ITEM 1 * #define DEBUG_ITEM 1
****/ ****/

View File

@ -34,8 +34,6 @@
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <sstream>
/***** /*****
* #define DEBUG_ITEM 1 * #define DEBUG_ITEM 1
****/ ****/
@ -194,14 +192,7 @@ void PeerItem::updateItem()
statusLabel->setText(status); statusLabel->setText(status);
trustLabel->setText(QString::fromStdString(RsPeerTrustString(details.trustLvl))); trustLabel->setText(QString::fromStdString(RsPeerTrustString(details.trustLvl)));
{ ipLabel->setText(QString("%1:%2/%3:%4").arg(QString::fromStdString(details.localAddr)).arg(details.localPort).arg(QString::fromStdString(details.extAddr)).arg(details.extPort));
std::ostringstream out;
out << details.localAddr << ":";
out << details.localPort << "/";
out << details.extAddr << ":";
out << details.extPort;
ipLabel->setText(QString::fromStdString(out.str()));
}
connLabel->setText(StatusDefs::connectStateString(details)); connLabel->setText(StatusDefs::connectStateString(details));

View File

@ -36,8 +36,6 @@
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <sstream>
/***** /*****
* #define DEBUG_ITEM 1 * #define DEBUG_ITEM 1
****/ ****/
@ -220,14 +218,7 @@ void SecurityItem::updateItem()
statusLabel->setText(status); statusLabel->setText(status);
trustLabel->setText(QString::fromStdString(RsPeerTrustString(details.trustLvl))); trustLabel->setText(QString::fromStdString(RsPeerTrustString(details.trustLvl)));
{ ipLabel->setText(QString("%1:%2/%3:%4").arg(QString::fromStdString(details.localAddr)).arg(details.localPort).arg(QString::fromStdString(details.extAddr)).arg(details.extPort));
std::ostringstream out;
out << details.localAddr << ":";
out << details.localPort << "/";
out << details.extAddr << ":";
out << details.extPort;
ipLabel->setText(QString::fromStdString(out.str()));
}
connLabel->setText(StatusDefs::connectStateString(details)); connLabel->setText(StatusDefs::connectStateString(details));

View File

@ -28,7 +28,6 @@
#include <QTime> #include <QTime>
#include <QDateTime> #include <QDateTime>
#include <sstream>
#include <list> #include <list>
#include <iostream> #include <iostream>
#include <string> #include <string>

View File

@ -46,10 +46,6 @@
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "SoundManager.h" #include "SoundManager.h"
#include <iostream>
#include <sstream>
#include <time.h>
/***** /*****
* #define NOTIFY_DEBUG * #define NOTIFY_DEBUG
****/ ****/

View File

@ -31,7 +31,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QTime> #include <QTime>
#include <sstream>
#include <iomanip> #include <iomanip>
/* Define the format used for displaying the date and time */ /* Define the format used for displaying the date and time */
@ -65,7 +64,6 @@ void ProfileWidget::closeEvent (QCloseEvent * event)
void ProfileWidget::showEvent ( QShowEvent * /*event*/ ) void ProfileWidget::showEvent ( QShowEvent * /*event*/ )
{ {
RsPeerDetails detail; RsPeerDetails detail;
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),detail)) if (rsPeers->getPeerDetails(rsPeers->getOwnId(),detail))
{ {
@ -108,12 +106,8 @@ void ProfileWidget::showEvent ( QShowEvent * /*event*/ )
rsPeers->getGPGAcceptedList(ids); rsPeers->getGPGAcceptedList(ids);
int friends = ids.size(); int friends = ids.size();
std::ostringstream out; ui.friendsEdit->setText(QString::number(friends));
out << friends << "";
ui.friendsEdit->setText(QString::fromStdString(out.str()));
} }
} }
void ProfileWidget::statusmessagedlg() void ProfileWidget::statusmessagedlg()

View File

@ -29,7 +29,6 @@
#include <QTime> #include <QTime>
#include <sstream>
#include <iomanip> #include <iomanip>

View File

@ -24,7 +24,6 @@
#include "rshare.h" #include "rshare.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
@ -175,27 +174,15 @@ void RelayPage::updateRelayOptions()
int nGeneral = ui.noGeneralSpinBox->value(); int nGeneral = ui.noGeneralSpinBox->value();
int genBandwidth = ui.bandGeneralSpinBox->value(); int genBandwidth = ui.bandGeneralSpinBox->value();
std::ostringstream tfriendout; ui.totalFriendLineEdit->setText(QString::number(nFriends * friendBandwidth * 2));
tfriendout << nFriends * friendBandwidth * 2;
ui.totalFriendLineEdit->setText(QString::fromStdString(tfriendout.str()));
std::ostringstream tfofout; ui.totalFOFLineEdit->setText(QString::number(nFOF * fofBandwidth * 2));
tfofout << nFOF * fofBandwidth * 2;
ui.totalFOFLineEdit->setText(QString::fromStdString(tfofout.str()));
std::ostringstream tgenout; ui.totalGeneralLineEdit->setText(QString::number(nGeneral * genBandwidth * 2));
tgenout << nGeneral * genBandwidth * 2;
ui.totalGeneralLineEdit->setText(QString::fromStdString(tgenout.str()));
std::ostringstream totalout; ui.totalBandwidthLineEdit->setText(QString::number((nFriends * friendBandwidth + nFOF * fofBandwidth + nGeneral * genBandwidth) * 2));
totalout << (nFriends * friendBandwidth
+ nFOF * fofBandwidth
+ nGeneral * genBandwidth) * 2;
ui.totalBandwidthLineEdit->setText(QString::fromStdString(totalout.str()));
std::ostringstream countout; ui.noTotalLineEdit->setText(QString::number(nFriends + nFOF + nGeneral));
countout << (nFriends + nFOF + nGeneral);
ui.noTotalLineEdit->setText(QString::fromStdString(countout.str()));
} }
void RelayPage::updateEnabled() void RelayPage::updateEnabled()
@ -274,5 +261,3 @@ void RelayPage::removeServer()
loadServers(); loadServers();
} }

View File

@ -26,7 +26,6 @@
#include "rsharesettings.h" #include "rsharesettings.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>

View File

@ -24,14 +24,11 @@
#include "rshare.h" #include "rshare.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <QTimer>
TransferPage::TransferPage(QWidget * parent, Qt::WFlags flags) TransferPage::TransferPage(QWidget * parent, Qt::WFlags flags)
: ConfigPage(parent, flags) : ConfigPage(parent, flags)
{ {

View File

@ -30,7 +30,6 @@
#include "util/misc.h" #include "util/misc.h"
#include <sstream>
#include <iomanip> #include <iomanip>
DHTStatus::DHTStatus(QWidget *parent) DHTStatus::DHTStatus(QWidget *parent)

View File

@ -24,8 +24,6 @@
#include "peerstatus.h" #include "peerstatus.h"
#include <sstream>
PeerStatus::PeerStatus(QWidget *parent) PeerStatus::PeerStatus(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
@ -50,16 +48,10 @@ void PeerStatus::getPeerStatus(unsigned int nFriendCount, unsigned int nOnlineCo
{ {
/* set users/friends/network */ /* set users/friends/network */
std::ostringstream out;
out << nFriendCount << " ";
std::ostringstream out2;
out2 << nOnlineCount << "";
statusPeers->setToolTip(tr("Online Friends/Total Friends") ); statusPeers->setToolTip(tr("Online Friends/Total Friends") );
if (statusPeers) if (statusPeers)
statusPeers -> setText( "<strong>" + tr("Friends") + ":</strong> " + QString::fromStdString(out2.str()) + "/" + QString::fromStdString(out.str()) ); statusPeers -> setText(QString("<strong>%1:</strong> %2/%3 ").arg(tr("Friends")).arg(nOnlineCount).arg(nFriendCount));
if (nOnlineCount > 0) if (nOnlineCount > 0)
{ {

View File

@ -25,7 +25,6 @@
#include "ratesstatus.h" #include "ratesstatus.h"
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <sstream>
#include <iomanip> #include <iomanip>
RatesStatus::RatesStatus(QWidget *parent) RatesStatus::RatesStatus(QWidget *parent)
@ -51,15 +50,8 @@ void RatesStatus::getRatesStatus(float downKb, float upKb)
{ {
/* set users/friends/network */ /* set users/friends/network */
std::ostringstream out;
out << std::setprecision(2) << std::fixed << downKb ;
std::ostringstream out2;
out2 << std::setprecision(2) << std::fixed << upKb ;
if (statusRates) if (statusRates)
statusRates -> setText( tr("<strong>Down:</strong>") + " " + QString::fromStdString(out.str()) + " (kB/s) | " + tr("<strong>Up:</strong>") + " " + QString::fromStdString(out2.str()) + " (kB/s) " ); statusRates -> setText(QString("<strong>%1:</strong> %2 (kB/s) | <strong>%3:</strong> %4 (kB/s) ").arg(tr("Down")).arg(downKb, 0, 'f', 2).arg(tr("Up")).arg(upKb, 0, 'f', 2));
if( upKb > 0 || downKb < 0 ) if( upKb > 0 || downKb < 0 )
{ {

View File

@ -32,7 +32,6 @@
//#include <retroshare/rsrank.h> //#include <retroshare/rsrank.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <map> #include <map>
#include <QContextMenuEvent> #include <QContextMenuEvent>

View File

@ -27,7 +27,6 @@
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>

View File

@ -28,7 +28,6 @@
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>

View File

@ -28,7 +28,6 @@
#include "util/RsAction.h" #include "util/RsAction.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <QtGui> #include <QtGui>
#include <QContextMenuEvent> #include <QContextMenuEvent>

View File

@ -28,7 +28,6 @@
#include <retroshare/rsphoto.h> #include <retroshare/rsphoto.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>

View File

@ -27,7 +27,6 @@
#include <retroshare/rsphoto.h> #include <retroshare/rsphoto.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>

View File

@ -28,7 +28,6 @@
#include <QTime> #include <QTime>
#include <QDateTime> #include <QDateTime>
#include <sstream>
#include <list> #include <list>
#include <iostream> #include <iostream>
#include <string> #include <string>

View File

@ -23,8 +23,6 @@
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <sstream>
#include <QMenu> #include <QMenu>

View File

@ -26,8 +26,6 @@
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <sstream>
//#include <QContextMenuEvent> //#include <QContextMenuEvent>
#include <QMenu> #include <QMenu>
#include <QFileDialog> #include <QFileDialog>

View File

@ -175,21 +175,21 @@ QString misc::userFriendlyDuration(qlonglong seconds)
} }
int minutes = seconds / 60; int minutes = seconds / 60;
if(minutes < 60) { if(minutes < 60) {
return tr("%1 minutes","e.g: 10minutes").arg(QString::QString::fromUtf8(misc::toString(minutes).c_str())); return tr("%1 minutes","e.g: 10minutes").arg(minutes);
} }
int hours = minutes / 60; int hours = minutes / 60;
minutes = minutes - hours*60; minutes = minutes - hours*60;
if(hours < 24) { if(hours < 24) {
return tr("%1h %2m", "e.g: 3hours 5minutes").arg(QString::fromUtf8(misc::toString(hours).c_str())).arg(QString::fromUtf8(misc::toString(minutes).c_str())); return tr("%1h %2m", "e.g: 3hours 5minutes").arg(hours).arg(minutes);
} }
int days = hours / 24; int days = hours / 24;
hours = hours - days * 24; hours = hours - days * 24;
if(days < 365) { if(days < 365) {
return tr("%1d %2h", "e.g: 2days 10hours").arg(QString::fromUtf8(misc::toString(days).c_str())).arg(QString::fromUtf8(misc::toString(hours).c_str())); return tr("%1d %2h", "e.g: 2days 10hours").arg(days).arg(hours);
} }
int years = days / 365; int years = days / 365;
days = days - years * 365; days = days - years * 365;
return tr("%1y %2d", "e.g: 2 years 2days ").arg(QString::fromUtf8(misc::toString(years).c_str())).arg(QString::fromUtf8(misc::toString(days).c_str())); return tr("%1y %2d", "e.g: 2 years 2days ").arg(years).arg(days);
} }
QString misc::userFriendlyUnit(double count, unsigned int decimal, double factor) QString misc::userFriendlyUnit(double count, unsigned int decimal, double factor)

View File

@ -23,7 +23,6 @@
#ifndef MISC_H #ifndef MISC_H
#define MISC_H #define MISC_H
#include <sstream>
#include <stdexcept> #include <stdexcept>
#include <QObject> #include <QObject>
#include <QPair> #include <QPair>
@ -39,45 +38,45 @@ class misc : public QObject
public: public:
// Convert any type of variable to C++ String // Convert any type of variable to C++ String
// convert=true will convert -1 to 0 // convert=true will convert -1 to 0
template <class T> static std::string toString(const T& x, bool convert=false) { // template <class T> static std::string toString(const T& x, bool convert=false) {
std::ostringstream o; // std::ostringstream o;
if(!(o<<x)) { // if(!(o<<x)) {
throw std::runtime_error("::toString()"); // throw std::runtime_error("::toString()");
} // }
if(o.str() == "-1" && convert) // if(o.str() == "-1" && convert)
return "0"; // return "0";
return o.str(); // return o.str();
} // }
template <class T> static QString toQString(const T& x, bool convert=false) { // template <class T> static QString toQString(const T& x, bool convert=false) {
std::ostringstream o; // std::ostringstream o;
if(!(o<<x)) { // if(!(o<<x)) {
throw std::runtime_error("::toString()"); // throw std::runtime_error("::toString()");
} // }
if(o.str() == "-1" && convert) // if(o.str() == "-1" && convert)
return QString::fromUtf8("0"); // return QString::fromUtf8("0");
return QString::fromUtf8(o.str().c_str()); // return QString::fromUtf8(o.str().c_str());
} // }
template <class T> static QByteArray toQByteArray(const T& x, bool convert=false) { // template <class T> static QByteArray toQByteArray(const T& x, bool convert=false) {
std::ostringstream o; // std::ostringstream o;
if(!(o<<x)) { // if(!(o<<x)) {
throw std::runtime_error("::toString()"); // throw std::runtime_error("::toString()");
} // }
if(o.str() == "-1" && convert) // if(o.str() == "-1" && convert)
return "0"; // return "0";
return QByteArray(o.str().c_str()); // return QByteArray(o.str().c_str());
} // }
// Convert C++ string to any type of variable // Convert C++ string to any type of variable
template <class T> static T fromString(const std::string& s) { // template <class T> static T fromString(const std::string& s) {
T x; // T x;
std::istringstream i(s); // std::istringstream i(s);
if(!(i>>x)) { // if(!(i>>x)) {
throw std::runtime_error("::fromString()"); // throw std::runtime_error("::fromString()");
} // }
return x; // return x;
} // }
// template <class T> static T fromQString::fromUtf8(const QString& s) { // template <class T> static T fromQString::fromUtf8(const QString& s) {
// T x; // T x;