本文整理汇总了C++中Package::getIcon方法的典型用法代码示例。如果您正苦于以下问题:C++ Package::getIcon方法的具体用法?C++ Package::getIcon怎么用?C++ Package::getIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::getIcon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Package
Package *Package::parse(QDomElement *e, QString *err, bool validate)
{
Package* p = new Package("test", "test");
p->name = e->attribute("name");
if (validate) {
*err = WPMUtils::validateFullPackageName(p->name);
if (!err->isEmpty()) {
err->prepend(QObject::tr("Error in the attribute 'name' in <package>: "));
}
}
p->title = XMLUtils::getTagContent(*e, "title");
p->url = XMLUtils::getTagContent(*e, "url");
p->description = XMLUtils::getTagContent(*e, "description");
p->license = XMLUtils::getTagContent(*e, "license");
QDomNodeList list = e->elementsByTagName("category");
if (err->isEmpty()) {
for (int i = 0; i < list.count(); i++) {
QDomElement ch = list.at(i).toElement();
QDomNode txt = ch.firstChild();
if (txt.isText()) {
QString v = txt.nodeValue().trimmed();
p->categories.append(v);
if (validate && err->isEmpty()) {
if (v.isEmpty()) {
*err = QObject::tr("Empty category");
break;
}
}
}
}
}
if (err->isEmpty()) {
list = e->elementsByTagName("link");
for (int i = 0; i < list.count(); i++) {
QDomElement ch = list.at(i).toElement();
QString rel = ch.attribute("rel").trimmed();
QString href = ch.attribute("href").trimmed();
p->links.insert(rel, href);
if (validate) {
if (rel.isEmpty()) {
*err = QObject::tr("Empty attribute 'rel' in <link>");
break;
}
if (!Package::isValidURL(href)) {
*err = QObject::tr("Empty attribute 'href' in <link>");
break;
}
}
}
}
if (err->isEmpty()) {
if (p->getIcon().isEmpty()) {
p->setIcon(XMLUtils::getTagContent(*e, "icon"));
}
}
if (validate && err->isEmpty()) {
if (!p->getIcon().isEmpty()) {
if (!Package::isValidURL(p->getIcon())) {
*err = QObject::tr("Empty icon URL");
}
}
}
if (err->isEmpty())
return p;
else {
delete p;
return 0;
}
}