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

View File

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

View File

@ -21,7 +21,7 @@
#include <QTextBrowser>
#include "HandleRichText.h"
#include "gui/RetroShareLink.h"
namespace RsHtml {
@ -93,16 +93,28 @@ void embedHtml(QDomDocument& doc, QDomElement& currentElement, EmbedInHtml& embe
QDomNodeList children = currentElement.childNodes();
for(uint index = 0; index < children.length(); index++) {
QDomNode tempNode = children.item(index);
if(tempNode.isElement()) {
QDomNode node = children.item(index);
if(node.isElement()) {
// child is an element, we skip it if it's an <a> tag
QDomElement tempElement = tempNode.toElement();
if(tempElement.tagName().toLower() != "head" && tempElement.tagName().toLower() != "a")
embedHtml(doc, tempElement, embedInfos);
QDomElement element = node.toElement();
if(element.tagName().toLower() == "head") {
// 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
QString tempText = tempNode.toText().data();
QString tempText = node.toText().data();
if(embedInfos.myRE.indexIn(tempText) == -1)
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) {
QDomText textPart = doc.createTextNode(tempText.mid(currentPos, nextPos - currentPos));
currentElement.insertBefore(textPart, tempNode);
currentElement.insertBefore(textPart, node);
index++;
}
// inserted tag
QDomElement insertedTag;
switch(embedInfos.myType) {
case Ahref: insertedTag = doc.createElement("a");
insertedTag.setAttribute("href", embedInfos.myRE.cap(0));
insertedTag.appendChild(doc.createTextNode(embedInfos.myRE.cap(0)));
break;
case Img: insertedTag = doc.createElement("img");
case Ahref:
{
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);
insertedTag.setAttribute("src", embedImg.smileys[embedInfos.myRE.cap(0)]);
}
break;
}
currentElement.insertBefore(insertedTag, tempNode);
currentElement.insertBefore(insertedTag, node);
currentPos = nextPos + embedInfos.myRE.matchedLength();
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()) {
QDomText textPart = doc.createTextNode(tempText.mid(currentPos));
currentElement.insertBefore(textPart, tempNode);
currentElement.insertBefore(textPart, node);
}
else
index--;
currentElement.removeChild(tempNode);
currentElement.removeChild(node);
}
}
}

View File

@ -2723,7 +2723,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+17"/>
<source>Priority:</source>
<translation type="unfinished"></translation>
<translation>Priorität:</translation>
</message>
<message>
<location line="+24"/>
@ -2894,12 +2894,12 @@ Das ist nützlich, wenn Du eine externe Festplatte freigibst und die Datei nicht
<message>
<location line="+11"/>
<source>Auto-check shared directories every </source>
<translation type="unfinished"></translation>
<translation>Automatische Überprüfung der Freigaben alle </translation>
</message>
<message>
<location line="+10"/>
<source> minute(s)</source>
<translation type="unfinished"></translation>
<translation> Minute(n)</translation>
</message>
<message>
<location line="-139"/>
@ -3039,7 +3039,7 @@ Das ist nützlich, wenn Du eine externe Festplatte freigibst und die Datei nicht
<message>
<location filename="../gui/connect/ConnectFriendWizard.cpp" line="+1080"/>
<source>Invite Friends by Email</source>
<translation type="unfinished"></translation>
<translation>Lade Freunde per Email ein</translation>
</message>
<message>
<location line="+2"/>
@ -5327,7 +5327,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="-238"/>
<source>Blogs</source>
<translation type="unfinished">Blogs</translation>
<translation>Blogs</translation>
</message>
<message>
<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>
</message>
<message>
<location filename="../gui/PeersDialog.ui" line="+453"/>
<location filename="../gui/PeersDialog.ui" line="+450"/>
<source>Italic</source>
<translation>Kursiv</translation>
</message>
@ -7664,7 +7664,7 @@ p, li { white-space: pre-wrap; }
<translation>Unterstrichen</translation>
</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;
&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; }
@ -7697,7 +7697,7 @@ p, li { white-space: pre-wrap; }
<translation>Statusnachricht ändern</translation>
</message>
<message>
<location line="+145"/>
<location line="+142"/>
<source>Messages entered here are sent to all collected friends</source>
<translation>Nachrichten, die Du hier eingibst, werden an alle verbundenen Freunde versendet</translation>
</message>
@ -7809,12 +7809,12 @@ p, li { white-space: pre-wrap; }
<translation>Schriftart</translation>
</message>
<message>
<location line="-326"/>
<location line="-323"/>
<source>Group Chat</source>
<translation>Gruppenchat</translation>
</message>
<message>
<location line="+454"/>
<location line="+451"/>
<source>Attach File</source>
<translation>Datei anhängen</translation>
</message>
@ -7890,7 +7890,7 @@ p, li { white-space: pre-wrap; }
<translation>Nachrichtenverlauf</translation>
</message>
<message>
<location line="-775"/>
<location line="-772"/>
<source>Friends</source>
<translation>Freunde</translation>
</message>
@ -9504,22 +9504,22 @@ p, li { white-space: pre-wrap; }
<message>
<location filename="../gui/RemoteDirModel.cpp" line="-472"/>
<source>Anonymous</source>
<translation type="unfinished">Anonym</translation>
<translation>Anonym</translation>
</message>
<message>
<location line="+1"/>
<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>
<location line="+1"/>
<source>Only browsable by friends</source>
<translation type="unfinished">Nur Durchsuchbar von Freunden</translation>
<translation>Nur Durchsuchbar von Freunden</translation>
</message>
<message>
<location line="+9"/>
<source>NEW</source>
<translation type="unfinished">NEU</translation>
<translation>NEU</translation>
</message>
</context>
<context>
@ -11393,7 +11393,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+13"/>
<source>Clean certificate</source>
<translation type="unfinished"></translation>
<translation>Bereinige Zertifikat</translation>
</message>
<message>
<location line="+107"/>