bool Themes::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: makeStyle((const QString&)static_QUType_QString.get(_o+1)); break; case 1: about(); break; case 2: aboutQt(); break; default: return QMainWindow::qt_invoke( _id, _o ); } return TRUE; }
void ViewParser::tag_start(const QString &tag, const list<QString> &attrs) { // the tag that will be actually written out QString oTag = tag; if (m_bInHead) return; QString style; if (tag == "img"){ QString src; for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){ QString name = (*it).lower(); ++it; QString value = *it; if (name == "src"){ src = value; break; } } if (src.left(10) == "icon:smile"){ bool bOK; unsigned nSmile = src.mid(10).toUInt(&bOK, 16); if (bOK){ const smile *s = smiles(nSmile); if (s == NULL) return; if (*s->exp == 0){ res += quoteString(s->paste); return; } } } }else if (tag == "a"){ m_bInLink = true; }else if (tag == "html"){ // we display as a part of a larger document return; }else if (tag == "head"){ m_bInHead = 1; return; }else if (tag == "body"){ // we display as a part of a larger document oTag = "span"; }else if (tag == "p"){ bool bRTL = false; m_bParaEnd = false; for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){ QString name = (*it).lower(); ++it; QString value = *it; if ((name == "dir") && (value.lower() == "rtl")) bRTL = true; } if (m_bPara){ if (bRTL == m_bRTL){ res += "<br/>"; }else{ if (m_bParaStart) res += "</p>"; res += "<p dir=\""; res += bRTL ? "rtl" : "ltr"; res += "\">"; m_bParaStart = true; } }else{ RTL = bRTL; m_bRTL = bRTL; m_bPara = true; } return; } if (m_bParaEnd){ res += "<br/>"; m_bParaEnd = false; } QString tagText; tagText += "<"; tagText += oTag; for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){ QString name = (*it).lower(); ++it; QString value = *it; // Handling for attributes of specific tags. if (tag == "body"){ if (name == "bgcolor"){ style += "background-color:" + value + ";"; continue; } }else if (tag == "font"){ if (name == "color" && m_bIgnoreColors) continue; } // Handle for generic attributes. if (name == "style"){ style += value; continue; } tagText += " "; tagText += name; if (!value.isEmpty()){ tagText += "=\""; tagText += value; tagText += "\""; } } // Quite crude but working CSS to remove color styling. // It won't filter out colors as part of 'background', but life's tough. // (If it's any comfort, Qt probably won't display it either.) if (!style.isEmpty()){ if (m_bIgnoreColors){ list<QString> opt = parseStyle(style); list<QString> new_opt; for (list<QString>::iterator it = opt.begin(); it != opt.end(); ++it){ QString name = *it; it++; if (it == opt.end()) break; QString value = *it; if ((name == "color") || (name == "background-color") || (name == "font-size") || (name == "font-style") || (name == "font-weight") || (name == "font-family")) continue; new_opt.push_back(name); new_opt.push_back(value); } style = makeStyle(new_opt); } if (!style.isEmpty()) tagText += " style=\"" + style + "\""; } tagText += ">"; res += tagText; }
void ViewParser::tag_start(const QString &tag, const list<QString> &attrs) { // the tag that will be actually written out QString oTag = tag; if (m_bInHead) return; QString style; if (tag == "img"){ QString src; for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){ QString name = (*it).lower(); ++it; QString value = *it; if (name == "src"){ src = value; break; } } if (src.left(10) == "icon:smile"){ bool bOK; unsigned nSmile = src.mid(10).toUInt(&bOK, 16); if (bOK && (nSmile < 26)){ QString s = def_smiles[nSmile]; res += getIcons()->parseSmiles(s); return; } } }else if (tag == "a"){ m_bInLink = true; }else if (tag == "p"){ m_bInParagraph = true; m_paragraphDir = DirAuto; }else if (tag == "html"){ // we display as a part of a larger document return; }else if (tag == "head"){ m_bInHead = 1; return; }else if (tag == "body"){ // we display as a part of a larger document oTag = "span"; } QString tagText; tagText += "<"; tagText += oTag; if (tag == "p") { m_paraDirInsertionPos = res.length() + tagText.length(); } for (list<QString>::const_iterator it = attrs.begin(); it != attrs.end(); ++it){ QString name = (*it).lower(); ++it; QString value = *it; // Handling for attributes of specific tags. if (tag == "body"){ if (name == "bgcolor"){ style += "background-color:" + value + ";"; continue; } }else if (tag == "p"){ if (name == "dir"){ QString dir = value.lower(); if (dir == "ltr") m_paragraphDir = DirLTR; else if (dir == "rtl") m_paragraphDir = DirRTL; else m_paragraphDir = DirUnknown; } }else if (tag == "font"){ if (name == "color" && m_bIgnoreColors) continue; } // Handle for generic attributes. if (name == "style"){ style += value; continue; } tagText += " "; tagText += name; if (!value.isEmpty()){ tagText += "=\""; tagText += value; tagText += "\""; } } // Quite crude but working CSS to remove color styling. // It won't filter out colors as part of 'background', but life's tough. // (If it's any comfort, Qt probably won't display it either.) if (!style.isEmpty()){ if (m_bIgnoreColors){ list<QString> opt = parseStyle(style); list<QString> new_opt; for (list<QString>::iterator it = opt.begin(); it != opt.end(); ++it){ QString name = *it; it++; if (it == opt.end()) break; QString value = *it; if ((name == "color") || (name == "background-color") || (name == "font-size") || (name == "font-style") || (name == "font-weight") || (name == "font-family")) continue; new_opt.push_back(name); new_opt.push_back(value); } style = makeStyle(new_opt); } if (!style.isEmpty()) tagText += " style=\"" + style + "\""; } tagText += ">"; res += tagText; }