Exemple #1
1
QDomElement StyleNode::getElement(QStringList path)
{
    if (path.size() < 1 || path.first() != elem.tagName() ) return QDomElement();

    if ( path.size() == 1) return elem;

    // Try to find this element among the children
    QDomElement e;
    int index = 0;
    while ( e.isNull() && index < children.size() )
    {
        e = children[index]->getElement(path.mid(1));
        index++;
    }
    if (!e.isNull() ) return e;

    // Try to find this element among the prototypes
    index = 0;
    while ( e.isNull() && index < prototypes.size() )
    {
        QStringList newPath = path.mid(1);
        newPath.prepend("style");
        e = prototypes[index]->getElement(newPath);
        index++;
    }

    return e;
}
		bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
		{
			--depth;
			if(depth == 0) {
				Parser::Event *e = new Parser::Event;
				e->setDocumentClose(namespaceURI, localName, qName);
				e->setActualString(in->lastString());
				in->resetLastData();
				eventList.append(e);
				in->pause(true);
			}
			else {
				// done with a depth 1 element?
				if(depth == 1) {
					Parser::Event *e = new Parser::Event;
					e->setElement(elem);
					e->setActualString(in->lastString());
					in->resetLastData();
					eventList.append(e);
					in->pause(true);

					elem = QDomElement();
					current = QDomElement();
				}
				else
					current = current.parentNode().toElement();
			}

			if(in->lastRead() == '/')
				checkNeedMore();

			return true;
		}
QDomElement QgsServerProjectParser::firstComposerLegendElement() const
{
  if ( !mXMLDoc )
  {
    return QDomElement();
  }

  QDomElement documentElem = mXMLDoc->documentElement();
  if ( documentElem.isNull() )
  {
    return QDomElement();
  }

  QDomElement composerElem = documentElem.firstChildElement( "Composer" );
  if ( composerElem.isNull() )
  {
    return QDomElement();
  }
  QDomElement compositionElem = composerElem.firstChildElement( "Composition" );
  if ( compositionElem.isNull() )
  {
    return QDomElement();
  }
  return compositionElem.firstChildElement( "ComposerLegend" );
}
Exemple #4
0
QDomElement XmlHelper::GetXmlNodeParent(const QString &node_tag)
{
    if (!LoadXmlFile())
    {
        return QDomElement();
    }

    QDomNodeList node_list = doc_.elementsByTagName(node_tag);
    if (node_list.count() > 0)
    {
        return node_list.at(0).toElement();
    }

    return QDomElement();
}
Exemple #5
0
void Item::setSaveToElement(bool val) {
    _saveToElement = val;

    // if we don't want direct saving, clear the memory
    if (!_saveToElement)
        _node = QDomElement();
}
Exemple #6
0
QDomElement QDomNodeProto:: lastChildElement(const QString &tagName) const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->lastChildElement(tagName);
  return QDomElement();
}
Exemple #7
0
QDomElement QDomDocumentProto::previousSiblingElement(const QString &tagName) const
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->previousSiblingElement(tagName);
    return QDomElement();
}
Exemple #8
0
QDomElement QDomDocumentProto::toElement() const
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->toElement();
    return QDomElement();
}
Exemple #9
0
QDomElement QDomDocumentProto::elementById(const QString& elementId)
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->elementById(elementId);
    return QDomElement();
}
 //@Override
 /*public*/ void OperationsSetupXml::readFile(QString name) //throw (JDOMException, IOException)
 {
     // suppress rootFromName(name) warning message by checking to see if file exists
     if (findFile(name) == NULL) {
         log->debug(tr("%1 file could not be found").arg(name));
         return;
     }
     // find root
     QDomElement root = rootFromName(name);
     if (root == QDomElement())
     {
      log->debug(tr("%1 file could not be read").arg(name));
      return;
     }
     Setup::load(root);

     // load manifest header text strings
     TrainManifestHeaderText::load(root);

     // load manifest text strings
     TrainManifestText::load(root);

     // load switch list text strings
     TrainSwitchListText::load(root);

     // load control settings
     Control::load(root);
 }
Exemple #11
0
QDomElement QDomNodeProto:: nextSiblingElement(const QString &taName) const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->nextSiblingElement(taName);
  return QDomElement();
}
QDomElement QDomAttrProto:: ownerElement() const
{
  QDomAttr *item = qscriptvalue_cast<QDomAttr*>(thisObject());
  if (item)
    return item->ownerElement();
  return QDomElement();
}
QDomElement QgsWFSServer::createPolygonElem( QgsGeometry* geom, QDomDocument& doc ) const
{
  if ( !geom )
  {
    return QDomElement();
  }

  QDomElement polygonElem = doc.createElement( "gml:Polygon" );
  QgsPolygon poly = geom->asPolygon();
  for ( int i = 0; i < poly.size(); ++i )
  {
    QString boundaryName;
    if ( i == 0 )
    {
      boundaryName = "outerBoundaryIs";
    }
    else
    {
      boundaryName = "innerBoundaryIs";
    }
    QDomElement boundaryElem = doc.createElementNS( "http://www.opengis.net/gml", boundaryName );
    QDomElement ringElem = doc.createElement( "gml:LinearRing" );
    QDomElement coordElem = createCoordinateElem( poly.at( i ), doc );
    ringElem.appendChild( coordElem );
    boundaryElem.appendChild( ringElem );
    polygonElem.appendChild( boundaryElem );
  }
  return polygonElem;
}
Exemple #14
0
QString ElementWrapper::xmlBase() const
{
    if (!d->xmlBaseParsed) // xmlBase not computed yet
    {
        QDomElement current = d->element;
        
        while (!current.isNull())
        {
            if (current.hasAttributeNS(xmlNamespace(), QLatin1String("base")))
            {
                d->xmlBase = current.attributeNS(xmlNamespace(), QLatin1String("base"));
                return d->xmlBase;
            }
            
            QDomNode parent = current.parentNode();

            if (!parent.isNull() && parent.isElement())
                current = parent.toElement();
            else
                current = QDomElement();
        }
        
        d->xmlBaseParsed = true;
    }
    
    return d->xmlBase;
}
Exemple #15
0
QDomElement KXMLGUIClient::findMatchingElement( const QDomElement &base, const QDomElement &additive )
{
  static const QString &tagAction = KGlobal::staticQString( "Action" );
  static const QString &tagMergeLocal = KGlobal::staticQString( "MergeLocal" );
  static const QString &attrName = KGlobal::staticQString( "name" );

  QDomNode n = additive.firstChild();
  while ( !n.isNull() )
  {
    QDomElement e = n.toElement();
    n = n.nextSibling(); // Advance now so that we can safely delete e
    if (e.isNull())
       continue;

    // skip all action and merge tags as we will never use them
    if ( ( e.tagName() == tagAction ) || ( e.tagName() == tagMergeLocal ) )
    {
      continue;
    }

    // now see if our tags are equivalent
    if ( ( e.tagName() == base.tagName() ) &&
         ( e.attribute( attrName ) == base.attribute( attrName ) ) )
    {
        return e;
    }
  }

  // nope, return a (now) null element
  return QDomElement();
}
QDomElement QgsWFSServer::createMultiLineStringElem( QgsGeometry* geom, QDomDocument& doc ) const
{
  if ( !geom )
  {
    return QDomElement();
  }

  QDomElement multiLineStringElem = doc.createElement( "gml:MultiLineString" );
  QgsMultiPolyline multiline = geom->asMultiPolyline();

  QgsMultiPolyline::const_iterator multiLineIt = multiline.constBegin();
  for ( ; multiLineIt != multiline.constEnd(); ++multiLineIt )
  {
    QgsGeometry* lineGeom = QgsGeometry::fromPolyline( *multiLineIt );
    if ( lineGeom )
    {
      QDomElement lineStringMemberElem = doc.createElement( "gml:lineStringMember" );
      QDomElement lineElem = createLineStringElem( lineGeom, doc );
      lineStringMemberElem.appendChild( lineElem );
      multiLineStringElem.appendChild( lineStringMemberElem );
    }
    delete lineGeom;
  }

  return multiLineStringElem;
}
Exemple #17
0
QDomElement ASkinner::skinModuleElement(QString module, QString elementName) {
   QDomElement moduleRoot = modules.firstChildElement(module);
   if(!moduleRoot.isNull()) {
      QDomElement objectRoot = moduleRoot.firstChildElement(elementName);
      if(!objectRoot.isNull()) {
         qDebug() << "Loaded skin element: " << elementName;
         return objectRoot;
      } else {
         qDebug() << "No such element in module" << module << "skin defenition:" << elementName;
         return QDomElement();
      }
   } else {
      qDebug() << "ERROR: No configuration for" << module << "in this skin!";
      return QDomElement();
   }
}
QList<QTreeWidgetItem*> BtBookmarkLoader::loadTree(QString fileName)
{
	qDebug() << "BtBookmarkLoader::loadTree";
	QList<QTreeWidgetItem*> itemList;
	
	QDomDocument doc;
	doc.setContent(loadXmlFromFile(fileName));
	
	//bookmarkfolder::loadBookmarksFromXML()
	
	QDomElement document = doc.documentElement();
	if( document.tagName() != "SwordBookmarks" ) {
		qWarning("Not a BibleTime Bookmark XML file");
		return QList<QTreeWidgetItem*>();
	}

	QDomElement child = document.firstChild().toElement();

	while ( !child.isNull() && child.parentNode() == document) {
		qDebug() << "BtBookmarkLoader::loadTree while start";
		QTreeWidgetItem* i = handleXmlElement(child, 0);
		itemList.append(i);
		if (!child.nextSibling().isNull()) {
			child = child.nextSibling().toElement();
		} else {
			child = QDomElement(); //null
		}
		
	}

	return itemList;
}
Exemple #19
0
bool ParseQuery(const QByteArray& data, XmlQuery* query,
                bool* connection_problems) {
  try {
    *query = lastfm::XmlQuery(data);
#ifdef Q_OS_WIN32
    if (lastfm::ws::last_parse_error != lastfm::ws::NoError) {
      return false;
    }
#endif  // Q_OS_WIN32
  } catch (lastfm::ws::ParseError e) {
    qLog(Error) << "Last.fm parse error: " << e.enumValue();
    if (connection_problems) {
      *connection_problems = e.enumValue() == lastfm::ws::MalformedResponse;
    }
    return false;
  } catch (std::runtime_error& e) {
    qLog(Error) << e.what();
    return false;
  }

  if (connection_problems) {
    *connection_problems = false;
  }

  // Check for app errors.
  if (QDomElement(*query).attribute("status") == "failed") {
    return false;
  }

  return true;
}
Exemple #20
0
QDomElement QDomDocumentProto::createElement(const QString& tagName)
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->createElement(tagName);
    return QDomElement();
}
Exemple #21
0
QDomElement RecordingSet::serialize(QDomDocument *doc) const
{
  if (m_isNull) return QDomElement();

  QDomElement recordingSetElem = doc->createElement("ttsset");
  recordingSetElem.setAttribute("id", QString::number(m_id));

  QDomElement nameElem = doc->createElement("name");
  nameElem.appendChild(doc->createTextNode(m_name));
  QDomElement recordingsElem = doc->createElement("recordings");
  QList<RecordingSetText> texts = m_recordings.keys();

  kDebug() << "Available texts:";
  kDebug() << texts;

  foreach (const RecordingSetText& text, texts)
  {
    QDomElement recordingElem = doc->createElement("recording");
    QDomElement textElem = doc->createElement("text");
    QDomElement pathElem = doc->createElement("path");
    textElem.appendChild(doc->createTextNode(text));
    pathElem.appendChild(doc->createTextNode(m_recordings.value(text)));
    recordingElem.appendChild(textElem);
    recordingElem.appendChild(pathElem);
    recordingsElem.appendChild(recordingElem);
  }
QDomElement JingleContent::nextCandidate()
{
    if (!FTransportCandidates.isEmpty() && FTransportCandidateItreator!=FTransportCandidates.constEnd())
        return *(FTransportCandidateItreator++);
    else
        return QDomElement();
}
Exemple #23
0
QDomElement QDomDocumentProto::firstChildElement(const QString &tagName) const
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->firstChildElement(tagName);
    return QDomElement();
}
Exemple #24
0
void QXmppStream::_q_socketReadyRead()
{
    d->dataBuffer.append(d->socket->readAll());

    // handle whitespace pings
    if (!d->dataBuffer.isEmpty() && d->dataBuffer.trimmed().isEmpty()) {
        d->dataBuffer.clear();
        handleStanza(QDomElement());
    }

    // FIXME : maybe these QRegExps could be static?
    QRegExp startStreamRegex("^(<\\?xml.*\\?>)?\\s*<stream:stream.*>");
    startStreamRegex.setMinimal(true);
    QRegExp endStreamRegex("</stream:stream>$");
    endStreamRegex.setMinimal(true);

    // check whether we need to add stream start / end elements
    //
    // NOTE: as we may only have partial XML content, do not alter the stream's
    // state until we have a valid XML document!
    QByteArray completeXml = d->dataBuffer;
    const QString strData = QString::fromUtf8(d->dataBuffer);
    bool streamStart = false;
    if (d->streamStart.isEmpty() && strData.contains(startStreamRegex))
        streamStart = true;
    else
        completeXml.prepend(d->streamStart);
    bool streamEnd = false;
    if (strData.contains(endStreamRegex))
        streamEnd = true;
    else
        completeXml.append(streamRootElementEnd);

    // check whether we have a valid XML document
    QDomDocument doc;
    if (!doc.setContent(completeXml, true))
        return;

    // remove data from buffer
    logReceived(strData);
    d->dataBuffer.clear();

    // process stream start
    if (streamStart) {
        d->streamStart = startStreamRegex.cap(0).toUtf8();
        handleStream(doc.documentElement());
    }

    // process stanzas
    QDomElement nodeRecv = doc.documentElement().firstChildElement();
    while (!nodeRecv.isNull()) {
        handleStanza(nodeRecv);
        nodeRecv = nodeRecv.nextSiblingElement();
    }

    // process stream end
    if (streamEnd)
        disconnectFromHost();
}
const QDomElement EffectsListWidget::currentEffect() const
{
    QTreeWidgetItem *item = currentItem();
    if (!item) return QDomElement();
    int type = item->data(0, TypeRole).toInt();
    QStringList info = item->data(0, IdRole).toStringList();
    return itemEffect(type, info);
}
QDomElement QgsServerProjectParser::legendElem() const
{
  if ( !mXMLDoc )
  {
    return QDomElement();
  }
  return mXMLDoc->documentElement().firstChildElement( "legend" );
}
inline QDomElement getDomElementByTagName(QDomElement parent, QString tagname)
{
	QDomNodeList elementList = parent.elementsByTagName(tagname);
	if (elementList.count())
		return elementList.at(0).toElement();
	else
		return QDomElement();
}
QDomElement findLastElementByTag(const QDomElement element, const QString tagName)
{
    QDomNodeList l = element.elementsByTagName(tagName);
    if (l.isEmpty())
        return QDomElement();

    return l.at(l.length()-1).toElement();
}
Exemple #29
0
void CreateCommand::redo()
{
    QString parentAddress = KBookmark::parentAddress(m_to);
    KBookmarkGroup parentGroup =
        m_model->bookmarkManager()->findByAddress(parentAddress).toGroup();

    QString previousSibling = KBookmark::previousAddress(m_to);

    // kDebug() << "previousSibling=" << previousSibling;
    KBookmark prev = (previousSibling.isEmpty())
        ? KBookmark(QDomElement())
        : m_model->bookmarkManager()->findByAddress(previousSibling);

    KBookmark bk = KBookmark(QDomElement());
    const int pos = KBookmark::positionInParent(m_to);
    m_model->beginInsert(parentGroup, pos, pos);

    if (m_separator) {
        bk = parentGroup.createNewSeparator();

    } else if (m_group) {
        Q_ASSERT(!m_text.isEmpty());
        bk = parentGroup.createNewFolder(m_text);
        bk.internalElement().setAttribute("folded", (m_open ? "no" : "yes"));
        if (!m_iconPath.isEmpty()) {
            bk.setIcon(m_iconPath);
        }
    } else if(!m_originalBookmark.isNull()) {
        QDomElement element = m_originalBookmark.internalElement().cloneNode().toElement();
        bk = KBookmark(element);
        parentGroup.addBookmark(bk);
    } else {
        bk = parentGroup.addBookmark(m_text, m_url, m_iconPath);
    }

    // move to right position
    parentGroup.moveBookmark(bk, prev);
    if (!(text().isEmpty()) && !parentAddress.isEmpty() ) {
        // open the parent (useful if it was empty) - only for manual commands
        Q_ASSERT( parentGroup.internalElement().tagName() != "xbel" );
        parentGroup.internalElement().setAttribute("folded", "no");
    }

    Q_ASSERT(bk.address() == m_to);
    m_model->endInsert();
}
Exemple #30
0
QDomElement ElementWrapper::firstElementByTagNameNS(const QString& nsURI, const QString& localName) const
{
    if (isNull())
        return QDomElement();
    
    for (QDomNode n = d->element.firstChild(); !n.isNull(); n = n.nextSibling())
    {
        if (n.isElement())
        {
            QDomElement e = n.toElement();
            if (e.localName() == localName && e.namespaceURI() == nsURI)
                return e;
        }
    }
    
    return QDomElement();
}