51 if (lang.length() != 2)
return;
120 void NamesList::fromXml(
const QDomElement &xml_element,
const QHash<QString, QString> &xml_options) {
121 QHash<QString, QString> xml_opt =
getXmlOptions(xml_options);
123 for (QDomNode node = xml_element.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
124 QDomElement names = node.toElement();
125 if (names.isNull() || names.tagName() != xml_opt[
"ParentTagName"])
continue;
127 for (QDomNode n = names.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
128 QDomElement
name = n.toElement();
129 if (
name.isNull() ||
name.tagName() != xml_opt[
"TagName"])
continue;
143 QDomElement
NamesList::toXml(QDomDocument &xml_document,
const QHash<QString, QString> &xml_options)
const {
144 QHash<QString, QString> xml_opt =
getXmlOptions(xml_options);
145 QDomElement names_elmt = xml_document.createElement(xml_opt[
"ParentTagName"]);
146 QHashIterator<QString, QString> names_iterator(
hash_names);
147 while (names_iterator.hasNext()) {
148 names_iterator.next();
149 QDomElement name_elmt = xml_document.createElement(xml_opt[
"TagName"]);
150 name_elmt.setAttribute(xml_opt[
"LanguageAttribute"], names_iterator.key());
151 name_elmt.appendChild(xml_document.createTextNode(names_iterator.value()));
152 names_elmt.appendChild(name_elmt);
165 QHash<QString, QString> new_xml_options = xml_options;
166 if (!xml_options.contains(
"ParentTagName")) {
167 new_xml_options.insert(
"ParentTagName",
"names");
169 if (!xml_options.contains(
"TagName")) {
170 new_xml_options.insert(
"TagName",
"name");
172 if (!xml_options.contains(
"LanguageAttribute")) {
173 new_xml_options.insert(
"LanguageAttribute",
"lang");
175 return new_xml_options;
207 QString returned_name;
212 }
else if (!fallback_name.isEmpty()) {
213 returned_name = fallback_name;
217 return(returned_name);
QString & operator[](const QString &)
void fromXml(const QDomElement &, const QHash< QString, QString > &=QHash< QString, QString >())
QHash< QString, QString > hash_names
QString name(const QString &=QString()) const
QDomElement toXml(QDomDocument &, const QHash< QString, QString > &=QHash< QString, QString >()) const
static QString langFromSetting()
QETApp::langFromSetting.
void addName(const QString &, const QString &)
void removeName(const QString &)
QHash< QString, QString > getXmlOptions(const QHash< QString, QString > &=QHash< QString, QString >()) const
bool operator==(const NamesList &) const
bool operator!=(const NamesList &) const
QList< QString > langs() const