Added title to the RetroShare file links shown as toolhelp "hash (size)".

Fixed german language.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4181 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-05-01 22:26:41 +00:00
parent 34fc615d2c
commit 60138e0137
6 changed files with 109 additions and 62 deletions

View File

@ -528,7 +528,7 @@ border: 1px solid #CCCCCC;}
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="images.qrc">:/images/user/friends24.png</pixmap> <pixmap>:/images/user/friends24.png</pixmap>
</property> </property>
</widget> </widget>
</item> </item>
@ -578,7 +578,7 @@ p, li { white-space: pre-wrap; }
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset> <normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -632,7 +632,7 @@ p, li { white-space: pre-wrap; }
}</string> }</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/looknfeel.png</normaloff>:/images/looknfeel.png</iconset> <normaloff>:/images/looknfeel.png</normaloff>:/images/looknfeel.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -944,9 +944,6 @@ p, li { white-space: pre-wrap; }
<string notr="true">QTextEdit#msgText{border: 1px solid #CCCCCC; <string notr="true">QTextEdit#msgText{border: 1px solid #CCCCCC;
background: white;}</string> background: white;}</string>
</property> </property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly"> <property name="readOnly">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -1063,7 +1060,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/emoticons/kopete/kopete020.png</normaloff>:/images/emoticons/kopete/kopete020.png</iconset> <normaloff>:/images/emoticons/kopete/kopete020.png</normaloff>:/images/emoticons/kopete/kopete020.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -1107,7 +1104,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/edit-bold.png</normaloff>:/images/edit-bold.png</iconset> <normaloff>:/images/edit-bold.png</normaloff>:/images/edit-bold.png</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
@ -1148,7 +1145,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/edit-underline.png</normaloff>:/images/edit-underline.png</iconset> <normaloff>:/images/edit-underline.png</normaloff>:/images/edit-underline.png</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
@ -1189,7 +1186,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/edit-italic.png</normaloff>:/images/edit-italic.png</iconset> <normaloff>:/images/edit-italic.png</normaloff>:/images/edit-italic.png</iconset>
</property> </property>
<property name="checkable"> <property name="checkable">
@ -1230,7 +1227,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/fonts.png</normaloff>:/images/fonts.png</iconset> <normaloff>:/images/fonts.png</normaloff>:/images/fonts.png</iconset>
</property> </property>
<property name="autoRaise"> <property name="autoRaise">
@ -1314,7 +1311,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/configure.png</normaloff>:/images/configure.png</iconset> <normaloff>:/images/configure.png</normaloff>:/images/configure.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -1358,7 +1355,7 @@ border: 1px solid #CCCCCC;}</string>
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset> <normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -1416,7 +1413,7 @@ border: 1px solid #CCCCCC;}</string>
</layout> </layout>
<action name="actionClear_Chat_History"> <action name="actionClear_Chat_History">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/edit-clear-history.png</normaloff>:/images/edit-clear-history.png</iconset> <normaloff>:/images/edit-clear-history.png</normaloff>:/images/edit-clear-history.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1425,7 +1422,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionAdd_Friend"> <action name="actionAdd_Friend">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/user/add_user16.png</normaloff>:/images/user/add_user16.png</iconset> <normaloff>:/images/user/add_user16.png</normaloff>:/images/user/add_user16.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1434,7 +1431,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionCreate_new_Profile"> <action name="actionCreate_new_Profile">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/contact_new.png</normaloff>:/images/contact_new.png</iconset> <normaloff>:/images/contact_new.png</normaloff>:/images/contact_new.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1443,7 +1440,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionCreate_New_Forum"> <action name="actionCreate_New_Forum">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/new_forum16.png</normaloff>:/images/new_forum16.png</iconset> <normaloff>:/images/new_forum16.png</normaloff>:/images/new_forum16.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1458,7 +1455,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionCreate_New_Channel"> <action name="actionCreate_New_Channel">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/add_channel24.png</normaloff>:/images/add_channel24.png</iconset> <normaloff>:/images/add_channel24.png</normaloff>:/images/add_channel24.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1473,7 +1470,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionSet_your_Avatar"> <action name="actionSet_your_Avatar">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset> <normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1485,7 +1482,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionSet_your_Personal_Message"> <action name="actionSet_your_Personal_Message">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/message-news.png</normaloff>:/images/message-news.png</iconset> <normaloff>:/images/message-news.png</normaloff>:/images/message-news.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1548,7 +1545,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionAdd_Group"> <action name="actionAdd_Group">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/user/add_group22.png</normaloff>:/images/user/add_group22.png</iconset> <normaloff>:/images/user/add_group22.png</normaloff>:/images/user/add_group22.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1560,7 +1557,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionSort_Peers_Descending_Order"> <action name="actionSort_Peers_Descending_Order">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/sort_decrease.png</normaloff>:/images/sort_decrease.png</iconset> <normaloff>:/images/sort_decrease.png</normaloff>:/images/sort_decrease.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1572,7 +1569,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionSort_Peers_Ascending_Order"> <action name="actionSort_Peers_Ascending_Order">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/sort_incr.png</normaloff>:/images/sort_incr.png</iconset> <normaloff>:/images/sort_incr.png</normaloff>:/images/sort_incr.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1584,7 +1581,7 @@ border: 1px solid #CCCCCC;}</string>
</action> </action>
<action name="actionDelete_Chat_History"> <action name="actionDelete_Chat_History">
<property name="icon"> <property name="icon">
<iconset resource="images.qrc"> <iconset>
<normaloff>:/images/edit-clear-history.png</normaloff>:/images/edit-clear-history.png</iconset> <normaloff>:/images/edit-clear-history.png</normaloff>:/images/edit-clear-history.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -1603,8 +1600,6 @@ border: 1px solid #CCCCCC;}</string>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources/>
<include location="images.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -302,6 +302,26 @@ void RetroShareLink::check()
} }
} }
QString RetroShareLink::title() const
{
if (!valid()) {
return "";
}
switch (_type) {
case TYPE_UNKNOWN:
break;
case TYPE_FILE:
return QString("%1 (%2)").arg(hash()).arg(misc::friendlyUnit(size()));
case TYPE_PERSON:
case TYPE_FORUM:
case TYPE_CHANNEL:
break;
}
return "";
}
QString RetroShareLink::toString(bool encoded /*= true*/) const QString RetroShareLink::toString(bool encoded /*= true*/) const
{ {
switch (_type) { switch (_type) {
@ -386,7 +406,15 @@ QString RetroShareLink::niceName() const
QString RetroShareLink::toHtml() const QString RetroShareLink::toHtml() const
{ {
return QString("<a href=\"") + toString(true) + "\">" + niceName() + "</a>" ; QString html = "<a href=\"" + toString(true);
QString linkTitle = title();
if (!linkTitle.isEmpty()) {
html += " title=\"" + linkTitle + "\"";
}
html += "\">" + niceName() + "</a>" ;
return html;
} }
QString RetroShareLink::toHtmlFull() const QString RetroShareLink::toHtmlFull() const

View File

@ -65,6 +65,7 @@ class RetroShareLink
const QString& hash() const { return _hash ; } const QString& hash() const { return _hash ; }
const QString& id() const { return _hash ; } const QString& id() const { return _hash ; }
const QString& msgId() const { return _msgId ; } const QString& msgId() const { return _msgId ; }
QString title() const;
// get nice name for anchor // get nice name for anchor
QString niceName() const; QString niceName() const;

View File

@ -21,7 +21,7 @@
#include <QTextBrowser> #include <QTextBrowser>
#include "HandleRichText.h" #include "HandleRichText.h"
#include "gui/RetroShareLink.h"
namespace RsHtml { namespace RsHtml {
@ -93,16 +93,28 @@ void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embe
QDomNodeList children = currentElement.childNodes(); QDomNodeList children = currentElement.childNodes();
for(uint index = 0; index < children.length(); index++) { for(uint index = 0; index < children.length(); index++) {
QDomNode tempNode = children.item(index); QDomNode node = children.item(index);
if(tempNode.isElement()) { if(node.isElement()) {
// child is an element, we skip it if it's an <a> tag // child is an element, we skip it if it's an <a> tag
QDomElement tempElement = tempNode.toElement(); QDomElement element = node.toElement();
if(tempElement.tagName().toLower() != "head" && tempElement.tagName().toLower() != "a") if(element.tagName().toLower() == "head") {
embedHtml(doc, tempElement, embedInfos); // skip it
} else if (element.tagName().toLower() == "a") {
// skip it, but add title if not available
if (element.attribute("title").isEmpty()) {
RetroShareLink link(element.attribute("href"));
QString title = link.title();
if (!title.isEmpty()) {
element.setAttribute("title", title);
}
}
} else {
embedHtml(doc, element, embedInfos);
}
} }
else if(tempNode.isText()) { else if(node.isText()) {
// child is a text, we parse it // child is a text, we parse it
QString tempText = tempNode.toText().data(); QString tempText = node.toText().data();
if(embedInfos.myRE.indexIn(tempText) == -1) if(embedInfos.myRE.indexIn(tempText) == -1)
continue; continue;
@ -113,40 +125,51 @@ void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embe
// if nextPos == 0 it means the text begins by a link // if nextPos == 0 it means the text begins by a link
if(nextPos > 0) { if(nextPos > 0) {
QDomText textPart = doc.createTextNode(tempText.mid(currentPos, nextPos - currentPos)); QDomText textPart = doc.createTextNode(tempText.mid(currentPos, nextPos - currentPos));
currentElement.insertBefore(textPart, tempNode); currentElement.insertBefore(textPart, node);
index++; index++;
} }
// inserted tag // inserted tag
QDomElement insertedTag; QDomElement insertedTag;
switch(embedInfos.myType) { switch(embedInfos.myType) {
case Ahref: insertedTag = doc.createElement("a"); case Ahref:
insertedTag.setAttribute("href", embedInfos.myRE.cap(0));
insertedTag.appendChild(doc.createTextNode(embedInfos.myRE.cap(0)));
break;
case Img: insertedTag = doc.createElement("img");
{ {
insertedTag = doc.createElement("a");
insertedTag.setAttribute("href", embedInfos.myRE.cap(0));
RetroShareLink link(embedInfos.myRE.cap(0));
QString title = link.title();
if (!title.isEmpty()) {
insertedTag.setAttribute("title", title);
}
insertedTag.appendChild(doc.createTextNode(embedInfos.myRE.cap(0)));
}
break;
case Img:
{
insertedTag = doc.createElement("img");
const EmbedInHtmlImg& embedImg = static_cast<const EmbedInHtmlImg&>(embedInfos); const EmbedInHtmlImg& embedImg = static_cast<const EmbedInHtmlImg&>(embedInfos);
insertedTag.setAttribute("src", embedImg.smileys[embedInfos.myRE.cap(0)]); insertedTag.setAttribute("src", embedImg.smileys[embedInfos.myRE.cap(0)]);
} }
break; break;
} }
currentElement.insertBefore(insertedTag, tempNode); currentElement.insertBefore(insertedTag, node);
currentPos = nextPos + embedInfos.myRE.matchedLength(); currentPos = nextPos + embedInfos.myRE.matchedLength();
index++; index++;
} }
// text after the last link, only if there's one, don't touch the index // text after the last link, only if there's one, don't touch the index
// otherwise decrement the index because we're going to remove tempNode // otherwise decrement the index because we're going to remove node
if(currentPos < tempText.length()) { if(currentPos < tempText.length()) {
QDomText textPart = doc.createTextNode(tempText.mid(currentPos)); QDomText textPart = doc.createTextNode(tempText.mid(currentPos));
currentElement.insertBefore(textPart, tempNode); currentElement.insertBefore(textPart, node);
} }
else else
index--; index--;
currentElement.removeChild(tempNode); currentElement.removeChild(node);
} }
} }
} }

View File

@ -2723,7 +2723,7 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location line="+17"/> <location line="+17"/>
<source>Priority:</source> <source>Priority:</source>
<translation type="unfinished"></translation> <translation>Priorität:</translation>
</message> </message>
<message> <message>
<location line="+24"/> <location line="+24"/>
@ -2894,12 +2894,12 @@ Das ist nützlich, wenn Du eine externe Festplatte freigibst und die Datei nicht
<message> <message>
<location line="+11"/> <location line="+11"/>
<source>Auto-check shared directories every </source> <source>Auto-check shared directories every </source>
<translation type="unfinished"></translation> <translation>Automatische Überprüfung der Freigaben alle </translation>
</message> </message>
<message> <message>
<location line="+10"/> <location line="+10"/>
<source> minute(s)</source> <source> minute(s)</source>
<translation type="unfinished"></translation> <translation> Minute(n)</translation>
</message> </message>
<message> <message>
<location line="-139"/> <location line="-139"/>
@ -3039,7 +3039,7 @@ Das ist nützlich, wenn Du eine externe Festplatte freigibst und die Datei nicht
<message> <message>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="+1080"/> <location filename="../gui/connect/ConnectFriendWizard.cpp" line="+1080"/>
<source>Invite Friends by Email</source> <source>Invite Friends by Email</source>
<translation type="unfinished"></translation> <translation>Lade Freunde per Email ein</translation>
</message> </message>
<message> <message>
<location line="+2"/> <location line="+2"/>
@ -5327,7 +5327,7 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location line="-238"/> <location line="-238"/>
<source>Blogs</source> <source>Blogs</source>
<translation type="unfinished">Blogs</translation> <translation>Blogs</translation>
</message> </message>
<message> <message>
<location line="+255"/> <location line="+255"/>
@ -7654,7 +7654,7 @@ p, li { white-space: pre-wrap; }
<translation>Ordner können nicht für Drag&apos;n&apos;Drop genutzt werden. Nur Dateien werden akzeptiert.</translation> <translation>Ordner können nicht für Drag&apos;n&apos;Drop genutzt werden. Nur Dateien werden akzeptiert.</translation>
</message> </message>
<message> <message>
<location filename="../gui/PeersDialog.ui" line="+453"/> <location filename="../gui/PeersDialog.ui" line="+450"/>
<source>Italic</source> <source>Italic</source>
<translation>Kursiv</translation> <translation>Kursiv</translation>
</message> </message>
@ -7664,7 +7664,7 @@ p, li { white-space: pre-wrap; }
<translation>Unterstrichen</translation> <translation>Unterstrichen</translation>
</message> </message>
<message> <message>
<location line="-601"/> <location line="-598"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
@ -7697,7 +7697,7 @@ p, li { white-space: pre-wrap; }
<translation>Statusnachricht ändern</translation> <translation>Statusnachricht ändern</translation>
</message> </message>
<message> <message>
<location line="+145"/> <location line="+142"/>
<source>Messages entered here are sent to all collected friends</source> <source>Messages entered here are sent to all collected friends</source>
<translation>Nachrichten, die Du hier eingibst, werden an alle verbundenen Freunde versendet</translation> <translation>Nachrichten, die Du hier eingibst, werden an alle verbundenen Freunde versendet</translation>
</message> </message>
@ -7809,12 +7809,12 @@ p, li { white-space: pre-wrap; }
<translation>Schriftart</translation> <translation>Schriftart</translation>
</message> </message>
<message> <message>
<location line="-326"/> <location line="-323"/>
<source>Group Chat</source> <source>Group Chat</source>
<translation>Gruppenchat</translation> <translation>Gruppenchat</translation>
</message> </message>
<message> <message>
<location line="+454"/> <location line="+451"/>
<source>Attach File</source> <source>Attach File</source>
<translation>Datei anhängen</translation> <translation>Datei anhängen</translation>
</message> </message>
@ -7890,7 +7890,7 @@ p, li { white-space: pre-wrap; }
<translation>Nachrichtenverlauf</translation> <translation>Nachrichtenverlauf</translation>
</message> </message>
<message> <message>
<location line="-775"/> <location line="-772"/>
<source>Friends</source> <source>Friends</source>
<translation>Freunde</translation> <translation>Freunde</translation>
</message> </message>
@ -9504,22 +9504,22 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location filename="../gui/RemoteDirModel.cpp" line="-472"/> <location filename="../gui/RemoteDirModel.cpp" line="-472"/>
<source>Anonymous</source> <source>Anonymous</source>
<translation type="unfinished">Anonym</translation> <translation>Anonym</translation>
</message> </message>
<message> <message>
<location line="+1"/> <location line="+1"/>
<source>Anonymous and browsable by friends</source> <source>Anonymous and browsable by friends</source>
<translation type="unfinished">Anonym und Durchsuchbar von Freunden</translation> <translation>Anonym und Durchsuchbar von Freunden</translation>
</message> </message>
<message> <message>
<location line="+1"/> <location line="+1"/>
<source>Only browsable by friends</source> <source>Only browsable by friends</source>
<translation type="unfinished">Nur Durchsuchbar von Freunden</translation> <translation>Nur Durchsuchbar von Freunden</translation>
</message> </message>
<message> <message>
<location line="+9"/> <location line="+9"/>
<source>NEW</source> <source>NEW</source>
<translation type="unfinished">NEU</translation> <translation>NEU</translation>
</message> </message>
</context> </context>
<context> <context>
@ -11393,7 +11393,7 @@ p, li { white-space: pre-wrap; }
<message> <message>
<location line="+13"/> <location line="+13"/>
<source>Clean certificate</source> <source>Clean certificate</source>
<translation type="unfinished"></translation> <translation>Bereinige Zertifikat</translation>
</message> </message>
<message> <message>
<location line="+107"/> <location line="+107"/>