Show tags as label in MessagesDialog.

Fixed german language.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3728 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-10-31 19:37:05 +00:00
parent 618cc702a8
commit 5cc222d251
7 changed files with 159 additions and 38 deletions

View File

@ -1580,6 +1580,54 @@ void MessagesDialog::markAsUnread()
updateMessageSummaryList();
}
void MessagesDialog::clearTagLabels()
{
/* clear all tags */
while (tagLabels.size()) {
delete tagLabels.front();
tagLabels.pop_front();
}
while (ui.taglayout->count()) {
delete ui.taglayout->takeAt(0);
}
ui.tagslabel->setVisible(false);
}
void MessagesDialog::showTagLabels()
{
clearTagLabels();
if (mCurrMsgId.empty()) {
return;
}
MsgTagInfo tagInfo;
rsMsgs->getMessageTag(mCurrMsgId, tagInfo);
if (tagInfo.tagIds.empty() == false) {
ui.tagslabel->setVisible(true);
MsgTagType Tags;
rsMsgs->getMessageTagTypes(Tags);
std::map<uint32_t, std::pair<std::string, uint32_t> >::iterator Tag;
for (std::list<uint32_t>::iterator tagId = tagInfo.tagIds.begin(); tagId != tagInfo.tagIds.end(); tagId++) {
Tag = Tags.types.find(*tagId);
if (Tag != Tags.types.end()) {
QLabel *tagLabel = new QLabel(TagDefs::name(Tag->first, Tag->second.first), this);
tagLabel->setStyleSheet(TagDefs::labelStyleSheet(Tag->second.second));
tagLabels.push_back(tagLabel);
ui.taglayout->addWidget(tagLabel);
ui.taglayout->addSpacing(3);
}
}
ui.taglayout->addStretch();
} else {
ui.tagslabel->setVisible(false);
}
}
void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
{
std::cerr << "MessagesDialog::insertMsgTxtAndFiles()" << std::endl;
@ -1591,12 +1639,23 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
QModelIndex currentIndex = proxyModel->mapToSource(Index);
if (currentIndex.isValid() == false)
{
mCurrCertId.clear();
mCurrMsgId.clear();
/* blank it */
ui.dateText-> setText("");
ui.toText->setText("");
ui.fromText->setText("");
ui.filesText->setText("");
ui.cclabel->setVisible(false);
ui.ccText->setVisible(false);
ui.ccText->clear();
ui.bcclabel->setVisible(false);
ui.bccText->setVisible(false);
ui.bccText->clear();
ui.subjectText->setText("");
ui.msgList->clear();
ui.msgText->clear();
@ -1605,18 +1664,17 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
ui.actionPrintPreview->setDisabled(true);
ui.actionPrint->setDisabled(true);
clearTagLabels();
return;
}
else
{
QStandardItem *item;
item = MessagesModel->item(currentIndex.row(),COLUMN_DATA);
QStandardItem *item = MessagesModel->item(currentIndex.row(),COLUMN_DATA);
if (item == NULL) {
return;
}
cid = item->data(ROLE_SRCID).toString().toStdString();
mid = item->data(ROLE_MSGID).toString().toStdString();
}
int nCount = getSelectedMsgCount (NULL, NULL, NULL);
if (nCount == 1) {
@ -1634,6 +1692,8 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
return;
}
clearTagLabels();
/* Save the Data.... for later */
mCurrCertId = cid;
@ -1775,6 +1835,8 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
ui.filesText->setText(QString::fromStdString(out.str()));
}
showTagLabels();
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Msg Displayed OK!" << std::endl;
}
@ -2295,6 +2357,8 @@ void MessagesDialog::tagTriggered(QAction *pAction)
}
}
showTagLabels();
// LockUpdate -> insertMessages();
}

View File

@ -141,6 +141,9 @@ private:
void processSettings(bool bLoad);
void clearTagLabels();
void showTagLabels();
void setToolbarButtonStyle(Qt::ToolButtonStyle style);
void fillTags();
bool m_bProcessSettings;
@ -151,6 +154,7 @@ private:
std::string mCurrCertId;
std::string mCurrMsgId;
QList<QLabel*> tagLabels;
QString fileName;
QFont mFont;

View File

@ -1707,6 +1707,32 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="tagslabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Tags:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="2" colspan="2">
<layout class="QHBoxLayout" name="taglayout"/>
</item>
</layout>
</item>
</layout>

View File

@ -20,6 +20,8 @@
****************************************************************/
#include <QCoreApplication>
#include <QColor>
#include <retroshare/rsmsgs.h>
#include "TagDefs.h"
@ -47,3 +49,20 @@ const QString TagDefs::name(const unsigned int tagId, const std::string &text)
std::cerr << "TagDefs::name: Unknown tag id requested " << tagId;
return "";
}
const QString TagDefs::labelStyleSheet(const QColor &color)
{
/* calculate best text color */
QRgb textColor;
if (qGray(color.rgb()) < 128) {
/* dark color, use white */
textColor = qRgb(255, 255, 255);
} else {
/* light color, use black */
textColor = qRgb(0, 0, 0);
}
return QString("QLabel{padding-left: 2px; padding-right: 2px; color: #%1; background-color: #%2; border-radius: 3px}")
.arg(textColor & RGB_MASK, 6, 16, QChar('0'))
.arg(color.rgb() & RGB_MASK, 6, 16, QChar('0'));
}

View File

@ -23,10 +23,13 @@
#ifndef _TAGDEFS_H
#define _TAGDEFS_H
class QColor;
class TagDefs
{
public:
static const QString name(const unsigned int tagId, const std::string &text);
static const QString labelStyleSheet(const QColor &color);
};
#endif

View File

@ -5211,7 +5211,7 @@ p, li { white-space: pre-wrap; }
<message>
<location line="+534"/>
<source>Do you really want to exit RetroShare ?</source>
<translation>Wollst Du RetroShare wirklich beenden?</translation>
<translation>Willst Du RetroShare wirklich beenden?</translation>
</message>
<message>
<location line="+2"/>
@ -5801,7 +5801,7 @@ Willst Du die Nachricht speichern ?</translation>
<name>MessagesDialog</name>
<message>
<location filename="../gui/MessagesDialog.ui" line="+573"/>
<location filename="../gui/MessagesDialog.cpp" line="+691"/>
<location filename="../gui/MessagesDialog.cpp" line="+692"/>
<source>New Message</source>
<translation>Neue Nachricht</translation>
</message>
@ -5824,12 +5824,12 @@ Willst Du die Nachricht speichern ?</translation>
<message>
<location line="-5"/>
<location filename="../gui/MessagesDialog.cpp" line="-1"/>
<location line="+914"/>
<location line="+928"/>
<source>From</source>
<translation>Von</translation>
</message>
<message>
<location line="+796"/>
<location line="+799"/>
<source>Size</source>
<translation>Grösse</translation>
</message>
@ -5842,7 +5842,7 @@ p, li { white-space: pre-wrap; }
<translation>&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; }&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Arial&apos;; font-size:8pt; font-weight:400; font-style:normal; text-decoration:none;&quot;&gt;&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-weight:600;&quot;&gt;Empfohlene Dateien&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<location line="-695"/>
<location line="-698"/>
<source>Reply</source>
<translation>Antworten</translation>
</message>
@ -5907,17 +5907,17 @@ p, li { white-space: pre-wrap; }
<translation>Anhänge</translation>
</message>
<message>
<location line="+174"/>
<location line="+177"/>
<location filename="../gui/MessagesDialog.cpp" line="-44"/>
<location line="+922"/>
<location line="+921"/>
<location line="+10"/>
<source>Inbox</source>
<translation>Posteingang</translation>
</message>
<message>
<location line="+9"/>
<location filename="../gui/MessagesDialog.cpp" line="-927"/>
<location line="+940"/>
<location filename="../gui/MessagesDialog.cpp" line="-926"/>
<location line="+939"/>
<location line="+8"/>
<source>Outbox</source>
<translation>Postausgang</translation>
@ -5929,7 +5929,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+9"/>
<location filename="../gui/MessagesDialog.cpp" line="-938"/>
<location filename="../gui/MessagesDialog.cpp" line="-937"/>
<source>Sent</source>
<translation>Gesendet</translation>
</message>
@ -5986,18 +5986,18 @@ p, li { white-space: pre-wrap; }
<translation>Speichern unter...</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.cpp" line="+687"/>
<location filename="../gui/MessagesDialog.cpp" line="+686"/>
<source>Print Document</source>
<translation>Dokument drucken</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.ui" line="-862"/>
<location filename="../gui/MessagesDialog.cpp" line="-1574"/>
<location filename="../gui/MessagesDialog.ui" line="-865"/>
<location filename="../gui/MessagesDialog.cpp" line="-1587"/>
<source>Subject</source>
<translation>Betreff</translation>
</message>
<message>
<location line="+517"/>
<location line="+520"/>
<source>Subject:</source>
<translation>Betreff:</translation>
</message>
@ -6027,7 +6027,7 @@ p, li { white-space: pre-wrap; }
<translation>Prüfsumme</translation>
</message>
<message>
<location line="-945"/>
<location line="-948"/>
<source>Print</source>
<translation>Drucken</translation>
</message>
@ -6052,7 +6052,7 @@ p, li { white-space: pre-wrap; }
<translation>Herunterladen</translation>
</message>
<message>
<location line="+82"/>
<location line="+96"/>
<location line="+47"/>
<source>Compose: </source>
<translation>Verfassen: </translation>
@ -6074,7 +6074,7 @@ p, li { white-space: pre-wrap; }
<translation>Empfohlene Dateien einblenden</translation>
</message>
<message>
<location line="+970"/>
<location line="+969"/>
<source>Save as...</source>
<translation>Speichern unter...</translation>
</message>
@ -6084,13 +6084,13 @@ p, li { white-space: pre-wrap; }
<translation>HTML-Dateien (*.htm *.html);;Alle Dateien (*)</translation>
</message>
<message>
<location line="-1558"/>
<location line="-1571"/>
<location line="+272"/>
<source>Reply to All</source>
<translation>Allen antworten</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.ui" line="+582"/>
<location filename="../gui/MessagesDialog.ui" line="+585"/>
<source>&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; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Arial&apos;; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
@ -6103,7 +6103,7 @@ p, li { white-space: pre-wrap; }
<translation>Posteingang gesamt:</translation>
</message>
<message>
<location line="-271"/>
<location line="-274"/>
<location filename="../gui/MessagesDialog.cpp" line="-324"/>
<source>Content</source>
<translation>Inhalt</translation>
@ -6122,9 +6122,9 @@ p, li { white-space: pre-wrap; }
<translation>Schlagwort</translation>
</message>
<message>
<location line="+174"/>
<location filename="../gui/MessagesDialog.cpp" line="+710"/>
<location line="+964"/>
<location line="+177"/>
<location filename="../gui/MessagesDialog.cpp" line="+724"/>
<location line="+963"/>
<location line="+5"/>
<source>Trash</source>
<translation>Papierkorb</translation>
@ -6140,7 +6140,7 @@ p, li { white-space: pre-wrap; }
<translation>Ordner</translation>
</message>
<message>
<location filename="../gui/MessagesDialog.cpp" line="-1668"/>
<location filename="../gui/MessagesDialog.cpp" line="-1681"/>
<source>Remove All Tags</source>
<translation>Alle Schlagwörter entfernen</translation>
</message>
@ -6165,7 +6165,12 @@ p, li { white-space: pre-wrap; }
<translation>Wiederherstellen</translation>
</message>
<message>
<location line="+222"/>
<location line="+57"/>
<source>Empty trash</source>
<translation>Papierkorb leeren</translation>
</message>
<message>
<location line="+179"/>
<source>Compose:</source>
<translation>Verfassen:</translation>
</message>
@ -6176,23 +6181,23 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<location line="+275"/>
<location line="+955"/>
<location line="+954"/>
<location line="+8"/>
<source>Drafts</source>
<translation>Entwürfe</translation>
</message>
<message>
<location line="-927"/>
<location line="-926"/>
<source>To</source>
<translation>An</translation>
</message>
<message>
<location line="-577"/>
<location line="-591"/>
<source>Edit...</source>
<translation>Editieren...</translation>
</message>
<message>
<location line="+1424"/>
<location line="+1437"/>
<location line="+4"/>
<location line="+4"/>
<location line="+4"/>