tinyxml2::XMLError Form::LoadFromMemory(cchar* buffer) { tinyxml2::XMLDocument document; tinyxml2::XMLError result = document.Parse(buffer); if (result != 0) return result; Button::ReadProperties(document.RootElement()); SetImage(XAGUI::GetRenderer()->GetTexture(document.RootElement()->Attribute("skin"))); ParseChildren(document.RootElement()); return result; }
bool MythUIStateType::ParseElement(QDomElement &element) { if (element.tagName() == "showempty") m_ShowEmpty = parseBool(element); else if (element.tagName() == "state") { QString name = element.attribute("name", "").lower(); QString type = element.attribute("type", "").lower(); MythUIType *uitype = ParseChildren(element, this); if (!type.isEmpty()) { StateType stype = None; if (type == "off") stype = Off; else if (type == "half") stype = Half; else if (type == "full") stype = Full; if (uitype && m_ObjectsByState.contains((int)stype)) { delete m_ObjectsByState[(int)stype]; m_ObjectsByState.erase((int)stype); } AddObject(stype, uitype); } else if (!name.isEmpty()) { if (uitype && m_ObjectsByName.contains(name)) { delete m_ObjectsByName[name]; m_ObjectsByName.erase(name); } AddObject(name, uitype); } } else return MythUIType::ParseElement(element); return true; }
bool XMLParseBase::doLoad(const QString &windowname, MythUIType *parent, const QString &filename, bool onlywindows, bool showWarnings) { QDomDocument doc; QFile f(filename); if (!f.open(QIODevice::ReadOnly)) return false; QString errorMsg; int errorLine = 0; int errorColumn = 0; if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn)) { VERBOSE(VB_IMPORTANT, LOC_ERR + QString("Location: '%1' @ %2 column: %3" "\n\t\t\tError: %4") .arg(qPrintable(filename)).arg(errorLine).arg(errorColumn) .arg(qPrintable(errorMsg))); f.close(); return false; } f.close(); QDomElement docElem = doc.documentElement(); QDomNode n = docElem.firstChild(); while (!n.isNull()) { QDomElement e = n.toElement(); if (!e.isNull()) { if (e.tagName() == "include") { QString include = getFirstText(e); if (!include.isEmpty()) LoadBaseTheme(include); } if (onlywindows && e.tagName() == "window") { QString name = e.attribute("name", ""); if (name.isEmpty()) { VERBOSE_XML(VB_IMPORTANT, filename, e, LOC_ERR + "Window needs a name"); return false; } if (name == windowname) { ParseChildren(filename, e, parent, showWarnings); return true; } } if (!onlywindows) { QString type = e.tagName(); if (type == "font" || type == "fontdef") { bool global = (GetGlobalObjectStore() == parent); MythFontProperties *font = MythFontProperties::ParseFromXml( filename, e, parent, global, showWarnings); if (!global && font) { QString name = e.attribute("name"); parent->AddFont(name, font); } delete font; } else if (type == "imagetype" || type == "textarea" || type == "group" || type == "textedit" || type == "button" || type == "buttonlist" || type == "buttonlist2" || type == "buttontree" || type == "spinbox" || type == "checkbox" || type == "statetype" || type == "window" || type == "clock" || type == "progressbar" || type == "webbrowser" || type == "guidegrid" || type == "shape" || type == "editbar" || type == "video") { ParseUIType(filename, e, type, parent, NULL, showWarnings); } else { VERBOSE_XML(VB_IMPORTANT, filename, e, LOC_ERR + "Unknown widget type"); } } } n = n.nextSibling(); } if (onlywindows) return false; return true; }