Example #1
0
bool DefinitionParser::createSingleFrameAsset (QDomNode& node, const Content::Class clazz, const QString& tag)
{
	QDomNamedNodeMap attr = node.attributes();
	const QString name = attr.namedItem(ATTR_CLASS).nodeValue();
	const QString pathattr = attr.namedItem(ATTR_PATH).nodeValue();
	if (pathattr.isEmpty()) {
		warnMissingAttr(ATTR_PATH, tag);
		return false;
	}
	const QString path = _targetDir.absoluteFilePath(pathattr);
	if (!checkPathExists(path)) {
		return false;
	}
	if (name.isEmpty()) {
		warnMissingAttr(ATTR_CLASS, tag);
		return false;
	}
	if (clazz == Content::SPRITE || clazz == Content::MOVIECLIP) {
		struct AssetBit asset;
		asset.path = _tempDir.relativeFilePath(path);
		copyAttributes(&asset, attr);
		struct SpriteAsset* sprite = new SpriteAsset();
		sprite->assets.push_back(asset);
		sprite->clazz = clazz;
		sprite->name = name;
		_assets[name] = sprite;
	} else {
		struct Asset* common = new Asset();
		common->path = path;
		common->name = name;
		_assets[name] = common;
	}
	return true;
}
Example #2
0
void WSettings::searchFinished(QNetworkReply *reply)
{
	reply->deleteLater();
	ui.addButton->setEnabled(true);
	ui.searchEdit->clear();

	QDomDocument doc;
	if (!doc.setContent(reply->readAll()))
		return;
	QDomElement rootElement = doc.documentElement();

	QDomNodeList locations = rootElement.elementsByTagName(QLatin1String("location"));
	if (locations.isEmpty())
		ui.searchEdit->addItem(tr("Not found"));
	for (int i = 0; i < locations.count(); i++) {
		QDomNamedNodeMap attributes = locations.at(i).attributes();
		QString cityId = attributes.namedItem(QLatin1String("location")).nodeValue();
		QString cityName = attributes.namedItem(QLatin1String("city")).nodeValue();
		QString stateName = attributes.namedItem(QLatin1String("state")).nodeValue();
		QString cityFullName = cityName + ", " + stateName;
		int index = ui.searchEdit->count();
		ui.searchEdit->addItem(cityFullName);
		ui.searchEdit->setItemData(index, cityId, CodeRole);
		ui.searchEdit->setItemData(index, cityName, CityRole);
		ui.searchEdit->setItemData(index, stateName, StateRole);
	}
}
Example #3
0
void DefinitionParser::copyAttributes (AssetBit* asset, const QDomNamedNodeMap& attributes) const
{
	asset->x = attributes.namedItem(ATTR_X).nodeValue();
	asset->y = attributes.namedItem(ATTR_Y).nodeValue();
	asset->alpha = attributes.namedItem(ATTR_ALPHA).nodeValue();
	asset->visible = attributes.namedItem(ATTR_VISIBLE).nodeValue();
}
Example #4
0
QVariant MetricDomModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (role != Qt::DisplayRole)
        return QVariant();

    DomItem *item = static_cast<DomItem*>(index.internalPointer());

    QDomNode node = item->node();

    QStringList attributes;
    QDomNamedNodeMap attributeMap = node.attributes();

    switch (index.column()) {
        case 0:
            return node.nodeName();
        case 1:
        	if( !attributeMap.contains("Type") ) {
        		return QVariant();
        	}
        	return attributeMap.namedItem("Type").nodeValue();
        case 2:
        	if( !attributeMap.contains("Format") ) {
        		return QVariant();
        	}
        	return attributeMap.namedItem("Format").nodeValue();
        default:
            return QVariant();
    }
}
Example #5
0
bool CAnm2DXml::loadLayers(QDomNode node, AnmLayer *pParent)
{
	while ( !node.isNull() ) {
		if ( node.nodeName() == kAnmXML_ID_Layer ) {
			QDomNamedNodeMap nodeMap = node.attributes() ;
			if ( nodeMap.namedItem(kAnmXML_Attr_Name).isNull()
			  || nodeMap.namedItem(kAnmXML_Attr_FrameNum).isNull()
			  || nodeMap.namedItem(kAnmXML_Attr_ChildNum).isNull() ) {
				return false ;
			}
			QString name ;
			int frameDataNum = 0 ;
			int childNum = 0 ;

			name = nodeMap.namedItem(kAnmXML_Attr_Name).toAttr().value() ;
			frameDataNum = nodeMap.namedItem(kAnmXML_Attr_FrameNum).toAttr().value().toInt() ;
			childNum = nodeMap.namedItem(kAnmXML_Attr_ChildNum).toAttr().value().toInt() ;

			AnmLayer *pLayer = new AnmLayer ;
			pLayer->pParentLayer = pParent ;
			pParent->childPtrs.append(pLayer) ;

			QDomNode child = node.firstChild() ;
			if ( !loadFrameData(child, pLayer, frameDataNum) ) {
				return false ;
			}
			QDomNode layers = node.firstChild() ;
			if ( !loadLayers(layers, pLayer) ) {
				return false ;
			}
		}
		node = node.nextSibling() ;
	}
	return true ;
}
Example #6
0
bool PodcastRSSParser::populateEpisodesFromChannelXML(QList<PodcastEpisode *> *episodes, QByteArray xmlReply)
{
    qDebug() << "Parsing XML for episodes";

    if (xmlReply.size() < 10) {
        return false;
    }

    QDomDocument xmlDocument;
    if (xmlDocument.setContent(xmlReply) == false) {        // Construct the XML document and parse it.
        return false;
    }

    QDomElement docElement = xmlDocument.documentElement();

    QDomNodeList channelNodes = docElement.elementsByTagName("item");  // Find all the "item nodes from the feed XML.
    qDebug() << "I have" << channelNodes.size() << "episode elements";

    for (uint i=0; i<channelNodes.length(); i++) {
        QDomNode node = channelNodes.at(i);

        if (isEmptyItem(node)) {
            qWarning() << "Empty podcast item. Ignoring...";
            continue;
        }

        PodcastEpisode *episode = new PodcastEpisode;
        QDateTime pubDate = parsePubDate(node);

        if (!pubDate.isValid()) {
            qWarning() << "Could not parse pubDate for podcast episode!";
            delete episode;
            continue;
        } else {
            episode->setPubTime(pubDate);
        }

        episode->setTitle(node.firstChildElement("title").text());
        episode->setDescription(node.firstChildElement("description").text());

        if (episode->description().isEmpty())
            episode->setDescription(node.firstChildElement("content:encoded").text());

        if (episode->description().isEmpty())
            episode->setDescription(node.firstChildElement("itunes:summary").text());


        episode->setDuration(node.firstChildElement("itunes:duration").text());

        QDomNamedNodeMap attrMap = node.firstChildElement("enclosure").attributes();
        episode->setDownloadLink(attrMap.namedItem("url").toAttr().value());
        episode->setDownloadSize(attrMap.namedItem("length").toAttr().value().toInt());

        episodes->append(episode);
    }

    return true;
}
Example #7
0
bool DefinitionParser::createMultiFrameSprite (QDomNode& frame, const Content::Class clazz)
{
	QDomNode parent = frame.parentNode();
	QDomNamedNodeMap attributes = parent.attributes();
	const QString childName = clazz == Content::MOVIECLIP ? ::NODE_FRAME : ::NODE_OBJECT;
	const QString className = attributes.namedItem(ATTR_CLASS).nodeValue();
	const QString basePath = attributes.namedItem(ATTR_PATH).nodeValue();
	const QString absBasePath = _targetDir.absoluteFilePath(basePath);
	struct SpriteAsset* sprite = NULL;

	if (!QFile::exists(absBasePath)) {
		info("base path \'" + absBasePath + "\' does not exist");
		return false;
	}

	while (!frame.isNull()) {
		QDomElement e = frame.toElement();
		QDomNamedNodeMap attr = frame.attributes();
		checkAttributes(frame);
		frame = frame.nextSibling();

		if (e.isNull()) {
			continue;
		}

		const QString tn = e.tagName();
		if (tn != childName) {
			warnInvalidTag(tn, frame.parentNode().nodeName());
			continue;
		}

		const QString relpath = attr.namedItem(ATTR_PATH).nodeValue();
		if (attr.isEmpty() || relpath.isEmpty()) {
			warnMissingAttr(ATTR_PATH, tn);
			continue;
		}

		const QString path = _targetDir.absoluteFilePath(basePath + relpath);
		if (!checkPathExists(path)) {
			continue;
		}
		struct AssetBit asset;
		asset.name = attr.namedItem(ATTR_NAME).nodeValue();
		asset.path = _tempDir.relativeFilePath(path);
		copyAttributes(&asset, attr);
		if (!sprite) {
			sprite = new SpriteAsset();
		}
		sprite->assets.push_back(asset);
	}
	if (sprite) {
		sprite->clazz = clazz;
		sprite->name = className;
		copyAttributes(sprite, attributes);
		_assets[className] = sprite;
	}
	return true;
}
Example #8
0
SBGNPort::SBGNPort(QDomNode node)
{
    QDomNamedNodeMap attrs = node.attributes();

    float x = attrs.namedItem("x").toAttr().value().toFloat();
    float y = attrs.namedItem("y").toAttr().value().toFloat();
    m_pos = QPointF(x,y);

    m_id = attrs.namedItem("id").toAttr().value();
}
Example #9
0
/******************************************************************************
    PopulateComponent
******************************************************************************/
void
CUpdateInfoGetter::PopulateComponent(
    const QDomNode &appNode,
    CComponentInfo& info)
{

    //TODO: sanity check xml

    //if (vecStrings.size() != 5)
    //{
    //    Q_ASSERT(false);
    //    throw ConnectionException(QT_TR_NOOP("Downloaded update info for "
    //        "component didn't contain the correct number of entries."));
    //}

    info.Clear();

    QDomNamedNodeMap appAttributes = appNode.attributes();

    info.SetName(appAttributes.namedItem( "name" ).nodeValue());

    #ifdef WIN32
        string sPF = UnicornUtils::programFilesPath();
        if (sPF == "")
        {
            // Do our best at faking it. Will at least work some of the time.
            LOG(1, "Couldn't get PF path so trying to fake it.");
            sPF = "C:\\Program Files\\";
        }
        info.SetPath(QString::fromStdString(sPF) +
                     appNode.firstChildElement("Path").text());
    #else // not WIN32
        info.SetPath(appNode.firstChildElement("Path").text());
    #endif // WIN32

    if ( !appNode.firstChildElement("Size").isNull() )
        info.SetSize( appNode.firstChildElement("Size").text().toInt() );
    else
        info.SetSize( 0 );

    info.SetDownloadURL ( appNode.firstChildElement("Url").text() );
    info.SetVersion     ( appAttributes.namedItem( "version" ).nodeValue() );
    info.SetInstallArgs ( appNode.firstChildElement("Args").text()  );

    if( appAttributes.contains( "majorUpgrade" )) {
        info.SetMajorUpgrade( appAttributes.namedItem( "majorUpgrade" ).nodeValue()
                              == "true" );
    }

    if( !appNode.firstChildElement("Description").isNull())
        info.SetDescription( appNode.firstChildElement("Description").text());

    if( !appNode.firstChildElement("Image").isNull())
        info.SetImage( QUrl( appNode.firstChildElement("Image").text()));
}
  void
  operator <<= (Miro::SensorGroupIDL& group, const QDomNode& node)
  {
    if (!node.isNull()) {

      // set sensor defaults
      Miro::SensorPositionIDL sensor;
      sensor.masked = false;
      QDomNamedNodeMap map = node.attributes();
      QDomNode n;
      n = map.namedItem("height");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.height = attr.value().toInt();
      }
      n = map.namedItem("distance");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.distance =attr.value().toInt();
      }
      n = map.namedItem("alpha");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.alpha = deg2Rad(attr.value().toDouble());
      }
      n = map.namedItem("beta");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.beta = deg2Rad(attr.value().toDouble());
      }
      n = map.namedItem("gamma");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.gamma = deg2Rad(attr.value().toDouble());
      }
      QDomNode n1 = node.firstChild();
      while(!n1.isNull() ) {
	if (n1.nodeName() == "description") {
	  group.description <<= n1;
	}
	else if (n1.nodeName() == "sensor") {
	  group.sensor.length(group.sensor.length() + 1);
	  group.sensor[group.sensor.length() - 1] = sensor;
	  group.sensor[group.sensor.length() - 1] <<= n1;
	}
	n1 = n1.nextSibling();
      }
    }
  }
Example #11
0
void mafGUIManager::createToolbar(QDomElement node) {
    QDomNamedNodeMap attributes = node.attributes();
    QString title = attributes.namedItem("title").nodeValue();
    QString actions = attributes.namedItem("actionList").nodeValue();

    QToolBar *toolBar = m_MainWindow->addToolBar(tr(title.toAscii().constData()));

    QStringList actionList = actions.split(",");
    foreach (QString action, actionList) {
        toolBar->addAction((QAction*)menuItemByName(action));
    }
Example #12
0
void loadFlowKnots(const QDomNamedNodeMap& _nodeMap, Flow* _flow)
{
    int count = _nodeMap.namedItem("KnotsCount").toAttr().value().toInt();
    QList<QPointF> list;
    for (int i = 0; i < count; ++i) {
        QPointF pt = QPointF(
                         _nodeMap.namedItem("KnotX_" + QString::number(i)).toAttr().value().toDouble(),
                         _nodeMap.namedItem("KnotY_" + QString::number(i)).toAttr().value().toDouble()
                     );
        list << pt;
    }
    _flow->setFlowKnots(list);
}
Example #13
0
void ColourParser::parseFile() {
    QDomNodeList colourList = doc.elementsByTagName("MabiSysPalette");
    for (int i = 0; i < colourList.count(); i++) {
        QDomNode colour = colourList.at(i);
        QDomNamedNodeMap attributes = colour.attributes();
        ColourParser::Object *c = new ColourParser::Object;
        c->name = localeMap->getValue(attributes.namedItem("nameLocal").nodeValue());
        c->colourID = attributes.namedItem("number").nodeValue().toInt();
        c->argb = QColor("#" + attributes.namedItem("RGB").nodeValue());
        colours.append(c);
    }

}
Example #14
0
// -------------------------------------------------------------------------------
void XMLPersister::parseDescriptionAttributes( QDomElement& elem,
                                        CTreeInformationElement& informationElem )
// -------------------------------------------------------------------------------
{
   QDomNamedNodeMap attributes = elem.attributes();

   if ( !attributes.namedItem("color").isNull() )
   {
      QColor c( attributes.namedItem("color").toAttr().value() );
      Q_ASSERT( c.isValid() );
      informationElem.setDescriptionColor( c );
   }
}
Example #15
0
/** Sets the layout attributes for the given report section */
void MReportEngine::setSectionAttributes(MReportSection *section, QDomNode *report)
{
  // Get the attributes for the section
  QDomNamedNodeMap attributes = report->attributes();

  // Get the section attributes
  section->setHeight(attributes.namedItem("Height").nodeValue().toInt());
  section->setPrintFrequency(attributes.namedItem("PrintFrequency").nodeValue().toInt());
  if (attributes.contains("SectionId"))
    section->setIdSec(attributes.namedItem("SectionId").nodeValue().toUInt());

  // Process the sections labels
  QDomNodeList children = report->childNodes();
  int childCount = children.length();

  // For each label, extract the attr list and add the new label
  // to the sections's label collection

  for (int j = 0; j < childCount; j++) {
    QDomNode child = children.item(j);

    if (child.nodeType() == QDomNode::ElementNode) {
      if (child.nodeName() == "Line") {
        QDomNamedNodeMap attributes = child.attributes();
        MLineObject *line = new MLineObject();

        setLineAttributes(line, &attributes);
        section->addLine(line);
      } else if (child.nodeName() == "Label") {
        QDomNamedNodeMap attributes = child.attributes();
        MLabelObject *label = new MLabelObject();

        setLabelAttributes(label, &attributes);
        section->addLabel(label);
      } else if (child.nodeName() == "Special") {
        QDomNamedNodeMap attributes = child.attributes();
        MSpecialObject *field = new MSpecialObject();

        setSpecialAttributes(field, &attributes);
        section->addSpecialField(field);
      } else if (child.nodeName() == "CalculatedField") {
        QDomNamedNodeMap attributes = child.attributes();
        MCalcObject *field = new MCalcObject();

        setCalculatedFieldAttributes(field, &attributes);
        section->addCalculatedField(field);
      }
    }
  }
}
void
StationsPluginFactorySimple::loadCity(const QDomNode & city)
{
  QDomNode node;
  QPointF min, max;
  QDomNamedNodeMap attrs;
  StationsPluginSimplePrivate data;

  attrs = city.attributes();

  data.id = attrs.namedItem("id").nodeValue();

  node = city.firstChildElement("latitude");
  attrs = node.attributes();

  data.center.setX(node.toElement().text().toDouble());
  min.setX(attrs.namedItem("min").nodeValue().toDouble());
  max.setX(attrs.namedItem("max").nodeValue().toDouble());

  node = city.firstChildElement("longitude");
  attrs = node.attributes();

  data.center.setY(node.toElement().text().toDouble());
  min.setY(attrs.namedItem("min").nodeValue().toDouble());
  max.setY(attrs.namedItem("max").nodeValue().toDouble());

  data.rect = QRectF(min, max);
  data.statusUrl = city.firstChildElement("status").text();
  data.infosUrl = city.firstChildElement("infos").text();
  data.name = city.firstChildElement("name").text();
  data.bikeName = city.firstChildElement("bikeName").text();
  data.type = city.firstChildElement("type").text();

  QString icon = city.firstChildElement("bikeIcon").text();

  if (icon.isEmpty())
    icon = ":/res/bike.png";

  data.bikeIcon = QIcon(icon);

  if (data.id.isEmpty() || !data.rect.isValid() || data.center.isNull() ||
      data.name.isEmpty() || data.bikeName.isEmpty() || data.type.isEmpty()) {
    qWarning() << "Error processing city " << data.id
	       << data.name << data.bikeName << data.type;
    return ;
  }

  cities[data.id] = data;
}
SyntaxHighlighter::SyntaxHighlighter( CodeEditor *parent, QDomNode& node)
	: QSyntaxHighlighter(parent->document()), m_pEditor(parent)
{
	// string list that holds the key words
	QStringList keys;

	// get first child
	QDomNode temp = node.lastChild();

	//////////////////////////////////////////////////////////////////////////
	// get key words
	while(!temp.isNull())
	{
		// get children
		QDomNodeList children = temp.childNodes();

		// get attributes
		QDomNamedNodeMap attributes = temp.toElement().attributes();

		// extract data
		for (int i = 0; i < children.length(); i++)
		{
			QString keyword = attributes.namedItem("StartTag").nodeValue() + 
								children.at(i).toElement().text() +
								attributes.namedItem("EndTag").nodeValue();

			keys.append(keyword);
		}	
			
		// rule 
		HighlightingRule rule;
		rule.format.setForeground(QColor(attributes.namedItem("Color").nodeValue()));
		rule.format.setFontItalic(attributes.namedItem("Italic").nodeValue().toInt());
		rule.format.setFontWeight(attributes.namedItem("Bold").nodeValue().toInt());

		// add to rule set
		foreach (const QString &pattern, keys)
		{			
			rule.pattern = QRegExp(pattern);
			highlightingRules.append(rule);
		}

		// clear keys
		keys.clear();

		// next
		temp = temp.previousSibling();
	}
Example #18
0
//copyright : (C) 2002-2004 InfoSiAL S.L.
//email     : [email protected]
void MReportEngine::drawDetailHeader(MPageCollection *pages, int level)
{
  MReportSection *header = findDetailHeader(level);

  if (header) {
    QDomNode record = records.item(currRecord_);

    if (!header->mustBeDrawed(&record))
      return;

    header->setPageNumber(currPage);
    header->setReportDate(currDate);

    if ((currY + header->getHeight()) > currHeight)
      newPage(pages);

    QString value;
    QDomNamedNodeMap fields = record.attributes();

    for (int i = 0; i < header->getFieldCount(); i++) {
      value = fields.namedItem(header->getFieldName(i)).nodeValue();
      header->setFieldData(i, value, &record, fillRecords_);
    }

    header->setCalcFieldData(0, 0, &record, fillRecords_);

    int sectionHeight = header->getHeight();
    header->draw(p, leftMargin, currY, sectionHeight);
    header->setLastPageIndex(pages->getCurrentIndex());
    header->setOnPage((QPicture *) p->painter()->device());
    currY += sectionHeight;
  }
}
Example #19
0
void SvgImage::modify(const QString &tag, const QString &id, const QString &attribute,
                      const QString &value)
{
    bool modified = false;

    QDomNodeList nodeList = m_svgDocument.elementsByTagName( tag );
    for ( int i = 0; i < nodeList.count(); ++i )
    {
        QDomNode node = nodeList.at( i );
        QDomNamedNodeMap attributes = node.attributes();
        if ( checkIDAttribute( attributes, id ) )
        {
            QDomNode attrElement = attributes.namedItem( attribute );
            if ( attrElement.isAttr() )
            {
                QDomAttr attr = attrElement.toAttr();
                attr.setValue( value );
                modified = true;
            }
        }
    }

    if ( modified )
    {
        m_updateNeeded = true;
        update();
    }
}
Example #20
0
//copyright : (C) 2002-2004 InfoSiAL S.L.
//email     : [email protected]
void MReportEngine::drawAddOnHeader(MPageCollection *pages, int level,
                                    QPtrList<QMemArray<double> > *gDT,
                                    QValueVector<QString> *gDTS)
{
  MReportSection *header = findAddOnHeader(level);

  if (header) {
    QDomNode record = records.item(currRecord_);

    if (!header->mustBeDrawed(&record))
      return;

    header->setPageNumber(currPage);
    header->setReportDate(currDate);

    if ((currY + header->getHeight()) > currHeight)
      newPage(pages);

    QString value;
    QDomNamedNodeMap fields = record.attributes();

    for (int i = 0; i < header->getFieldCount(); i++) {
      value = fields.namedItem(header->getFieldName(i)).nodeValue();
      header->setFieldData(i, value, &record, fillRecords_);
    }

    if (gDT && level > -1)
      header->setCalcFieldData(gDT, gDTS, &record, fillRecords_);
    header->setCalcFieldDataGT(grandTotal);

    int sectionHeight = header->getHeight();
    header->draw(p, leftMargin, currY, sectionHeight);
    currY += sectionHeight;
  }
}
QDomNode QDomNamedNodeMapProto:: namedItem(const QString& name) const
{
  QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject());
  if (item)
    return item->namedItem(name);
  return QDomNode();
}
Example #22
0
// the constructor
ComponentGenerator::ComponentGenerator(QDomNode &generatorNode):
    Generator(generatorNode),
    scope_(ComponentGenerator::INSTANCE),
    groups_() {

    QDomNamedNodeMap attributeMap = generatorNode.attributes();

    // get the spirit scope attribute
    QString scope = attributeMap.namedItem(QString("spirit:scope")).nodeValue();
    if (scope == QString("entity")) {
        scope_ = ComponentGenerator::ENTITY;
    }
    else {
        scope_ = ComponentGenerator::INSTANCE;
    }

    // go through all the child nodes of the component generator
    for (int i = 0; i < generatorNode.childNodes().count(); ++i) {
        QDomNode tempNode = generatorNode.childNodes().at(i);

        if (tempNode.nodeName() == QString("spirit:group")) {
            QString groupName = tempNode.childNodes().at(0).nodeValue();
            groupName = XmlUtils::removeWhiteSpace(groupName);
            groups_.append(groupName);
        }
    }
}
Example #23
0
QString Unpacker::getVarAppTitle(QString contents) const
{
    QString manifest;

    QFile f(contents + "/AndroidManifest.xml");
    if (f.open(QFile::ReadOnly | QFile::Text)) {
        manifest = f.readAll();
        f.close();
    }
    else {
        return QString();
    }

    // Parse application title variable name:

    QDomDocument dom;
    dom.setContent(manifest);
    QDomNodeList nodes = dom.elementsByTagName("application");
    if (!nodes.isEmpty()) {
        QDomNamedNodeMap attr = nodes.at(0).attributes();
        const QString LABEL = attr.namedItem("android:label").nodeValue();
        if (LABEL.startsWith("@string/")) {
            return LABEL.mid(8);
        }
        else {
            return QString();
        }
    }
    else {
        return QString();
    }
}
Example #24
0
/** Returns wether the Report Section must be drawed or not depending on the DrawIf attribute and the current record values */
bool MReportSection::mustBeDrawed( QDomNode * record ) {
  QString value;
  QDomNamedNodeMap fields = record->attributes();
  QString drawIfField = getDrawIf();

  if ( !drawIfField.isEmpty() ) {
    QDomNode n = fields.namedItem( drawIfField );

    if ( n.isNull() )
      return false;

    value = n.toAttr().value();

    if ( value.isEmpty() )
      return false;

    bool b = true;

    float f = value.toFloat( &b );

    if ( f == 0 && b )
      return false;
  }

  return true;
}
Example #25
0
void ComponentItem::initPins()
{
    QDomNode pinsNode;
    QDomNodeList list = m_svgDocument.elementsByTagName("g");
    for (int i=0;i<list.count();i++){
        QDomNamedNodeMap attrs = list.item(i).attributes();
        if (attrs.contains("id") &&
            attrs.namedItem("id").toAttr().value() == QString("pins")){
            pinsNode = list.item(i);
            break;
        }
    }
    if (pinsNode.isNull() || !pinsNode.hasChildNodes()){
        kWarning() << "No pins definition found for this component";
        return;
    }
    QDomElement pin = pinsNode.firstChildElement();
    while (!pin.isNull()) {
        QRectF pinRect;
        double r = pin.attribute("r").toDouble();
        pinRect.setLeft(pin.attribute("cx").toDouble());
        pinRect.setTop(pin.attribute("cy").toDouble());
        pinRect.setWidth(r*2);
        pinRect.setHeight(r*2);
        PinItem* p = new PinItem(pinRect, this, qobject_cast< IDocumentScene* >(scene()));
        p->setId(pin.attribute("id"));
        pin = pin.nextSiblingElement();
    }
}
Example #26
0
bool Configurator::loadSectionItem( QDomNode sectionItem, QListWidget& listWidget )
{
	if( false == sectionItem.hasChildNodes() )
		return false;

	if( sectionItem.nodeName() != c_sectionItemNodeName )
		return false;

	QDomNamedNodeMap sectionItemAttributes = sectionItem.attributes();
	if( false == sectionItemAttributes.contains(c_attributeName) )
		return false;

	if( false == sectionItemAttributes.contains(c_attributeText) )
		return false;

	// add the item to the section
	QString sectionItemName = sectionItemAttributes.namedItem(c_attributeName).nodeValue();
	QString sectionItemText = sectionItemAttributes.namedItem(c_attributeText).nodeValue();
	
	QListWidgetItem*	listWidgetItem = new QListWidgetItem();
					    listWidgetItem->setText( sectionItemText );
					    listWidgetItem->setData( Qt::UserRole, sectionItemName );

    listWidget.addItem( listWidgetItem );

	return true;
}
bool RedisConnectionConfig::getValueFromXml(const QDomNamedNodeMap & attr, const QString& name, QString & value)
{
    if (!attr.contains(name))
        return false;

    value = attr.namedItem(name).nodeValue();

    return true;
}
Example #28
0
void DefinitionParser::parseAssetNodes (QDomNode& node, const Content::Class clazz)
{
	bool sprite = false;
	QString nodeName;
	switch (clazz) {
	case Content::MOVIECLIP:
		nodeName = NODE_MOVIECLIP;
		sprite = true;
		break;
	case Content::SPRITE:
		sprite = true;
		nodeName = NODE_SPRITE;
		break;
	case Content::BITMAPDATA:
		nodeName = NODE_BITMAP;
		break;
	case Content::SOUND:
		nodeName = NODE_SOUND;
		break;
	case Content::BYTEARRAY:
		nodeName = NODE_BINARY;
		break;
	default:
		error("invalid class type " + QString::number(clazz));
		return;
	}
	while (!node.isNull()) {
		QDomElement elem = node.toElement();
		QDomNode parseNode = node;
		QDomNamedNodeMap attributes = node.attributes();
		QDomNode frame = node.firstChild();
		checkAttributes(node);
		node = node.nextSibling();

		if (elem.isNull()) {
			continue;
		}

		const QString tag = elem.tagName();
		if (nodeName != tag) {
			warnInvalidTag(tag, parseNode.parentNode().nodeName());
			continue;
		}

		if (attributes.isEmpty() || attributes.namedItem(ATTR_CLASS).nodeValue().isEmpty()) {
			warnMissingAttr(ATTR_CLASS, tag);
			continue;
		}

		if (frame.isNull() || !sprite) {
			createSingleFrameAsset(parseNode, clazz, nodeName);
		} else {
			createMultiFrameSprite(frame, clazz);
		}
	}
}
Example #29
0
QString TocDomModel::getLinkStringFromIndex(const QModelIndex &index) {
    /* TODO: where does the info that the named item is called 'Destination' come from?! */
    if (!index.isValid()) return QString();

    TocDomItem *item = static_cast<TocDomItem*>(index.internalPointer());
    QDomNode node = item->node();
    QDomNamedNodeMap attributeMap = node.attributes();

    return attributeMap.namedItem("Destination").nodeValue();
}
Example #30
0
bool checkIDAttribute( const QDomNamedNodeMap& map, const QString& value )
{
    QDomNode attrElement = map.namedItem( "id" );
    if ( attrElement.isAttr() )
    {
        QDomAttr attr = attrElement.toAttr();
        return attr.value() == value;
    }
    return false;
}