Пример #1
0
void AcquisitionData::parseXml(QDomNode& dataNode)
{
	QDomNode recordsessionsNode = dataNode.namedItem("recordSessions");
	QDomElement recodesessionNode = recordsessionsNode.firstChildElement("recordSession");
	for (; !recodesessionNode.isNull(); recodesessionNode = recodesessionNode.nextSiblingElement("recordSession"))
	{
//		RecordSessionPtr session(new RecordSession("", 0,0,""));
		RecordSessionPtr session(new RecordSession());
		session->parseXml(recodesessionNode);
		this->addRecordSession(session);
	}
}
Пример #2
0
void PluginDialog::parsePluginNode(QDomNode node)
{
    QString name = node.firstChildElement("name").text();
    QString shortname = node.firstChildElement("shortname").text();
    QString iconUrl = node.firstChildElement("icon").text();
    QString category = node.firstChildElement("category").text();
    QString downloadUrl = node.firstChildElement("download").text();
    QString version = node.firstChildElement("version").text();
    QIcon icon = NetworkUtils::getIconFromUrl(QUrl(iconUrl));

    QList<QStandardItem *> rowItems;
    QStandardItem* pluginItem = new QStandardItem(icon, name);
    pluginItem->setData(shortname, Qt::UserRole);
    pluginItem->setData(downloadUrl, Qt::UserRole + 1);
    pluginItem->setData(version, Qt::UserRole + 2);
    rowItems << pluginItem;
    QStandardItem* enableItem = new QStandardItem("");
    enableItem->setCheckable(true);
    if(pluginManager->isInstalled(shortname))
    {
        enableItem->setCheckState(Qt::Checked);
    }
    rowItems << enableItem;
    if(category != "local")
    {
        categoryOnline->appendRow(rowItems);
    }else
    {
        categoryLocal->appendRow(rowItems);
    }
}
Пример #3
0
void XMLParser::callDone()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>(this->sender());

    if(!reply)
        return;

    QDomDocument doc;
    doc.setContent(reply->readAll());

    QDomElement docRootElement = doc.documentElement();

    QDomNode n = docRootElement.firstChild();

    for(QDomNode n = docRootElement.firstChild(); !n.isNull(); n= n.nextSibling())
    {
        qDebug() << n.firstChildElement("text").text();
        d->tweetList.prepend(n.firstChildElement("text").text());
    }

   // qDebug() << d->tweetList;
}
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;
}
void
StationsPluginFactorySimple::loadInfos(const QString & xml)
{
  QFile file(xml);
  QDomDocument doc;
  QDomNode node;
  QDomNamedNodeMap attrs;

  if (!file.open(QIODevice::ReadOnly)) {
    qWarning() << "Can't open" << file.fileName() << ": " << file.error();
    return ;
  }

  doc.setContent(&file);
  node = doc.firstChildElement("country");
  attrs = node.attributes();

  id_ =  attrs.namedItem("id").nodeValue();
  name_ = node.firstChildElement("name").text();
  description_ = node.firstChildElement("description").text();
  icon_ = QIcon(node.firstChildElement("icon").text());
}
Пример #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;
}
Пример #7
0
void PicasaModel::listAllPhotos(KJob *job)
{
    QDomDocument document;
    document.setContent(m_datas[static_cast<KIO::Job*>(job)]);

    QDomNodeList entries = document.elementsByTagName("entry");
    m_expandable = false;
    m_photos.clear();
    for (int i = 0; i < entries.count(); i++) {

        QString id = entries.at(i).namedItem("id").toElement().text().split('/').last();
        QString published = entries.at(i).namedItem("published").toElement().text();
        QString updated = entries.at(i).namedItem("updated").toElement().text();
        QString title = entries.at(i).namedItem("title").toElement().text();
        QDomElement contentElement = entries.at(i).firstChildElement("content");
        QString link = contentElement.attribute("src");
        QString albumid = entries.at(i).namedItem("gphoto:albumid").toElement().text();
        QString width = entries.at(i).namedItem("gphoto:width").toElement().text();
        QString height = entries.at(i).namedItem("gphoto:height").toElement().text();
        QString size = entries.at(i).namedItem("gphoto:size").toElement().text();

        QDomNode mediaNode = entries.at(i).namedItem("media:group");
        QDomElement mediaElement = mediaNode.firstChildElement("media:thumbnail");
        QString thumb72 = mediaElement.attribute("url");
        mediaElement = mediaElement.nextSiblingElement("media:thumbnail");
        QString thumb144 = mediaElement.attribute("url");
        mediaElement = mediaElement.nextSiblingElement("media:thumbnail");
        QString thumb288 = mediaElement.attribute("url");

        Photo photo;
        photo.published = published;
        photo.updated = updated;
        photo.title = title;
        photo.link = link;
        photo.albumId = albumid;
        photo.width = width;
        photo.height = height;
        photo.size = size;

        photo.thumbnail72 = thumb72;
        photo.thumbnail144 = thumb144;
        photo.thumbnail288 = thumb288;

        m_photos.append(photo);
    }
    m_queries.remove(static_cast<KIO::Job*>(job));
    m_datas.remove(static_cast<KIO::Job*>(job));
    reset();

}
Пример #8
0
//API for query datebase, return a DOM tree's pointer.
bool queryDB(const QString &dep, const QString &arr, const QDate &date, QDomElement* &elem){
	QDomDocument doc;
	QFile file("Resources\\" + date.toString("yyyy-MM-dd") + ".xml");
	if(!file.open(QFile::ReadOnly))return false;
	if(!doc.setContent(&file))return false;
	QDomNode root = doc.documentElement();
	QDomElement ret;
	//search for the goal flights , create a DOM subtree in heap and return its pointer as a parameter
	for(ret = root.firstChildElement(); ret.attribute("name") != dep; ret = ret.nextSiblingElement());
	for(ret = ret.firstChildElement(); ret.attribute("name") != arr; ret = ret.nextSiblingElement());
	if(ret.isNull())return false;
	elem = new QDomElement(ret);
	file.close();
	return true;
}
Пример #9
0
QList< QPair < Mirrors::Mask, QUrl > >
Mirrors::parseMirrors(const QDomNode & node)
{
  QList< QPair < Mirrors::Mask, QUrl > > list;

  QDomElement p = node.firstChildElement("Mirror");
  while (!p.isNull()) {
    QUrl url(p.firstChildElement("mirrorpath").text());
    Mirrors::Mask mask = (Mirrors::Mask) p.firstChildElement("typemask").text().toUInt();

    list.append(QPair < Mirrors::Mask, QUrl >(mask, url));

    p = p.nextSiblingElement("Mirror");
  }
  return list;
}
Пример #10
0
bool QgsMeshLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &context )
{
  QgsDebugMsgLevel( QStringLiteral( "Datasource in QgsMeshLayer::readXml: %1" ).arg( mDataSource.toLocal8Bit().data() ), 3 );

  //process provider key
  QDomNode pkeyNode = layer_node.namedItem( QStringLiteral( "provider" ) );

  if ( pkeyNode.isNull() )
  {
    mProviderKey.clear();
  }
  else
  {
    QDomElement pkeyElt = pkeyNode.toElement();
    mProviderKey = pkeyElt.text();
  }

  QgsDataProvider::ProviderOptions providerOptions;
  if ( !setDataProvider( mProviderKey, providerOptions ) )
  {
    return false;
  }

  QDomElement elemExtraDatasets = layer_node.firstChildElement( QStringLiteral( "extra-datasets" ) );
  if ( !elemExtraDatasets.isNull() )
  {
    QDomElement elemUri = elemExtraDatasets.firstChildElement( QStringLiteral( "uri" ) );
    while ( !elemUri.isNull() )
    {
      QString uri = context.pathResolver().readPath( elemUri.text() );

      bool res = mDataProvider->addDataset( uri );
#ifdef QGISDEBUG
      QgsDebugMsg( QStringLiteral( "extra dataset (res %1): %2" ).arg( res ).arg( uri ) );
#else
      ( void )res; // avoid unused warning in release builds
#endif

      elemUri = elemUri.nextSiblingElement( QStringLiteral( "uri" ) );
    }
  }

  QString errorMsg;
  readSymbology( layer_node, errorMsg, context );

  return mValid; // should be true if read successfully
}
Пример #11
0
QDomNode XmlFloTransBase::findSiblingName(QDomNode &node,QString &name)
{
    if(name.isEmpty())
        return QDomNode();

    QDomNode parent = node.parentNode();
    QDomNode itnode = parent.firstChild();

    while(!itnode.isNull())
    {
        if(itnode.firstChildElement(XmlEleTagName).text() == name)
            return itnode;
        itnode = itnode.nextSibling();
    }

    return itnode;
}
Пример #12
0
void loader::loaduserinfo(QDomNode infos, account* newaccount){
    useraccount* temp=dynamic_cast<useraccount*>(newaccount);
    QString name=infos.firstChildElement(QString("name")).text(),
    surname=infos.firstChildElement(QString("surname")).text(),
    daybirth=infos.firstChildElement(QString("daybirth")).text(),
    monthbirth=infos.firstChildElement(QString("monthbirth")).text(),
    yearbirth=infos.firstChildElement(QString("yearbirth")).text(),
    birthplace=infos.firstChildElement(QString("birthplace")).text(),
    telnum=infos.firstChildElement(QString("telnum")).text(),
    email=infos.firstChildElement(QString("email")).text();
    userinfo* infotemp=new userinfo();
    if(!name.isEmpty()) infotemp->setName(name);
    if(!surname.isEmpty()) infotemp->setSurname(surname);
    if(!daybirth.isEmpty()&&!monthbirth.isEmpty()&&!yearbirth.isEmpty()) infotemp->setDate(QDate(yearbirth.toInt(), monthbirth.toInt(), daybirth.toInt()));
    if(!birthplace.isEmpty()) infotemp->setPlace(birthplace);
    if(!telnum.isEmpty()) infotemp->setNumber(telnum);
    if(!email.isEmpty()) infotemp->setEmail(email);
    temp->setinfo(*infotemp);
}
Пример #13
0
void FeedFetcher::handleRdfXml(QDomNode node) {
	QList<Tweet*> tweets;
	QDomNodeList children = node.childNodes();
	QDateTime startDate = QDateTime::currentDateTime();
	for (int x=0;x<children.count();x++) {
		QDomNode item = children.at(x);
//			QMessageBox::information(0,"Bleugh",item.nodeName());
		if (nodeName(item)=="channel") {
			QDomNode title = item.firstChildElement("title");
			if (!title.isNull())
				emit feedTitle(title.firstChild().nodeValue());
		} else if (nodeName(item)=="item") {
			FeedItem *tweet = new FeedItem();
			tweet->created_at=startDate.addSecs(-x);
			tweet->feed_item_date="";//tweet->created_at.toString();
			tweet->sourceUrl=url;
			QDomNodeList children2 = item.childNodes();
			for (int y=0;y<children2.count();y++) {
				QDomNode childItem = children2.at(y);
				if (nodeName(childItem)=="title") {
					tweet->message=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="guid") {
					tweet->id=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="description") {
					tweet->content=childItem.firstChild().nodeValue();
				} else if (nodeName(childItem)=="link") {
					tweet->url=childItem.firstChild().nodeValue();
					if (tweet->id=="")
						tweet->id=tweet->url;
				} else if (nodeName(childItem)=="pubDate") {
					//Thu Feb 19 00:20:20 +0000 2009
					QString date = childItem.firstChild().nodeValue();
//					tweet->feed_item_date = childItem.firstChild().nodeValue().left(26);
//						QString hour = dateStr.mid(20,5);
//						dateStr=dateStr.left(20)+dateStr.right(4);
//					tweet->created_at=QDateTime::fromString(dateStr,"ddd MMM dd HH:mm:ss +0000 yyyy");
					// Sat, 05 Sep 2009 14:51:00 GMT
					tweet->created_at=parseRdfDate(date.left(25));
				}
			}
			tweets.append(tweet);
		}
	}
	emit haveTweets(tweets);
}
QString XmlRelationCheckerCoreImpl::SearchGivenNodeTo(QDomNode nodeToCheck, const QString& key, XmlRelation* xmlRelation,
                                                   const QString& parentNumberBase, int number) const
{
    if(!nodeToCheck.isNull())
    {
        if(nodeToCheck.isElement() && !nodeToCheck.isComment())
        {
            //Initialize the identifiersNumber string with the base number
            QString identifierNumber = parentNumberBase;

            //If it's not empty is because it's the first node and it needn't the dot seprator
            if(!parentNumberBase.isEmpty())
            {
                identifierNumber.append('.');
            }

            //Attach the number
            identifierNumber.append(QString::number(number));

            //Controll if the node is a node to key
            const QString& nodeToKey = CheckIsNodeTo(nodeToCheck, xmlRelation);

            //Check this is the wanted node to
            if(key.compare(nodeToKey, Qt::CaseInsensitive) == 0)
            {
                return identifierNumber;
            }
            //Check the son
            else
            {
                const QString& sonIdentifier = SearchGivenNodeTo(nodeToCheck.firstChildElement(), key, xmlRelation, identifierNumber, 1);

                //If the son is the node searched
                if( ! sonIdentifier.isEmpty())
                {
                    //return the child identifier number
                    return sonIdentifier;
                }
            }
        }
        //Recursive call on the sibling
        return SearchGivenNodeTo(nodeToCheck.nextSiblingElement(), key, xmlRelation, parentNumberBase, number+1);
    }
    return "";
}
void AutomationPathSerializer::read_automation_path(const QDomNode &node, AutomationPath &path)
{
	auto point = node.firstChildElement();
	while (! point.isNull()) {
		if (point.tagName() == "point") {
			bool hasX = false;
			bool hasY = false;
			float x = point.attribute("x").toFloat(&hasX);
			float y = point.attribute("y").toFloat(&hasY);

			if (hasX && hasY) {
				path.add_point(x, y);
			}

		}
		point = point.nextSiblingElement();
	}
}
Пример #16
0
void EffectStackEdit::setFrameSize(QPoint p)
{
    m_frameSize = p;
    QDomNodeList namenode = m_params.elementsByTagName("parameter");
    for (int i = 0;i < namenode.count() ;i++) {
        QDomNode pa = namenode.item(i);
        QDomNode na = pa.firstChildElement("name");
        QString type = pa.attributes().namedItem("type").nodeValue();
        QString paramName = i18n(na.toElement().text().toUtf8().data());

        if (type == "geometry") {
            Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
            geom->setFrameSize(m_frameSize);
            break;
        }
    }

}
Пример #17
0
//-----------------------------------------------------------------------------
bool Root::parseDatabase(ServerPtr server, QDomNode& xmlnParent)
{
    Q_ASSERT(server);
    Q_ASSERT(!xmlnParent.isNull());

    DatabasePtr database = server->addDatabase();
    SubjectLocker locker(database.get());

    for (QDomElement xmln = xmlnParent.firstChildElement();
		 !xmln.isNull();
		 xmln = xmln.nextSiblingElement())
    {
		QString value = xmln.text();
        if (xmln.tagName() == QString::fromLatin1("name"))
            database->setName_(value);
        else if (xmln.tagName() == QString::fromLatin1("path"))
            database->setPath(value);
        else if (xmln.tagName() == QString::fromLatin1("charset"))
            database->setConnectionCharset(value);
        else if (xmln.tagName() == QString::fromLatin1("username"))
            database->setUsername(value);
        else if (xmln.tagName() == QString::fromLatin1("password"))
            database->setRawPassword(value);
        else if (xmln.tagName() == QString::fromLatin1("encrypted") && value == QString::fromLatin1("1"))
            database->getAuthenticationMode().setStoreEncryptedPassword();
        else if (xmln.tagName() == QString::fromLatin1("authentication"))
            database->getAuthenticationMode().setConfigValue(value);
        else if (xmln.tagName() == QString::fromLatin1("role"))
            database->setRole(value);
        else if (xmln.tagName() == QString::fromLatin1("id"))
        {
			bool isOk = false;
            unsigned long id = value.toULong(&isOk);
            if (isOk)
                database->setId(id);
        }
    }

    // make sure the database has an Id before Root::save() is called,
    // otherwise a new Id will be generated then, but the generator value
    // will not be stored because it's at the beginning of the file.
    database->getId();
    return true;
}
Пример #18
0
void CDeviceGarminBulk::readDeviceXml(const QString& filename)
{
    QFile file(filename);
    file.open(QIODevice::ReadOnly);

    QDomDocument dom;
    dom.setContent(&file);

    QDomElement device              = dom.firstChildElement("Device");
    QDomElement MassStorageMode     = device.firstChildElement("MassStorageMode");
    const QDomNodeList& DataTypes   = MassStorageMode.elementsByTagName("DataType");

    for(int i = 0; i < DataTypes.size(); i++)
    {
        QDomNode dataType       = DataTypes.at(i);
        QDomElement Name        = dataType.firstChildElement("Name");
        QDomElement File        = dataType.firstChildElement("File");
        QDomElement Location    = File.firstChildElement("Location");
        QDomElement Path        = Location.firstChildElement("Path");

        qDebug() << Name.text().simplified() << Path.text().simplified();

        QString name = Name.text().simplified();

        if(name == "GPSData")
        {
            pathGpx = Path.text().simplified();
        }
        else if(name == "UserDataSync")
        {
            pathGpx = Path.text().simplified();
        }
        else if(name == "GeotaggedPhotos")
        {
            pathPictures = Path.text().simplified();
        }
        else if(name == "GeocachePhotos")
        {
            pathSpoilers = Path.text().simplified();
        }

    }

}
void QgsVectorLayerJoinBuffer::readXml( const QDomNode& layer_node )
{
  mVectorJoins.clear();
  QDomElement vectorJoinsElem = layer_node.firstChildElement( "vectorjoins" );
  if ( !vectorJoinsElem.isNull() )
  {
    QDomNodeList joinList = vectorJoinsElem.elementsByTagName( "join" );
    for ( int i = 0; i < joinList.size(); ++i )
    {
      QDomElement infoElem = joinList.at( i ).toElement();
      QgsVectorJoinInfo info;
      info.joinFieldName = infoElem.attribute( "joinFieldName" ); // TODO[MD]: compatibility with 1.x?
      info.joinLayerId = infoElem.attribute( "joinLayerId" );
      info.targetFieldName = infoElem.attribute( "targetFieldName" ); // TODO[MD]: compatibility with 1.x?
      info.memoryCache = infoElem.attribute( "memoryCache" ).toInt();
      addJoin( info );
    }
  }
}
Пример #20
0
void CGroup::gotKicked(QDomNode message)
{

  if (message.nodeName() != "data") {
    qDebug( "Called gotKicked with wrong node. No data node.");
    return;
  }

  QDomNode e = message.firstChildElement();

  if (e.nodeName() != "text") {
    qDebug( "Called gotKicked with wrong node. No text node.");
    return;
  }

  QDomElement text = e.toElement();
  emit log("GroupManager", QString("You got kicked! Reason [nodename %1] : %2").arg(text.nodeName().toAscii().constData()).arg(text.text().toAscii().constData()));
//      QMessageBox::critical(this, "groupManager", QString("You got kicked! Reason: %1.").arg(text.text()));
}
Пример #21
0
Файл: ssu.cpp Проект: lbt/ssu
bool Ssu::setCredentials(QDomDocument *response){
  SsuCoreConfig *settings = SsuCoreConfig::instance();
  // generate list with all scopes for generic section, add sections
  QDomNodeList credentialsList = response->elementsByTagName("credentials");
  QStringList credentialScopes;
  for (int i=0;i<credentialsList.size();i++){
    QDomNode node = credentialsList.at(i);
    QString scope;

    QDomNamedNodeMap attributes = node.attributes();
    if (attributes.contains("scope")){
      scope = attributes.namedItem("scope").toAttr().value();
    } else {
      setError(tr("Credentials element does not have scope"));
      return false;
    }

    if (node.hasChildNodes()){
      QDomElement username = node.firstChildElement("username");
      QDomElement password = node.firstChildElement("password");
      if (username.isNull() || password.isNull()){
        setError(tr("Username and/or password not set"));
        return false;
      } else {
        settings->beginGroup("credentials-" + scope);
        settings->setValue("username", username.text());
        settings->setValue("password", password.text());
        settings->endGroup();
        settings->sync();
        credentialScopes.append(scope);
      }
    } else {
      setError("");
      return false;
    }
  }
  settings->setValue("credentialScopes", credentialScopes);
  settings->setValue("lastCredentialsUpdate", QDateTime::currentDateTime());
  settings->sync();
  emit credentialsChanged();

  return true;
}
Пример #22
0
QString LocalFileMng::processNode( QDomNode node, const QString& nodeName, bool bCanBeEmpty, bool bShouldExists )
{
	QDomElement element = node.firstChildElement( nodeName );

	if ( !node.isNull() && !element.isNull() ) {
		QString text = element.text();
		if( !text.isEmpty() ) {
			return text;
		} else {
			if ( !bCanBeEmpty ) {
				_WARNINGLOG( "node '" + nodeName + "' is empty" );
			}
		}
	} else {
		if (  bShouldExists ) {
			_WARNINGLOG( "node '" + nodeName + "' is not found" );
		}
	}
	return NULL;
}
Пример #23
0
bool KDReports::XmlParser::parseTableContents( KDReports::TableElement& table, const QDomNode& tableNode, KDReports::ReportBuilder& builder, bool inHeader, bool inFooter )
{
    // Loop over elements
    for ( QDomElement element = tableNode.firstChildElement(); !element.isNull();
          element = element.nextSiblingElement() ) {
        if ( testForErrorAndFillErrorDetails() )
            return false;

        const QString name = element.tagName();
        if( name == QLatin1String( "cell" ) ) {
            const int row = element.attribute( QLatin1String( "row" ) ).toInt();
            const int column = element.attribute( QLatin1String( "column" ) ).toInt();
            const int rowSpan = element.attribute( QLatin1String( "rowspan" ), QLatin1String("1") ).toInt();
            const int colSpan = element.attribute( QLatin1String( "colspan" ), QLatin1String("1") ).toInt();
            KDReports::Cell& cell = table.cell( row, column );
            cell.setRowSpan( rowSpan );
            cell.setColumnSpan( colSpan );
            const QColor bgColor = KDReports::XmlHelper::readBackground( element );
            if( bgColor.isValid() )
                cell.setBackground( bgColor );
            CellReportBuilder cellReportBuilder( cell, builder.contentDocumentData(),
                                                 builder.contentDocumentCursor(),
                                                 builder.report() );
            cellReportBuilder.copyStateFrom( builder );

            if ( m_xmlElementHandler && !m_xmlElementHandler->startCell( cell, element ) )
                continue;

            if ( !processNode( element, &cellReportBuilder, inHeader, inFooter ) )
                return false;

            if ( m_xmlElementHandler && !m_xmlElementHandler->endCell( cell, element ) )
                continue;
        }
    }

    if ( testForErrorAndFillErrorDetails() )
        return false;

    return true;
}
Пример #24
0
void FadeCurve::set_shape(QString shapeName)
{
	QDomDocument doc("FadeShapes");
	
	if (defaultShapes.contains(shapeName)) {
		QFile file(":/fadeshapes");
		
		if (!file.open(QIODevice::ReadOnly)) {
			printf("Could not open fadeshapes file!!\n");
			return;
		}
		if (!doc.setContent(&file)) {
			file.close();
			printf("Could not set QDomDocument content!\n");
			return;
		}
		file.close();
	} else {
		// Load from custom saved fades
	}
	

	QDomElement root = doc.documentElement();
	QDomNode node = root.firstChildElement(m_sType);
	
	QDomElement fadeElement = node.firstChildElement(shapeName);
	
	if (fadeElement.isNull()) {
		printf("%s does not exist?????\n", shapeName.toAscii().data());
		return;
	}
	
	CommandGroup* group = new CommandGroup(this, tr("Fade Preset"));
	
	group->add_command(new FadeBend(this, fadeElement.attribute( "bendfactor", "0.0" ).toDouble()));
	group->add_command(new FadeStrength(this, fadeElement.attribute( "strengthfactor", "0.5" ).toDouble()));
	
	TCommand::process_command(group);
	
	emit stateChanged();
}
Пример #25
0
int LocalFileMng::readXmlInt( QDomNode node , const QString& nodeName, int defaultValue, bool bCanBeEmpty, bool bShouldExists, bool tinyXmlCompatMode)
{
	QLocale c_locale = QLocale::c();
 	QDomElement element = node.firstChildElement( nodeName );
	
	if( !node.isNull() && !element.isNull() ){
		if(  !element.text().isEmpty() ){
			return c_locale.toInt( element.text() );
		} else {
			if ( !bCanBeEmpty ) {
				//_WARNINGLOG( "Using default value in " + nodeName );
			}
			return defaultValue;
		}
	} else {	
		if(  bShouldExists ){
			//_WARNINGLOG( "'" + nodeName + "' node not found" );
		}
		return defaultValue;
	}
}
Пример #26
0
void QgsMapSettings::readXML( QDomNode& theNode )
{
  // set units
  QDomNode mapUnitsNode = theNode.namedItem( "units" );
  QGis::UnitType units = QgsXmlUtils::readMapUnits( mapUnitsNode.toElement() );
  setMapUnits( units );

  // set projections flag
  QDomNode projNode = theNode.namedItem( "projections" );
  setCrsTransformEnabled( projNode.toElement().text().toInt() );

  // set destination CRS
  QgsCoordinateReferenceSystem srs;
  QDomNode srsNode = theNode.namedItem( "destinationsrs" );
  srs.readXML( srsNode );
  setDestinationCrs( srs );

  // set extent
  QDomNode extentNode = theNode.namedItem( "extent" );
  QgsRectangle aoi = QgsXmlUtils::readRectangle( extentNode.toElement() );
  setExtent( aoi );

  // set rotation
  QDomNode rotationNode = theNode.namedItem( "rotation" );
  QString rotationVal = rotationNode.toElement().text();
  if ( ! rotationVal.isEmpty() )
  {
    double rot = rotationVal.toDouble();
    setRotation( rot );
  }

  //render map tile
  QDomElement renderMapTileElem = theNode.firstChildElement( "rendermaptile" );
  if ( !renderMapTileElem.isNull() )
  {
    setFlag( QgsMapSettings::RenderMapTile, renderMapTileElem.text() == "1" ? true : false );
  }

  mDatumTransformStore.readXML( theNode );
}
Пример #27
0
bool LocalFileMng::readXmlBool( QDomNode node , const QString& nodeName, bool defaultValue, bool bShouldExists, bool tinyXmlCompatMode)
{
 	QDomElement element = node.firstChildElement( nodeName );
	
	if( !node.isNull() && !element.isNull() ){
		if(  !element.text().isEmpty() ){
			if( element.text() == "true"){
				return true;
			} else {
				return false;
			}
		} else {
			//_WARNINGLOG( "Using default value in " + nodeName );
			return defaultValue;
		}
	} else {	
		if(  bShouldExists ){
			//_WARNINGLOG( "'" + nodeName + "' node not found" );
		}
		return defaultValue;
	}
}
Пример #28
0
void XmlStnInterface::readStratigraphy( const QDomNode &stratRoot, GEOLIB::StationBorehole* borehole )
{
	//borehole->addSoilLayer((*borehole)[0], (*borehole)[1], (*borehole)[2], "");
	double depth_check((*borehole)[2]);
	QDomElement horizon = stratRoot.firstChildElement();
	while (!horizon.isNull())
	{
		if (horizon.hasAttribute("id") && horizon.hasAttribute("x") &&
		    horizon.hasAttribute("y") && horizon.hasAttribute("z"))
		{
			std::string horizonName("[NN]");

			QDomNodeList horizonFeatures = horizon.childNodes();
			for(int i = 0; i < horizonFeatures.count(); i++)
				if (horizonFeatures.at(i).nodeName().compare("name") == 0)
					horizonName = horizonFeatures.at(i).toElement().text().toStdString();
				/* add other horizon features here */

			double depth (strtod((horizon.attribute("z")).toStdString().c_str(), 0));
			if (fabs(depth - depth_check) > std::numeric_limits<double>::epsilon()) // skip soil-layer if its thickness is zero
			{
				borehole->addSoilLayer(strtod((horizon.attribute("x")).toStdString().c_str(), 0),
									   strtod((horizon.attribute("y")).toStdString().c_str(), 0),
									   depth,
									   horizonName);
				depth_check = depth;
			}
			else
				std::cout << "Warning: Skipped layer \"" << horizonName << "\" in borehole \"" 
					      << borehole->getName() << "\" because of thickness 0.0." << "\n";
		}
		else
			std::cout <<
			"XmlStnInterface::readStratigraphy() - Attribute missing in <horizon> tag ..."
			          << "\n";
		horizon = horizon.nextSiblingElement();
	}
}
Пример #29
0
void CGroup::renameChar(QDomNode blob)
{
  if (blob.nodeName() != "data") {
    qDebug( "Called renameChar with wrong node. No data node.");
    return;
  }

  QDomNode e = blob.firstChildElement();

//      QDomElement root = node.toElement();
  QString oldname = e.toElement().attribute("oldname");
  QString newname = e.toElement().attribute("newname");

  emit log("GroupManager", QString("Renaming a char from %1 to %2").arg(oldname.toAscii().constData()).arg(newname.toAscii().constData()));

  CGroupChar *ch;
  ch = getCharByName(oldname.toAscii());
  if (ch == NULL)
    return;

  ch->setName(newname.toAscii());
  ch->updateLabels();
}
Пример #30
0
void WebResourceProvider::importNodeIntoDB( const QDomNode & _n,
											ResourceItem::Relation * _parent )
{
	QDomNode n = _n;
	while( !n.isNull() )
	{
		QString path = n.firstChildElement( "dir" ).text();
		ResourceItem::Type type = ResourceItem::TypeUnknown;

		if( !path.isEmpty() )
		{
			path += "/";
		}
		if( n.nodeName() == "webresources" )
		{
			type = ResourceItem::TypeDirectory;
		}

		ResourceItem * item =
			new ResourceItem( this,
				n.firstChildElement( "name" ).text(),
				type,
				ResourceItem::BaseURL,
				path,
				n.firstChildElement( "hash" ).text(),
				n.firstChildElement( "author" ).text(),
				n.firstChildElement( "tags" ).text(),
				n.firstChildElement( "size" ).text().toInt(),
				QDateTime::fromString(
					n.firstChildElement( "date" ).text(), Qt::ISODate ) );
		database()->addItem( item );

		ResourceItem::Relation * relation = addRelation( _parent, item );
		if( n.nodeName() != "file" )
		{
			importNodeIntoDB( n.firstChild(), relation );
		}
		n = n.nextSibling();
	}
}