mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
cleaned up ChatStyle.cpp from obvious comments
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7703 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
99274d1a05
commit
7b8cdd685d
@ -291,20 +291,20 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
|||||||
if ((str.startsWith("<body>")) && (str.endsWith( "</body>"))) {
|
if ((str.startsWith("<body>")) && (str.endsWith( "</body>"))) {
|
||||||
str.remove(0, 6);
|
str.remove(0, 6);
|
||||||
str.chop( 7);
|
str.chop( 7);
|
||||||
}//if ((str.startsWith("<body>")) && (str.endsWith( "</body>")))
|
}
|
||||||
//remove first <span> if it is without attribute
|
//remove first <span> if it is without attribute
|
||||||
if ((str.startsWith("<span>")) && (str.endsWith( "</span>"))) {
|
if ((str.startsWith("<span>")) && (str.endsWith( "</span>"))) {
|
||||||
str.remove(0, 6);
|
str.remove(0, 6);
|
||||||
str.chop( 7);
|
str.chop( 7);
|
||||||
}//if ((str.startsWith("<span>")) && (str.endsWith( "</span>")))
|
}
|
||||||
messageBody += str;
|
messageBody += str;
|
||||||
} else {
|
} else {
|
||||||
QDomText text = it.firstChild().toText();
|
QDomText text = it.firstChild().toText();
|
||||||
styleOptimized = text.data();
|
styleOptimized = text.data();
|
||||||
}//if (it.nodeName().toLower() != "style")
|
}
|
||||||
}//foreach (QDomElement it, body.childNodes())
|
}
|
||||||
}//if (!body.isNull()){
|
}
|
||||||
}//if (docOK = doc.setContent(text, &errorMsg, &errorLine, &errorColumn))
|
}
|
||||||
if (messageBody.isEmpty()) messageBody = message;
|
if (messageBody.isEmpty()) messageBody = message;
|
||||||
|
|
||||||
QString style = m_style[type];
|
QString style = m_style[type];
|
||||||
@ -329,30 +329,30 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
|||||||
case FORMATMSG_SYSTEM:
|
case FORMATMSG_SYSTEM:
|
||||||
style = getStyle(m_styleDir, m_styleVariant, GETSTYLE_SYSTEM);
|
style = getStyle(m_styleDir, m_styleVariant, GETSTYLE_SYSTEM);
|
||||||
break;
|
break;
|
||||||
}//switch (type)
|
}
|
||||||
|
|
||||||
if (style.isEmpty()) {
|
if (style.isEmpty()) {
|
||||||
// default style
|
// default style
|
||||||
style = "<table width='100%'><tr><td><b>%name%</b></td><td width='130' align='right'>%time%</td></tr></table><table width='100%'><tr><td>%message%</td></tr></table>";
|
style = "<table width='100%'><tr><td><b>%name%</b></td><td width='130' align='right'>%time%</td></tr></table><table width='100%'><tr><td>%message%</td></tr></table>";
|
||||||
}//if (style.isEmpty())
|
}
|
||||||
|
|
||||||
style = style.replace("\r","").replace("\n","").replace("\t","") ;
|
style = style.replace("\r","").replace("\n","").replace("\t","") ;
|
||||||
m_style[type] = style;
|
m_style[type] = style;
|
||||||
}//if (style.isEmpty())
|
}
|
||||||
|
|
||||||
#ifdef COLORED_NICKNAMES
|
#ifdef COLORED_NICKNAMES
|
||||||
QColor color;
|
QColor color;
|
||||||
if (flag & CHAT_FORMATMSG_SYSTEM) {
|
if (flag & CHAT_FORMATMSG_SYSTEM) {
|
||||||
color = Qt::darkBlue;
|
color = Qt::darkBlue;
|
||||||
} else {//if ( flag & CHAT_FORMATMSG_SYSTEM
|
} else {
|
||||||
// Calculate color from the name
|
// Calculate color from the name
|
||||||
uint hash = 0;
|
uint hash = 0;
|
||||||
for (int i = 0; i < name.length(); ++i) {
|
for (int i = 0; i < name.length(); ++i) {
|
||||||
hash = (((hash << 1) + (hash >> 14)) ^ ((int) name[i].toLatin1())) & 0x3fff;
|
hash = (((hash << 1) + (hash >> 14)) ^ ((int) name[i].toLatin1())) & 0x3fff;
|
||||||
}//for (int i = 0; i < name.length(); ++i)
|
}
|
||||||
|
|
||||||
color.setHsv(hash, 255, 150);
|
color.setHsv(hash, 255, 150);
|
||||||
}//if (flag & CHAT_FORMATMSG_SYSTEM)
|
}
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(flag);
|
Q_UNUSED(flag);
|
||||||
#endif
|
#endif
|
||||||
@ -368,8 +368,8 @@ QString ChatStyle::formatMessage(enumFormatMessage type, const QString &name, co
|
|||||||
int pos = formatMsg.indexOf("</style>") ;
|
int pos = formatMsg.indexOf("</style>") ;
|
||||||
if ( pos >= 0 ) {
|
if ( pos >= 0 ) {
|
||||||
formatMsg.insert(pos, styleOptimized) ;
|
formatMsg.insert(pos, styleOptimized) ;
|
||||||
}//if (pos >= 0)
|
}
|
||||||
}//if (!styleOptimized.isEmpty())
|
}
|
||||||
return formatMsg;
|
return formatMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user