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; ChannelInfo ci;
if (rsChannels->getChannelInfo(mChannelId, ci)) { if (rsChannels->getChannelInfo(mChannelId, ci)) {
RetroShareLink link; RetroShareLink link;
if (link.createChannel(QString::fromStdWString(ci.channelName), QString::fromStdString(ci.channelId), "")) { if (link.createChannel(ci.channelId, "")) {
std::vector<RetroShareLink> urls; std::vector<RetroShareLink> urls;
urls.push_back(link); urls.push_back(link);
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);

View File

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

View File

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

View File

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

View File

@ -248,32 +248,57 @@ bool RetroShareLink::createPerson(const QString& name, const QString& hash)
return valid(); 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(); clear();
_name = name; if (!id.empty()) {
_hash = id; _hash = QString::fromStdString(id);
_msgId = msgId; _msgId = QString::fromStdString(msgId);
_type = TYPE_FORUM; _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(); check();
return valid(); 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(); clear();
_name = name; if (!id.empty()) {
_size = 0; _hash = QString::fromStdString(id);
_hash = id; _msgId = QString::fromStdString(msgId);
_msgId = msgId;
_type = TYPE_CHANNEL; _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(); check();
return valid(); return valid();

View File

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

View File

@ -1116,7 +1116,7 @@ void TransfersDialog::copyLink ()
} }
RetroShareLink link; 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) ; links.push_back(link) ;
} }
} }

View File

@ -1245,7 +1245,7 @@ void PopupChatDialog::updatePeersCustomStateString(const QString& peer_id, const
ui.statusmessagelabel->hide(); ui.statusmessagelabel->hide();
} else { } else {
ui.statusmessagelabel->show(); 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); ui.statusmessagelabel->setText(status_text);
} }
} }

View File

@ -142,7 +142,7 @@ void ConfCertDialog::load()
if (!detail.isOnlyGPGdetail) { 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 // Dont Show a timestamp in RS calculate the day
QDateTime date = QDateTime::fromTime_t(detail.lastConnect); QDateTime date = QDateTime::fromTime_t(detail.lastConnect);
QString stime = date.toString(Qt::LocalDate); QString stime = date.toString(Qt::LocalDate);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -66,8 +66,8 @@ void ProfileWidget::showEvent ( QShowEvent * event )
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),detail)) if (rsPeers->getPeerDetails(rsPeers->getOwnId(),detail))
{ {
ui.name->setText(QString::fromStdString(detail.name)); ui.name->setText(QString::fromUtf8(detail.name.c_str()));
ui.country->setText(QString::fromStdString(detail.location)); ui.country->setText(QString::fromUtf8(detail.location.c_str()));
ui.peerid->setText(QString::fromStdString(detail.id)); ui.peerid->setText(QString::fromStdString(detail.id));