mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 17:15:31 -05:00
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:
parent
9ef7d08d2b
commit
4cb844c44d
@ -19,7 +19,6 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <sstream>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <algorithm>
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#define URL_FAQ "http://retroshare.sourceforge.net/wiki/index.php/Frequently_Asked_Questions"
|
||||
#define URL_FORUM "http://retroshare.sourceforge.net/forum/"
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <retroshare/rsdisc.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTextStream>
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <retroshare/rsiface.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTextStream>
|
||||
|
@ -93,7 +93,6 @@
|
||||
#include "settings/rsharesettings.h"
|
||||
#include "common/StatusDefs.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "settings/rsharesettings.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
/*****
|
||||
@ -1184,7 +1183,7 @@ void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std
|
||||
QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) const
|
||||
{
|
||||
/* extract from each the member text */
|
||||
std::string text;
|
||||
QString text;
|
||||
QModelIndexList::const_iterator it;
|
||||
std::map<std::string, uint64_t> drags;
|
||||
std::map<std::string, uint64_t>::iterator dit;
|
||||
@ -1235,17 +1234,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
|
||||
|
||||
drags[details.hash] = details.count;
|
||||
|
||||
std::string line = details.name;
|
||||
line += "/";
|
||||
line += details.hash;
|
||||
line += "/";
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << details.count;
|
||||
line += out.str();
|
||||
line += "/";
|
||||
}
|
||||
QString line = QString("%1/%2/%3/").arg(QString::fromUtf8(details.name.c_str())).arg(QString::fromStdString(details.hash)).arg(details.count);
|
||||
|
||||
if (RemoteMode)
|
||||
{
|
||||
@ -1269,11 +1258,9 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
|
||||
#endif
|
||||
|
||||
QMimeData *data = new QMimeData();
|
||||
data->setData("application/x-rsfilelist", QByteArray(text.c_str()));
|
||||
data->setData("application/x-rsfilelist", QByteArray(text.toAscii()));
|
||||
|
||||
return data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
QStringList RetroshareDirModel::mimeTypes () const
|
||||
|
@ -1171,8 +1171,6 @@ void SearchDialog::resultsToTree(std::string txt,qulonglong searchId, const std:
|
||||
ui.searchResultWidget->setSortingEnabled(false);
|
||||
|
||||
/* translate search results */
|
||||
std::ostringstream out;
|
||||
out << searchId;
|
||||
|
||||
std::list<DirDetails>::const_iterator it;
|
||||
for(it = results.begin(); it != results.end(); it++)
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include <iostream>
|
||||
#include <QTimer>
|
||||
#include <QObject>
|
||||
#include <retroshare/rsturtle.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||
#include <retroshare/rsiface.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -109,9 +108,7 @@ void ChannelDetails::loadChannel()
|
||||
|
||||
// Set Channel Popularity
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << ci.pop;
|
||||
ui.popline -> setText(QString::fromStdString(out.str()));
|
||||
ui.popline -> setText(QString::number(ci.pop));
|
||||
}
|
||||
|
||||
// Set Last Channel Post Date
|
||||
|
@ -1331,15 +1331,14 @@ QTreeWidgetItem *FriendList::getCurrentPeer() const
|
||||
}
|
||||
|
||||
/* Display the columns of this item. */
|
||||
std::ostringstream out;
|
||||
out << "CurrentPeerItem: " << std::endl;
|
||||
QString out = "CurrentPeerItem: \n";
|
||||
|
||||
for(int i = 1; i < COLUMN_COUNT; 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
|
||||
return item;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
@ -146,11 +145,11 @@ void DhtWindow::update()
|
||||
void DhtWindow::updateNetStatus()
|
||||
{
|
||||
|
||||
QString status;
|
||||
QString status;
|
||||
QString oldstatus;
|
||||
|
||||
#if 0
|
||||
status = QString::fromStdString(mPeerNet->getPeerStatusString());
|
||||
status = QString::fromStdString(mPeerNet->getPeerStatusString());
|
||||
oldstatus = ui->peerLine->text();
|
||||
if (oldstatus != status)
|
||||
{
|
||||
@ -158,7 +157,7 @@ void DhtWindow::updateNetStatus()
|
||||
}
|
||||
#endif
|
||||
|
||||
status = QString::fromStdString(rsDht->getUdpAddressString());
|
||||
status = QString::fromStdString(rsDht->getUdpAddressString());
|
||||
oldstatus = ui->peerAddressLabel->text();
|
||||
if (oldstatus != status)
|
||||
{
|
||||
@ -242,29 +241,29 @@ void DhtWindow::updateNetStatus()
|
||||
uint32_t connect = rsConfig->getConnectModes();
|
||||
|
||||
label = ui->connectLabel;
|
||||
std::ostringstream connOut;
|
||||
QString connOut;
|
||||
if (connect & RSNET_CONNECT_OUTGOING_TCP)
|
||||
{
|
||||
connOut << "TCP_OUT ";
|
||||
connOut += "TCP_OUT ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_ACCEPT_TCP)
|
||||
{
|
||||
connOut << "TCP_IN ";
|
||||
connOut += "TCP_IN ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_DIRECT_UDP)
|
||||
{
|
||||
connOut << "DIRECT_UDP ";
|
||||
connOut += "DIRECT_UDP ";
|
||||
}
|
||||
if (connect & RSNET_CONNECT_PROXY_UDP)
|
||||
{
|
||||
connOut << "PROXY_UDP ";
|
||||
connOut += "PROXY_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();
|
||||
|
||||
@ -306,8 +305,6 @@ void DhtWindow::updateNetStatus()
|
||||
|
||||
void DhtWindow::updateNetPeers()
|
||||
{
|
||||
|
||||
|
||||
QTreeWidget *peerTreeWidget = ui->peerTreeWidget;
|
||||
|
||||
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_RSID, Qt::DisplayRole, QString::fromStdString(status.mRsId));
|
||||
|
||||
std::ostringstream dhtstate;
|
||||
QString dhtstate;
|
||||
switch(status.mDhtState)
|
||||
{
|
||||
default:
|
||||
case RSDHT_PEERDHT_NOT_ACTIVE:
|
||||
dhtstate << "Not Active (Maybe Connected!)";
|
||||
dhtstate = "Not Active (Maybe Connected!)";
|
||||
break;
|
||||
case RSDHT_PEERDHT_SEARCHING:
|
||||
dhtstate << "Searching";
|
||||
dhtstate = "Searching";
|
||||
break;
|
||||
case RSDHT_PEERDHT_FAILURE:
|
||||
dhtstate << "Failed";
|
||||
dhtstate = "Failed";
|
||||
break;
|
||||
case RSDHT_PEERDHT_OFFLINE:
|
||||
dhtstate << "offline";
|
||||
dhtstate = "offline";
|
||||
nOfflinePeers++;
|
||||
break;
|
||||
case RSDHT_PEERDHT_UNREACHABLE:
|
||||
dhtstate << "Unreachable";
|
||||
dhtstate = "Unreachable";
|
||||
nUnreachablePeers++;
|
||||
break;
|
||||
case RSDHT_PEERDHT_ONLINE:
|
||||
dhtstate << "ONLINE";
|
||||
dhtstate = "ONLINE";
|
||||
nOnlinePeers++;
|
||||
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
|
||||
std::ostringstream cpmstr;
|
||||
QString cpmstr;
|
||||
switch(status.mPeerConnectMode)
|
||||
{
|
||||
case RSDHT_TOU_MODE_DIRECT:
|
||||
cpmstr << "Direct";
|
||||
cpmstr = "Direct";
|
||||
break;
|
||||
case RSDHT_TOU_MODE_PROXY:
|
||||
cpmstr << "Proxy VIA ";
|
||||
cpmstr << status.mPeerConnectProxyId;
|
||||
cpmstr = "Proxy VIA " + QString::fromStdString(status.mPeerConnectProxyId);
|
||||
break;
|
||||
case RSDHT_TOU_MODE_RELAY:
|
||||
cpmstr << "Relay VIA ";
|
||||
cpmstr << status.mPeerConnectProxyId;
|
||||
cpmstr = "Relay VIA " + QString::fromStdString(status.mPeerConnectProxyId);
|
||||
break;
|
||||
default:
|
||||
cpmstr << "None";
|
||||
cpmstr = "None";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
std::ostringstream cpsstr;
|
||||
QString cpsstr;
|
||||
switch(status.mPeerConnectState)
|
||||
{
|
||||
default:
|
||||
case RSDHT_PEERCONN_DISCONNECTED:
|
||||
cpsstr << "Disconnected";
|
||||
cpsstr = "Disconnected";
|
||||
nDisconnPeers++;
|
||||
break;
|
||||
case RSDHT_PEERCONN_UDP_STARTED:
|
||||
cpsstr << "Udp Started";
|
||||
cpsstr = "Udp Started";
|
||||
break;
|
||||
case RSDHT_PEERCONN_CONNECTED:
|
||||
{
|
||||
cpsstr << "Connected";
|
||||
cpsstr = "Connected";
|
||||
break;
|
||||
switch(status.mPeerConnectMode)
|
||||
{
|
||||
@ -481,7 +476,7 @@ void DhtWindow::updateNetPeers()
|
||||
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)
|
||||
{
|
||||
@ -489,28 +484,28 @@ void DhtWindow::updateNetPeers()
|
||||
}
|
||||
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.
|
||||
std::ostringstream reqstr;
|
||||
if (status.mExclusiveProxyLock)
|
||||
{
|
||||
reqstr << "(E) ";
|
||||
}
|
||||
QString reqstr;
|
||||
if (status.mExclusiveProxyLock)
|
||||
{
|
||||
reqstr = "(E) ";
|
||||
}
|
||||
switch(status.mPeerReqState)
|
||||
{
|
||||
case RSDHT_PEERREQ_RUNNING:
|
||||
reqstr << "Request Active";
|
||||
reqstr += "Request Active";
|
||||
break;
|
||||
case RSDHT_PEERREQ_STOPPED:
|
||||
reqstr << "No Request";
|
||||
reqstr += "No Request";
|
||||
break;
|
||||
default:
|
||||
reqstr << "Unknown";
|
||||
reqstr += "Unknown";
|
||||
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_CONNECTLOGIC, Qt::DisplayRole,
|
||||
@ -518,20 +513,18 @@ void DhtWindow::updateNetPeers()
|
||||
}
|
||||
|
||||
|
||||
std::ostringstream connstr;
|
||||
connstr << "#Peers: " << nPeers;
|
||||
connstr << " DHT: (#off:" << nOfflinePeers;
|
||||
connstr << ",unreach:" << nUnreachablePeers;
|
||||
connstr << ",online:" << nOnlinePeers;
|
||||
connstr << ") Connections: (#dis:" << nDisconnPeers;
|
||||
connstr << ",#dir:" << nDirectPeers;
|
||||
connstr << ",#proxy:" << nProxyPeers;
|
||||
connstr << ",#relay:" << nRelayPeers;
|
||||
connstr << ")";
|
||||
|
||||
QLabel *label = ui->peerSummaryLabel;
|
||||
label->setText(QString::fromStdString(connstr.str()));
|
||||
QString connstr;
|
||||
connstr = "#Peers: " + QString::number(nPeers);
|
||||
connstr += " DHT: (#off:" + QString::number(nOfflinePeers);
|
||||
connstr += ",unreach:" + QString::number(nUnreachablePeers);
|
||||
connstr += ",online:" + QString::number(nOnlinePeers);
|
||||
connstr += ") Connections: (#dis:" + QString::number(nDisconnPeers);
|
||||
connstr += ",#dir:" + QString::number(nDirectPeers);
|
||||
connstr += ",#proxy:" + QString::number(nProxyPeers);
|
||||
connstr += ",#relay:" + QString::number(nRelayPeers);
|
||||
connstr += ")";
|
||||
|
||||
ui->peerSummaryLabel->setText(connstr);
|
||||
}
|
||||
|
||||
|
||||
@ -569,42 +562,26 @@ void DhtWindow::updateRelays()
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
relayTreeWidget->addTopLevelItem(item);
|
||||
|
||||
std::ostringstream typestr;
|
||||
typestr << "RELAY END";
|
||||
|
||||
std::ostringstream srcstr;
|
||||
srcstr << "Yourself";
|
||||
|
||||
std::ostringstream proxystr;
|
||||
proxystr << reit->mProxyAddr;
|
||||
|
||||
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";
|
||||
QString typestr = "RELAY END";
|
||||
QString srcstr = "Yourself";
|
||||
QString proxystr = QString::fromStdString(reit->mProxyAddr);
|
||||
QString deststr = QString::fromStdString(reit->mRemoteAddr);
|
||||
QString agestr = "unknown";
|
||||
QString lastsendstr = "unknown";
|
||||
QString bandwidthstr = "unlimited";
|
||||
QString classstr = "Own Relay";
|
||||
|
||||
//std::ostringstream dhtupdatestr;
|
||||
//dhtupdatestr << now - status.mDhtUpdateTS << " secs ago";
|
||||
|
||||
|
||||
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()));
|
||||
item -> setData(RTW_COL_TYPE, Qt::DisplayRole, typestr);
|
||||
item -> setData(RTW_COL_SRC, Qt::DisplayRole, srcstr);
|
||||
item -> setData(RTW_COL_PROXY, Qt::DisplayRole, proxystr);
|
||||
item -> setData(RTW_COL_DEST, Qt::DisplayRole, deststr);
|
||||
item -> setData(RTW_COL_CLASS, Qt::DisplayRole, classstr);
|
||||
item -> setData(RTW_COL_AGE, Qt::DisplayRole, agestr);
|
||||
item -> setData(RTW_COL_LASTSEND, Qt::DisplayRole, lastsendstr);
|
||||
item -> setData(RTW_COL_BANDWIDTH, Qt::DisplayRole, bandwidthstr);
|
||||
|
||||
}
|
||||
|
||||
@ -615,38 +592,23 @@ void DhtWindow::updateRelays()
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
relayTreeWidget->addTopLevelItem(item);
|
||||
|
||||
std::ostringstream typestr;
|
||||
typestr << "RELAY PROXY";
|
||||
QString 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;
|
||||
srcstr << rpit->mSrcAddr;
|
||||
|
||||
std::ostringstream proxystr;
|
||||
proxystr << "Yourself";
|
||||
|
||||
std::ostringstream deststr;
|
||||
deststr << rpit->mDestAddr;
|
||||
|
||||
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()));
|
||||
item -> setData(RTW_COL_TYPE, Qt::DisplayRole, typestr);
|
||||
item -> setData(RTW_COL_SRC, Qt::DisplayRole, srcstr);
|
||||
item -> setData(RTW_COL_PROXY, Qt::DisplayRole, proxystr);
|
||||
item -> setData(RTW_COL_DEST, Qt::DisplayRole, deststr);
|
||||
item -> setData(RTW_COL_CLASS, Qt::DisplayRole, classstr);
|
||||
item -> setData(RTW_COL_AGE, Qt::DisplayRole, agestr);
|
||||
item -> setData(RTW_COL_LASTSEND, Qt::DisplayRole, lastsendstr);
|
||||
item -> setData(RTW_COL_BANDWIDTH, Qt::DisplayRole, bandwidthstr);
|
||||
|
||||
}
|
||||
}
|
||||
@ -717,43 +679,32 @@ void DhtWindow::updateDhtPeers()
|
||||
/* insert */
|
||||
dht_item = new DhtTreeWidgetItem();
|
||||
|
||||
int dist = it->mBucket;
|
||||
std::ostringstream buckstr;
|
||||
buckstr << dist;
|
||||
QString buckstr = QString::number(it->mBucket);
|
||||
QString ipstr = QString::fromStdString(it->mAddr);
|
||||
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;
|
||||
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;
|
||||
QString lastsendstr;
|
||||
if (it->mLastSendTime == 0)
|
||||
{
|
||||
lastsendstr << "never";
|
||||
lastsendstr = "never";
|
||||
}
|
||||
else
|
||||
{
|
||||
lastsendstr << now - it->mLastSendTime << " secs ago";
|
||||
lastsendstr = QString ("%1 secs ago").arg(now - it->mLastSendTime);
|
||||
}
|
||||
|
||||
std::ostringstream lastrecvstr;
|
||||
lastrecvstr << now - it->mLastRecvTime << " secs ago";
|
||||
QString lastrecvstr = QString ("%1 secs ago").arg(now - it->mLastRecvTime);
|
||||
|
||||
dht_item -> setData(DTW_COL_BUCKET, Qt::DisplayRole, QString::fromStdString(buckstr.str()));
|
||||
dht_item -> setData(DTW_COL_IPADDR, Qt::DisplayRole, QString::fromStdString(ipstr.str()));
|
||||
dht_item -> setData(DTW_COL_PEERID, Qt::DisplayRole, QString::fromStdString(idstr.str()));
|
||||
dht_item -> setData(DTW_COL_FLAGS, Qt::DisplayRole, QString::fromStdString(flagsstr.str()));
|
||||
dht_item -> setData(DTW_COL_BUCKET, Qt::DisplayRole, buckstr);
|
||||
dht_item -> setData(DTW_COL_IPADDR, Qt::DisplayRole, ipstr);
|
||||
dht_item -> setData(DTW_COL_PEERID, Qt::DisplayRole, idstr);
|
||||
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_SEND, Qt::DisplayRole, QString::fromStdString(lastsendstr.str()));
|
||||
dht_item -> setData(DTW_COL_RECV, Qt::DisplayRole, QString::fromStdString(lastrecvstr.str()));
|
||||
dht_item -> setData(DTW_COL_FOUND, Qt::DisplayRole, foundstr);
|
||||
dht_item -> setData(DTW_COL_SEND, Qt::DisplayRole, lastsendstr);
|
||||
dht_item -> setData(DTW_COL_RECV, Qt::DisplayRole, lastrecvstr);
|
||||
|
||||
dhtTreeWidget->addTopLevelItem(dht_item);
|
||||
}
|
||||
|
@ -33,9 +33,6 @@
|
||||
|
||||
#include <retroshare/rschannels.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
/****
|
||||
* #define DEBUG_ITEM 1
|
||||
****/
|
||||
@ -170,12 +167,8 @@ void ChanMsgItem::updateItemStatic()
|
||||
qtime.setTime_t(cmi.ts);
|
||||
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
|
||||
datetimelabel->setText(timestamp);
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "(" << cmi.count << " Files)";
|
||||
filelabel->setText(QString::fromStdString(out.str()) + " " + misc::friendlyUnit(cmi.size));
|
||||
}
|
||||
|
||||
filelabel->setText(QString("(%1 %2) %3").arg(cmi.count).arg(tr("Files")).arg(misc::friendlyUnit(cmi.size)));
|
||||
|
||||
if (mFileItems.empty() == false) {
|
||||
std::list<SubFileItem *>::iterator it;
|
||||
|
@ -35,8 +35,6 @@
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/*****
|
||||
* #define DEBUG_ITEM 1
|
||||
****/
|
||||
|
@ -34,8 +34,6 @@
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/*****
|
||||
* #define DEBUG_ITEM 1
|
||||
****/
|
||||
@ -194,14 +192,7 @@ void PeerItem::updateItem()
|
||||
statusLabel->setText(status);
|
||||
trustLabel->setText(QString::fromStdString(RsPeerTrustString(details.trustLvl)));
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << details.localAddr << ":";
|
||||
out << details.localPort << "/";
|
||||
out << details.extAddr << ":";
|
||||
out << details.extPort;
|
||||
ipLabel->setText(QString::fromStdString(out.str()));
|
||||
}
|
||||
ipLabel->setText(QString("%1:%2/%3:%4").arg(QString::fromStdString(details.localAddr)).arg(details.localPort).arg(QString::fromStdString(details.extAddr)).arg(details.extPort));
|
||||
|
||||
connLabel->setText(StatusDefs::connectStateString(details));
|
||||
|
||||
|
@ -36,8 +36,6 @@
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/*****
|
||||
* #define DEBUG_ITEM 1
|
||||
****/
|
||||
@ -220,14 +218,7 @@ void SecurityItem::updateItem()
|
||||
statusLabel->setText(status);
|
||||
trustLabel->setText(QString::fromStdString(RsPeerTrustString(details.trustLvl)));
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << details.localAddr << ":";
|
||||
out << details.localPort << "/";
|
||||
out << details.extAddr << ":";
|
||||
out << details.extPort;
|
||||
ipLabel->setText(QString::fromStdString(out.str()));
|
||||
}
|
||||
ipLabel->setText(QString("%1:%2/%3:%4").arg(QString::fromStdString(details.localAddr)).arg(details.localPort).arg(QString::fromStdString(details.extAddr)).arg(details.extPort));
|
||||
|
||||
connLabel->setText(StatusDefs::connectStateString(details));
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
@ -46,10 +46,6 @@
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "SoundManager.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <time.h>
|
||||
|
||||
/*****
|
||||
* #define NOTIFY_DEBUG
|
||||
****/
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTime>
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
/* Define the format used for displaying the date and time */
|
||||
@ -65,55 +64,50 @@ void ProfileWidget::closeEvent (QCloseEvent * event)
|
||||
|
||||
void ProfileWidget::showEvent ( QShowEvent * /*event*/ )
|
||||
{
|
||||
|
||||
RsPeerDetails detail;
|
||||
RsPeerDetails detail;
|
||||
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),detail))
|
||||
{
|
||||
|
||||
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
|
||||
ui.country->setText(QString::fromUtf8(detail.location.c_str()));
|
||||
|
||||
ui.peerid->setText(QString::fromStdString(detail.id));
|
||||
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
|
||||
ui.country->setText(QString::fromUtf8(detail.location.c_str()));
|
||||
|
||||
ui.peerid->setText(QString::fromStdString(detail.id));
|
||||
|
||||
// Dont Show a timestamp in RS calculate the day
|
||||
QDateTime date = QDateTime::fromTime_t(detail.lastConnect);
|
||||
QString stime = date.toString(Qt::LocalDate);
|
||||
// Dont Show a timestamp in RS calculate the day
|
||||
QDateTime date = QDateTime::fromTime_t(detail.lastConnect);
|
||||
QString stime = date.toString(Qt::LocalDate);
|
||||
|
||||
/* set retroshare version */
|
||||
std::map<std::string, std::string>::iterator vit;
|
||||
std::map<std::string, std::string> versions;
|
||||
bool retv = rsDisc->getDiscVersions(versions);
|
||||
if (retv && versions.end() != (vit = versions.find(detail.id)))
|
||||
{
|
||||
ui.version->setText(QString::fromStdString(vit->second));
|
||||
}
|
||||
/* set retroshare version */
|
||||
std::map<std::string, std::string>::iterator vit;
|
||||
std::map<std::string, std::string> versions;
|
||||
bool retv = rsDisc->getDiscVersions(versions);
|
||||
if (retv && versions.end() != (vit = versions.find(detail.id)))
|
||||
{
|
||||
ui.version->setText(QString::fromStdString(vit->second));
|
||||
}
|
||||
|
||||
ui.ipAddressList->clear();
|
||||
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
|
||||
ui.ipAddressList->addItem(QString::fromStdString(*it));
|
||||
ui.ipAddressList->clear();
|
||||
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
|
||||
ui.ipAddressList->addItem(QString::fromStdString(*it));
|
||||
|
||||
|
||||
/* set local address */
|
||||
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
|
||||
ui.localPort -> setText(QString::number(detail.localPort));
|
||||
/* set the server address */
|
||||
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
|
||||
ui.extPort -> setText(QString::number(detail.extPort));
|
||||
/* set DynDNS */
|
||||
ui.dyndns->setText(QString::fromStdString(detail.dyndns));
|
||||
ui.dyndns->setCursorPosition (0);
|
||||
|
||||
std::list<std::string> ids;
|
||||
ids.clear();
|
||||
rsPeers->getGPGAcceptedList(ids);
|
||||
int friends = ids.size();
|
||||
|
||||
std::ostringstream out;
|
||||
out << friends << "";
|
||||
ui.friendsEdit->setText(QString::fromStdString(out.str()));
|
||||
|
||||
/* set local address */
|
||||
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
|
||||
ui.localPort -> setText(QString::number(detail.localPort));
|
||||
/* set the server address */
|
||||
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
|
||||
ui.extPort -> setText(QString::number(detail.extPort));
|
||||
/* set DynDNS */
|
||||
ui.dyndns->setText(QString::fromStdString(detail.dyndns));
|
||||
ui.dyndns->setCursorPosition (0);
|
||||
|
||||
std::list<std::string> ids;
|
||||
ids.clear();
|
||||
rsPeers->getGPGAcceptedList(ids);
|
||||
int friends = ids.size();
|
||||
|
||||
ui.friendsEdit->setText(QString::number(friends));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ProfileWidget::statusmessagedlg()
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include <QTime>
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "rshare.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
@ -175,27 +174,15 @@ void RelayPage::updateRelayOptions()
|
||||
int nGeneral = ui.noGeneralSpinBox->value();
|
||||
int genBandwidth = ui.bandGeneralSpinBox->value();
|
||||
|
||||
std::ostringstream tfriendout;
|
||||
tfriendout << nFriends * friendBandwidth * 2;
|
||||
ui.totalFriendLineEdit->setText(QString::fromStdString(tfriendout.str()));
|
||||
ui.totalFriendLineEdit->setText(QString::number(nFriends * friendBandwidth * 2));
|
||||
|
||||
std::ostringstream tfofout;
|
||||
tfofout << nFOF * fofBandwidth * 2;
|
||||
ui.totalFOFLineEdit->setText(QString::fromStdString(tfofout.str()));
|
||||
ui.totalFOFLineEdit->setText(QString::number(nFOF * fofBandwidth * 2));
|
||||
|
||||
std::ostringstream tgenout;
|
||||
tgenout << nGeneral * genBandwidth * 2;
|
||||
ui.totalGeneralLineEdit->setText(QString::fromStdString(tgenout.str()));
|
||||
ui.totalGeneralLineEdit->setText(QString::number(nGeneral * genBandwidth * 2));
|
||||
|
||||
std::ostringstream totalout;
|
||||
totalout << (nFriends * friendBandwidth
|
||||
+ nFOF * fofBandwidth
|
||||
+ nGeneral * genBandwidth) * 2;
|
||||
ui.totalBandwidthLineEdit->setText(QString::fromStdString(totalout.str()));
|
||||
ui.totalBandwidthLineEdit->setText(QString::number((nFriends * friendBandwidth + nFOF * fofBandwidth + nGeneral * genBandwidth) * 2));
|
||||
|
||||
std::ostringstream countout;
|
||||
countout << (nFriends + nFOF + nGeneral);
|
||||
ui.noTotalLineEdit->setText(QString::fromStdString(countout.str()));
|
||||
ui.noTotalLineEdit->setText(QString::number(nFriends + nFOF + nGeneral));
|
||||
}
|
||||
|
||||
void RelayPage::updateEnabled()
|
||||
@ -274,5 +261,3 @@ void RelayPage::removeServer()
|
||||
|
||||
loadServers();
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "rsharesettings.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
@ -24,14 +24,11 @@
|
||||
#include "rshare.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
TransferPage::TransferPage(QWidget * parent, Qt::WFlags flags)
|
||||
: ConfigPage(parent, flags)
|
||||
{
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
DHTStatus::DHTStatus(QWidget *parent)
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "peerstatus.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
PeerStatus::PeerStatus(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@ -50,16 +48,10 @@ void PeerStatus::getPeerStatus(unsigned int nFriendCount, unsigned int nOnlineCo
|
||||
{
|
||||
/* set users/friends/network */
|
||||
|
||||
std::ostringstream out;
|
||||
out << nFriendCount << " ";
|
||||
|
||||
std::ostringstream out2;
|
||||
out2 << nOnlineCount << "";
|
||||
|
||||
statusPeers->setToolTip(tr("Online Friends/Total Friends") );
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "ratesstatus.h"
|
||||
#include <retroshare/rsiface.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
RatesStatus::RatesStatus(QWidget *parent)
|
||||
@ -51,16 +50,9 @@ void RatesStatus::getRatesStatus(float downKb, float upKb)
|
||||
{
|
||||
/* 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)
|
||||
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 )
|
||||
{
|
||||
iconLabel->setPixmap(QPixmap(":/images/up1down0.png"));
|
||||
|
@ -32,7 +32,6 @@
|
||||
//#include <retroshare/rsrank.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <retroshare/rsiface.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "util/RsAction.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <QtGui>
|
||||
#include <QContextMenuEvent>
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <retroshare/rsphoto.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <retroshare/rsphoto.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
//#include <QContextMenuEvent>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
|
@ -175,21 +175,21 @@ QString misc::userFriendlyDuration(qlonglong seconds)
|
||||
}
|
||||
int minutes = seconds / 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;
|
||||
minutes = minutes - hours*60;
|
||||
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;
|
||||
hours = hours - days * 24;
|
||||
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;
|
||||
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)
|
||||
|
@ -23,7 +23,6 @@
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
@ -39,45 +38,45 @@ class misc : public QObject
|
||||
public:
|
||||
// Convert any type of variable to C++ String
|
||||
// convert=true will convert -1 to 0
|
||||
template <class T> static std::string toString(const T& x, bool convert=false) {
|
||||
std::ostringstream o;
|
||||
if(!(o<<x)) {
|
||||
throw std::runtime_error("::toString()");
|
||||
}
|
||||
if(o.str() == "-1" && convert)
|
||||
return "0";
|
||||
return o.str();
|
||||
}
|
||||
// template <class T> static std::string toString(const T& x, bool convert=false) {
|
||||
// std::ostringstream o;
|
||||
// if(!(o<<x)) {
|
||||
// throw std::runtime_error("::toString()");
|
||||
// }
|
||||
// if(o.str() == "-1" && convert)
|
||||
// return "0";
|
||||
// return o.str();
|
||||
// }
|
||||
|
||||
template <class T> static QString toQString(const T& x, bool convert=false) {
|
||||
std::ostringstream o;
|
||||
if(!(o<<x)) {
|
||||
throw std::runtime_error("::toString()");
|
||||
}
|
||||
if(o.str() == "-1" && convert)
|
||||
return QString::fromUtf8("0");
|
||||
return QString::fromUtf8(o.str().c_str());
|
||||
}
|
||||
// template <class T> static QString toQString(const T& x, bool convert=false) {
|
||||
// std::ostringstream o;
|
||||
// if(!(o<<x)) {
|
||||
// throw std::runtime_error("::toString()");
|
||||
// }
|
||||
// if(o.str() == "-1" && convert)
|
||||
// return QString::fromUtf8("0");
|
||||
// return QString::fromUtf8(o.str().c_str());
|
||||
// }
|
||||
|
||||
template <class T> static QByteArray toQByteArray(const T& x, bool convert=false) {
|
||||
std::ostringstream o;
|
||||
if(!(o<<x)) {
|
||||
throw std::runtime_error("::toString()");
|
||||
}
|
||||
if(o.str() == "-1" && convert)
|
||||
return "0";
|
||||
return QByteArray(o.str().c_str());
|
||||
}
|
||||
// template <class T> static QByteArray toQByteArray(const T& x, bool convert=false) {
|
||||
// std::ostringstream o;
|
||||
// if(!(o<<x)) {
|
||||
// throw std::runtime_error("::toString()");
|
||||
// }
|
||||
// if(o.str() == "-1" && convert)
|
||||
// return "0";
|
||||
// return QByteArray(o.str().c_str());
|
||||
// }
|
||||
|
||||
// Convert C++ string to any type of variable
|
||||
template <class T> static T fromString(const std::string& s) {
|
||||
T x;
|
||||
std::istringstream i(s);
|
||||
if(!(i>>x)) {
|
||||
throw std::runtime_error("::fromString()");
|
||||
}
|
||||
return x;
|
||||
}
|
||||
// template <class T> static T fromString(const std::string& s) {
|
||||
// T x;
|
||||
// std::istringstream i(s);
|
||||
// if(!(i>>x)) {
|
||||
// throw std::runtime_error("::fromString()");
|
||||
// }
|
||||
// return x;
|
||||
// }
|
||||
|
||||
// template <class T> static T fromQString::fromUtf8(const QString& s) {
|
||||
// T x;
|
||||
|
Loading…
x
Reference in New Issue
Block a user