Fixed some more utf8 handling in the GUI.

Optimized creation of the RetroShare links for forum and channel messages.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4194 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-05-08 23:11:27 +00:00
parent dd457e15c7
commit 0619463948
16 changed files with 73 additions and 48 deletions

View File

@ -232,7 +232,7 @@ void ChannelFeed::copyChannelLink()
ChannelInfo ci;
if (rsChannels->getChannelInfo(mChannelId, ci)) {
RetroShareLink link;
if (link.createChannel(QString::fromStdWString(ci.channelName), QString::fromStdString(ci.channelId), "")) {
if (link.createChannel(ci.channelId, "")) {
std::vector<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);

View File

@ -1425,7 +1425,7 @@ void ForumsDialog::copyForumLink()
ForumInfo fi;
if (rsForums->getForumInfo(mCurrForumId, fi)) {
RetroShareLink link;
if (link.createForum(QString::fromStdWString(fi.forumName), QString::fromStdString(fi.forumId), "")) {
if (link.createForum(fi.forumId, "")) {
std::vector<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);
@ -1442,7 +1442,7 @@ void ForumsDialog::copyMessageLink()
ForumInfo fi;
if (rsForums->getForumInfo(mCurrForumId, fi)) {
RetroShareLink link;
if (link.createForum(QString::fromStdWString(fi.forumName), QString::fromStdString(mCurrForumId), QString::fromStdString(mCurrThreadId))) {
if (link.createForum(mCurrForumId, mCurrThreadId)) {
std::vector<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);

View File

@ -572,11 +572,11 @@ void MessengerWindow::insertPeers()
}
#endif // MINIMAL_RSGUI
if (sCustomString.isEmpty()) {
sslItem -> setText( COLUMN_NAME, tr("location") + " : " + QString::fromStdString(sslDetail.location) + " " + StatusDefs::connectStateString(sslDetail));
sslItem -> setToolTip( COLUMN_NAME, tr("location") + " : " + QString::fromStdString(sslDetail.location));
sslItem -> setText( COLUMN_NAME, tr("location") + " : " + QString::fromUtf8(sslDetail.location.c_str()) + " " + StatusDefs::connectStateString(sslDetail));
sslItem -> setToolTip( COLUMN_NAME, tr("location") + " : " + QString::fromUtf8(sslDetail.location.c_str()));
} else {
sslItem -> setText( COLUMN_NAME, tr("location") + " : " + QString::fromStdString(sslDetail.location) + " " + StatusDefs::connectStateString(sslDetail));
sslItem -> setToolTip( COLUMN_NAME, tr("location") + " : " + QString::fromStdString(sslDetail.location) + " - " + sCustomString);
sslItem -> setText( COLUMN_NAME, tr("location") + " : " + QString::fromUtf8(sslDetail.location.c_str()) + " " + StatusDefs::connectStateString(sslDetail));
sslItem -> setToolTip( COLUMN_NAME, tr("location") + " : " + QString::fromUtf8(sslDetail.location.c_str()) + " - " + sCustomString);
/* store custom state string */
sslCustomStateStrings[sslDetail.id] = sCustomString;

View File

@ -255,7 +255,7 @@ PeersDialog::PeersDialog(QWidget *parent)
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) {
QString titleStr("<span style=\"font-size:16pt; font-weight:500;"
"color:#32cd32;\">%1</span>");
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::fromUtf8(pd.location.c_str())));
}
/* Hide platform specific features */
@ -907,7 +907,7 @@ void PeersDialog::insertPeers()
if (sslDetail.state & RS_PEER_STATE_CONNECTED) {
customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(sslDetail.id).c_str());
}
sText = tr("location") + " : " + QString::fromStdString(sslDetail.location);
sText = tr("location") + " : " + QString::fromUtf8(sslDetail.location.c_str());
if (customStateString.isEmpty() == false) {
sText += " - " + customStateString;
}

View File

@ -248,32 +248,57 @@ bool RetroShareLink::createPerson(const QString& name, const QString& hash)
return valid();
}
bool RetroShareLink::createForum(const QString& name, const QString& id, const QString& msgId)
bool RetroShareLink::createForum(const std::string& id, const std::string& msgId)
{
clear();
_name = name;
_hash = id;
_msgId = msgId;
if (!id.empty()) {
_hash = QString::fromStdString(id);
_msgId = QString::fromStdString(msgId);
_type = TYPE_FORUM;
if (msgId.empty()) {
ForumInfo fi;
if (rsForums->getForumInfo(id, fi)) {
_name = QString::fromStdWString(fi.forumName);
}
} else {
ForumMsgInfo mi;
if (rsForums->getForumMessage(id, msgId, mi)) {
_name = QString::fromStdWString(mi.title);
}
}
}
check();
return valid();
}
bool RetroShareLink::createChannel(const QString& name, const QString& id, const QString& msgId)
bool RetroShareLink::createChannel(const std::string& id, const std::string& msgId)
{
clear();
_name = name;
_size = 0;
_hash = id;
_msgId = msgId;
if (!id.empty()) {
_hash = QString::fromStdString(id);
_msgId = QString::fromStdString(msgId);
_type = TYPE_CHANNEL;
if (msgId.empty()) {
ChannelInfo ci;
if (rsChannels->getChannelInfo(id, ci)) {
_name = QString::fromStdWString(ci.channelName);
}
} else {
ChannelMsgInfo mi;
if (rsChannels->getChannelMessage(id, msgId, mi)) {
_name = QString::fromStdWString(mi.subject);
}
}
}
check();
return valid();

View File

@ -56,8 +56,8 @@ class RetroShareLink
bool createFile(const QString& name, uint64_t size, const QString& hash);
bool createPerson(const QString& name, const QString& hash);
bool createForum(const QString& name, const QString& id, const QString& msgId);
bool createChannel(const QString& name, const QString& id, const QString& msgId);
bool createForum(const std::string& id, const std::string& msgId);
bool createChannel(const std::string& id, const std::string& msgId);
bool createSearch(const QString& keywords);
bool createMessage(const std::string& peerId, const QString& subject);
@ -99,7 +99,7 @@ class RetroShareLink
void clear();
void check();
static bool checkHash(const QString& hash);
static bool checkName(const QString& hash);
static bool checkName(const QString& name);
bool _valid;
enumType _type;

View File

@ -1116,7 +1116,7 @@ void TransfersDialog::copyLink ()
}
RetroShareLink link;
if (link.createFile(QString::fromStdString(info.fname), info.size, QString::fromStdString(info.hash))) {
if (link.createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash))) {
links.push_back(link) ;
}
}

View File

@ -1245,7 +1245,7 @@ void PopupChatDialog::updatePeersCustomStateString(const QString& peer_id, const
ui.statusmessagelabel->hide();
} else {
ui.statusmessagelabel->show();
status_text = RsHtml::formatText(QString(status_string), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
status_text = RsHtml::formatText(status_string, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
ui.statusmessagelabel->setText(status_text);
}
}

View File

@ -142,7 +142,7 @@ void ConfCertDialog::load()
if (!detail.isOnlyGPGdetail) {
ui.loc->setText(QString::fromStdString(detail.location));
ui.loc->setText(QString::fromUtf8(detail.location.c_str()));
// Dont Show a timestamp in RS calculate the day
QDateTime date = QDateTime::fromTime_t(detail.lastConnect);
QString stime = date.toString(Qt::LocalDate);

View File

@ -435,7 +435,7 @@ int TextPage::nextId() const {
#endif
wizard()->setField(SSL_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.id));
wizard()->setField(GPG_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.gpg_id));
wizard()->setField(LOCATION_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.location));
wizard()->setField(LOCATION_FIELD_CONNECT_FRIEND_WIZARD, QString::fromUtf8(pd.location.c_str()));
wizard()->setField(CERT_STRING_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(certstr));
wizard()->setField("ext_friend_ip", QString::fromStdString(pd.extAddr));
@ -807,7 +807,7 @@ int CertificatePage::nextId() const
#endif
wizard()->setField(SSL_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.id));
wizard()->setField(GPG_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.gpg_id));
wizard()->setField(LOCATION_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.location));
wizard()->setField(LOCATION_FIELD_CONNECT_FRIEND_WIZARD, QString::fromUtf8(pd.location.c_str()));
wizard()->setField(CERT_STRING_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(certstr));
wizard()->setField("ext_friend_ip", QString::fromStdString(pd.extAddr));
@ -1072,7 +1072,7 @@ void ConclusionPage::initializePage() {
nameEdit->setText( QString::fromStdString( detail.name ) ) ;
trustEdit->setText(QString::fromStdString( trustString ) ) ;
emailEdit->setText(QString::fromStdString( detail.email ) );
locEdit->setText( QString::fromStdString( detail.location ) );
locEdit->setText( QString::fromUtf8( detail.location.c_str() ) );
signersEdit->setPlainText( ts );
std::list<RsGroupInfo> groupInfoList;
@ -1152,7 +1152,7 @@ int RsidPage::nextId() const {
if (rsidstr.empty() == false && rsPeers->getPeerDetails(rsidstr, pd) ) {
wizard()->setField(SSL_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.id));
wizard()->setField(GPG_ID_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.gpg_id));
wizard()->setField(LOCATION_FIELD_CONNECT_FRIEND_WIZARD, QString::fromStdString(pd.location));
wizard()->setField(LOCATION_FIELD_CONNECT_FRIEND_WIZARD, QString::fromUtf8(pd.location.c_str()));
wizard()->setField("ext_friend_ip", QString::fromStdString(pd.extAddr));
wizard()->setField("ext_friend_port", QString::number(pd.extPort));

View File

@ -105,11 +105,11 @@ void ChanMsgItem::updateItemStatic()
{
title = tr("Channel Feed") + ": ";
RetroShareLink link;
link.createChannel(QString::fromStdWString(ci.channelName), QString::fromStdString(ci.channelId), "");
link.createChannel(ci.channelId, "");
title += link.toHtml();
titleLabel->setText(title);
RetroShareLink msgLink;
msgLink.createChannel(QString::fromStdWString(cmi.subject), QString::fromStdString(cmi.channelId), QString::fromStdString(cmi.msgId));
msgLink.createChannel(cmi.channelId, cmi.msgId);
subjectLabel->setText(msgLink.toHtml());
if ((ci.channelFlags & RS_DISTRIB_SUBSCRIBED) || (ci.channelFlags & RS_DISTRIB_ADMIN)) {
@ -406,7 +406,7 @@ void ChanMsgItem::copyLink()
ChannelMsgInfo cmi;
if (rsChannels->getChannelMessage(mChanId, mMsgId, cmi)) {
RetroShareLink link;
if (link.createChannel(QString::fromStdWString(cmi.subject), QString::fromStdString(cmi.channelId), QString::fromStdString(cmi.msgId))) {
if (link.createChannel(cmi.channelId, cmi.msgId)) {
std::vector<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);

View File

@ -70,7 +70,7 @@ void ChanNewItem::updateItemStatic()
if (rsChannels->getChannelInfo(mChanId, ci))
{
RetroShareLink link;
link.createChannel(QString::fromStdWString(ci.channelName), QString::fromStdString(ci.channelId), "");
link.createChannel(ci.channelId, "");
nameLabel->setText(link.toHtml());
descLabel->setText(QString::fromStdWString(ci.channelDesc));

View File

@ -89,7 +89,7 @@ void ForumMsgItem::updateItemStatic()
if (rsForums->getForumInfo(mForumId, fi))
{
RetroShareLink link;
link.createForum(QString::fromStdWString(fi.forumName), QString::fromStdString(fi.forumId), "");
link.createForum(fi.forumId, "");
QString title = tr("Forum Post") + ": ";
title += link.toHtml();
@ -138,7 +138,7 @@ void ForumMsgItem::updateItemStatic()
}
RetroShareLink link;
link.createForum(QString::fromStdWString(msg.title), QString::fromStdString(msg.forumId), QString::fromStdString(msg.msgId));
link.createForum(msg.forumId, msg.msgId);
if (mIsTop)
{
@ -196,7 +196,7 @@ void ForumMsgItem::updateItemStatic()
mGpgIdPrev = msgParent.srcId;
RetroShareLink linkParent;
linkParent.createForum(QString::fromStdWString(msgParent.title), QString::fromStdString(msgParent.forumId), QString::fromStdString(msgParent.msgId));
linkParent.createForum(msgParent.forumId, msgParent.msgId);
prevSubLabel->setText(linkParent.toHtml());
prevMsgLabel->setText(RsHtml::formatText(QString::fromStdWString(msgParent.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));

View File

@ -71,7 +71,7 @@ void ForumNewItem::updateItemStatic()
if (rsForums->getForumInfo(mForumId, fi))
{
RetroShareLink link;
link.createForum(QString::fromStdWString(fi.forumName), QString::fromStdString(fi.forumId), "");
link.createForum(fi.forumId, "");
nameLabel->setText(link.toHtml());
descLabel->setText(QString::fromStdWString(fi.forumDesc));

View File

@ -128,9 +128,9 @@ void PeerItem::updateItemStatic()
lastLabel-> setText(stime);
/* expanded Info */
nameLabel->setText(QString::fromStdString(details.name));
nameLabel->setText(QString::fromUtf8(details.name.c_str()));
idLabel->setText(QString::fromStdString(details.id));
locLabel->setText(QString::fromStdString(details.location));
locLabel->setText(QString::fromUtf8(details.location.c_str()));
}
else
{

View File

@ -66,8 +66,8 @@ void ProfileWidget::showEvent ( QShowEvent * event )
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),detail))
{
ui.name->setText(QString::fromStdString(detail.name));
ui.country->setText(QString::fromStdString(detail.location));
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));