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(); 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) void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
{ {
std::cerr << "MessagesDialog::insertMsgTxtAndFiles()" << std::endl; std::cerr << "MessagesDialog::insertMsgTxtAndFiles()" << std::endl;
@ -1591,12 +1639,23 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
QModelIndex currentIndex = proxyModel->mapToSource(Index); QModelIndex currentIndex = proxyModel->mapToSource(Index);
if (currentIndex.isValid() == false) if (currentIndex.isValid() == false)
{ {
mCurrCertId.clear();
mCurrMsgId.clear();
/* blank it */ /* blank it */
ui.dateText-> setText(""); ui.dateText-> setText("");
ui.toText->setText(""); ui.toText->setText("");
ui.fromText->setText(""); ui.fromText->setText("");
ui.filesText->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.subjectText->setText("");
ui.msgList->clear(); ui.msgList->clear();
ui.msgText->clear(); ui.msgText->clear();
@ -1605,18 +1664,17 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
ui.actionPrintPreview->setDisabled(true); ui.actionPrintPreview->setDisabled(true);
ui.actionPrint->setDisabled(true); ui.actionPrint->setDisabled(true);
clearTagLabels();
return; return;
} }
else
{ QStandardItem *item = MessagesModel->item(currentIndex.row(),COLUMN_DATA);
QStandardItem *item; if (item == NULL) {
item = MessagesModel->item(currentIndex.row(),COLUMN_DATA); return;
if (item == NULL) {
return;
}
cid = item->data(ROLE_SRCID).toString().toStdString();
mid = item->data(ROLE_MSGID).toString().toStdString();
} }
cid = item->data(ROLE_SRCID).toString().toStdString();
mid = item->data(ROLE_MSGID).toString().toStdString();
int nCount = getSelectedMsgCount (NULL, NULL, NULL); int nCount = getSelectedMsgCount (NULL, NULL, NULL);
if (nCount == 1) { if (nCount == 1) {
@ -1634,6 +1692,8 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
return; return;
} }
clearTagLabels();
/* Save the Data.... for later */ /* Save the Data.... for later */
mCurrCertId = cid; mCurrCertId = cid;
@ -1775,6 +1835,8 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
ui.filesText->setText(QString::fromStdString(out.str())); ui.filesText->setText(QString::fromStdString(out.str()));
} }
showTagLabels();
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Msg Displayed OK!" << std::endl; std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Msg Displayed OK!" << std::endl;
} }
@ -2295,6 +2357,8 @@ void MessagesDialog::tagTriggered(QAction *pAction)
} }
} }
showTagLabels();
// LockUpdate -> insertMessages(); // LockUpdate -> insertMessages();
} }

View file

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

View file

@ -1707,6 +1707,32 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </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> </layout>
</item> </item>
</layout> </layout>

View file

@ -20,6 +20,8 @@
****************************************************************/ ****************************************************************/
#include <QCoreApplication> #include <QCoreApplication>
#include <QColor>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include "TagDefs.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; std::cerr << "TagDefs::name: Unknown tag id requested " << tagId;
return ""; 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 #ifndef _TAGDEFS_H
#define _TAGDEFS_H #define _TAGDEFS_H
class QColor;
class TagDefs class TagDefs
{ {
public: public:
static const QString name(const unsigned int tagId, const std::string &text); static const QString name(const unsigned int tagId, const std::string &text);
static const QString labelStyleSheet(const QColor &color);
}; };
#endif #endif

View file

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