当前位置: 首页>>代码示例>>C++>>正文


C++ QDomElement类代码示例

本文整理汇总了C++中QDomElement的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement类的具体用法?C++ QDomElement怎么用?C++ QDomElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QDomElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MIRO_ASSERT

void
DeferredParameterEdit::setXML()
{
  QDomNode tmpNode = tmpParentNode_.firstChild();

  // no edit -> nothing to be done
  if (!modified_)
    return;

  // delete entry if edit field is empty
  if (tmpNode.isNull() || 
      tmpNode.firstChild().isNull()) {

    if (!node_.isNull()) {
      parentNode_.removeChild(node_);
      delete item_;
    }
    else {
      modified_ = false;
    }
    return;
  }  

  // crete a node if necessary
  if (node_.isNull()) {

    MIRO_ASSERT(!parentNode_.ownerDocument().isNull());
    QDomElement e = parentNode_.ownerDocument().createElement(XML_TAG_PARAMETER);

    e.setAttribute(XML_ATTRIBUTE_KEY, name());
    node_ = parentNode_.appendChild(e);

    MIRO_ASSERT(!node_.isNull());
  }

  //--------------------------------------
  // replace node by new content

  // remember the predecessor
  QListViewItem * pre = NULL;
  if (item_) {
    QListViewItem * parent = item_->listViewItem()->parent();
    if (parent != NULL) {
      pre = parent->firstChild();
      while (pre != NULL) {
	if (pre->nextSibling() == item_->listViewItem())
	  break;
	pre = pre->nextSibling();
      }
    }
    // delete the current content
    delete item_;
  }

  // replace the xml subtree
  QDomNode node = tmpNode.cloneNode();
  node_.parentNode().replaceChild(node, node_);
  node_ = node;

  // reconstruct the listview if available
  if (parentItem_) {
    item_ = NULL;
    QString typeName = parameter_.type_;
    if (type_ == NESTED_PARAMETER) {
      Miro::CFG::Type const * const parameterType =
	ConfigFile::instance()->description().getType(typeName);
      
      if (parameterType == NULL) {
	throw QString("Parameter description for " + typeName +
		      " not found.\nCheck whether the relevant description file is loaded.");
      }
    
      item_ = new CompoundParameter(*parameterType,
				    node,
				    parentItem_->listViewItem(), pre,
				    parentItem_, name());
    }
    else if (type_ == VECTOR ||
	     type_ == SET) {
      item_ = new ParameterList(parameter_, 
				node,
				parentItem_->listViewItem(), pre,
				parentItem_, name());
    }
    if (item_ != NULL)
      dynamic_cast<ParameterXML *>(item_)->init();
  }
}
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:88,代码来源:DeferredParameterEdit.cpp

示例2: signalLoginProgress

void SmugTalker::parseResponseLogin(const QByteArray& data)
{
    int errCode = -1;
    QString errMsg;

    emit signalLoginProgress(3);
    QDomDocument doc("login");
    if (!doc.setContent(data))
        return;

    kDebug() << "Parse Login response:" << endl << data;

    QDomElement e = doc.documentElement();
    for (QDomNode node = e.firstChild();
         !node.isNull();
         node = node.nextSibling())
    {
        if (!node.isElement())
            continue;

        e = node.toElement();

        if (e.tagName() == "Login")
        {
            m_user.accountType = e.attribute("AccountType");
            m_user.fileSizeLimit = e.attribute("FileSizeLimit").toInt();

            for (QDomNode nodeL = e.firstChild();
                 !nodeL.isNull();
                 nodeL = nodeL.nextSibling())
            {
                if (!nodeL.isElement())
                    continue;

                e = nodeL.toElement();

                if (e.tagName() == "Session")
                {
                    m_sessionID = e.attribute("id");
                }
                else if (e.tagName() == "User")
                {
                    m_user.nickName = e.attribute("NickName");
                    m_user.displayName = e.attribute("DisplayName");
                }
            }
            errCode = 0;
        }
        else if (e.tagName() == "err")
        {
            errCode = e.attribute("code").toInt();
            errMsg  = e.attribute("msg");
            kDebug() << "Error:" << errCode << errMsg;
        }
    }

    emit signalLoginProgress(4);
    if (errCode != 0) // if login failed, reset user properties
    {
        m_sessionID.clear();
        m_user.clear();
    }

    emit signalBusy(false);
    emit signalLoginDone(errCode, errorToText(errCode, errMsg));
}
开发者ID:UIKit0,项目名称:digikam-2012-kipi-plugins,代码行数:66,代码来源:smugtalker.cpp

示例3: doc

void SmugTalker::parseResponseListPhotos(const QByteArray& data)
{
    int errCode = -1;
    QString errMsg;
    QDomDocument doc("images.get");
    if (!doc.setContent(data))
        return;

    kDebug() << "Parse Photos response:" << endl << data;

    QList <SmugPhoto> photosList;
    QDomElement e = doc.documentElement();

    for (QDomNode node = e.firstChild();
         !node.isNull();
         node = node.nextSibling())
    {
        if (!node.isElement())
            continue;

        e = node.toElement();

        if (e.tagName() == "Images")
        {
            for (QDomNode nodeP = e.firstChild();
                 !nodeP.isNull();
                 nodeP = nodeP.nextSibling())
            {
                if (!nodeP.isElement())
                    continue;

                e = nodeP.toElement();

                if (e.tagName() == "Image")
                {
                    SmugPhoto photo;
                    photo.id = e.attribute("id").toInt();
                    photo.key = e.attribute("Key");
                    photo.caption = htmlToText(e.attribute("Caption"));
                    photo.keywords = htmlToText(e.attribute("Keywords"));
                    photo.thumbURL = e.attribute("ThumbURL");
                    // try to get largest size available
                    if (e.hasAttribute("Video1280URL"))
                        photo.originalURL = e.attribute("Video1280URL");
                    else if (e.hasAttribute("Video960URL"))
                        photo.originalURL = e.attribute("Video960URL");
                    else if (e.hasAttribute("Video640URL"))
                        photo.originalURL = e.attribute("Video640URL");
                    else if (e.hasAttribute("Video320URL"))
                        photo.originalURL = e.attribute("Video320URL");
                    else if (e.hasAttribute("OriginalURL"))
                        photo.originalURL = e.attribute("OriginalURL");
                    else if (e.hasAttribute("X3LargeURL"))
                        photo.originalURL = e.attribute("X3LargeURL");
                    else if (e.hasAttribute("X2LargeURL"))
                        photo.originalURL = e.attribute("X2LargeURL");
                    else if (e.hasAttribute("XLargeURL"))
                        photo.originalURL = e.attribute("XLargeURL");
                    else if (e.hasAttribute("LargeURL"))
                        photo.originalURL = e.attribute("LargeURL");
                    else if (e.hasAttribute("MediumURL"))
                        photo.originalURL = e.attribute("MediumURL");
                    else if (e.hasAttribute("SmallURL"))
                        photo.originalURL = e.attribute("SmallURL");
                    photosList.append(photo);
                }
            }
            errCode = 0;
        }
        else if (e.tagName() == "err")
        {
            errCode = e.attribute("code").toInt();
            errMsg  = e.attribute("msg");
            kDebug() << "Error:" << errCode << errMsg;
        }
    }

    if (errCode == 15)  // 15: empty list
        errCode = 0;
    emit signalBusy(false);
    emit signalListPhotosDone(errCode, errorToText(errCode, errMsg),
                              photosList);
}
开发者ID:UIKit0,项目名称:digikam-2012-kipi-plugins,代码行数:83,代码来源:smugtalker.cpp

示例4: updateDomElement

void Bookmarks::updateDomElement(QTreeWidgetItem* item, int column)
{
    QDomElement element = m_domElementForItem.value(item);
    if (!element.isNull()) {
        if (column == 0) {
            QDomElement oldTitleElement = element.firstChildElement("title");
            QDomElement newTitleElement = m_domDocument.createElement("title");

            QDomText newTitleText = m_domDocument.createTextNode(item->text(0));
            newTitleElement.appendChild(newTitleText);

            element.replaceChild(newTitleElement, oldTitleElement);
        }
        else {
            if (element.tagName() == "bookmark") {
                QDomElement oldDescElement = element.firstChildElement("desc");
                QDomElement newDescElement = m_domDocument.createElement("desc");
                QDomText newDesc = m_domDocument.createTextNode(item->text(1));//setAttribute("href", item->text(1));
                newDescElement.appendChild(newDesc);
                element.replaceChild(newDescElement, oldDescElement);
                element.setAttribute("href", item->data(1, Qt::UserRole).toString());
            }
        }
    }
}
开发者ID:mkhoeini,项目名称:Saaghar,代码行数:25,代码来源:bookmarks.cpp

示例5: findChildNode

bool Bookmarks::updateBookmarkState(const QString &type, const QVariant &data, bool state)
{
    if (type == "Verses" || type == tr("Verses")) {
        QDomElement verseNode = findChildNode("folder", "Verses");
        if (verseNode.isNull()) {
            QDomElement root = m_domDocument.createElement("folder");
            QDomElement child = m_domDocument.createElement("title");
            QDomText newTitleText = m_domDocument.createTextNode(tr("Verses"));
            root.setAttribute("folded", "no");
            child.appendChild(newTitleText);
            root.appendChild(child);
            m_domDocument.documentElement().appendChild(root);
            verseNode = root;
            parseFolderElement(root);
        }

        QTreeWidgetItem* parentItem = m_domElementForItem.key(verseNode);
        //REMOVE OPERATION
        if (!state) {
            int countOfChildren = parentItem->childCount();
            int numOfDel = 0;
            bool allMatchedRemoved = true;
            for (int i = 0; i < countOfChildren; ++i) {
                QTreeWidgetItem* childItem = parentItem->child(i);
                if (!childItem) {
                    continue;
                }

                if (childItem->data(0, Qt::UserRole).toString() == data.toStringList().at(0) + "|" + data.toStringList().at(1)) {
                    ++numOfDel;

                    if (unBookmarkItem(childItem)) {
                        --i; //because one of children was deleted
                        --countOfChildren;
                    }
                    else {
                        allMatchedRemoved = false;
                    }
                }
            }

            //allMatchedRemoved is false when at least one of
            // matched items are not deleted!!
            return allMatchedRemoved;
        }

        QDomElement bookmark = m_domDocument.createElement("bookmark");
        QDomElement bookmarkTitle = m_domDocument.createElement("title");
        QDomElement bookmarkDescription = m_domDocument.createElement("desc");
        QDomElement bookmarkInfo = m_domDocument.createElement("info");
        QDomElement infoMetaData = m_domDocument.createElement("metadata");

        infoMetaData.setAttribute("owner", "http://saaghar.pozh.org");
        QDomText bookmarkSaagharMetadata = m_domDocument.createTextNode(data.toStringList().at(0) + "|" + data.toStringList().at(1));
        infoMetaData.appendChild(bookmarkSaagharMetadata);
        bookmarkInfo.appendChild(infoMetaData);
        bookmark.appendChild(bookmarkTitle);
        bookmark.appendChild(bookmarkDescription);
        bookmark.appendChild(bookmarkInfo);
        verseNode.appendChild(bookmark);

        qDebug() << data << state;
        QDomElement firstChild = m_domDocument.documentElement().firstChildElement("folder");
        firstChild.text();
        QTreeWidgetItem* item = createItem(bookmark, parentItem);
        item->setIcon(0, m_bookmarkIcon);

        QString title = data.toStringList().at(2);
        item->setText(0, title);
        item->setToolTip(0, title);
        item->setData(0, Qt::UserRole, data.toStringList().at(0) + "|" + data.toStringList().at(1));
        item->setData(1, Qt::UserRole, data.toStringList().at(3));
        if (data.toStringList().size() == 5) {
            item->setText(1, data.toStringList().at(4));
            item->setToolTip(1, data.toStringList().at(4));
        }

        if (parentItem->childCount() == 1) {
            resizeColumnToContents(0);
            resizeColumnToContents(1);
        }

        return true;
    }

    //an unknown type!!
    return false;
}
开发者ID:mkhoeini,项目名称:Saaghar,代码行数:88,代码来源:bookmarks.cpp

示例6: sosLayer

QgsVectorLayer* QgsRemoteOWSBuilder::sosLayer( const QDomElement& remoteOWSElem, const QString& url, const QString& layerName, QList<QgsMapLayer*>& layersToRemove, bool allowCaching ) const
{
  //url for sos provider is: "url=... method=... xml=....
  QString method = remoteOWSElem.attribute( "method", "POST" ); //possible GET/POST/SOAP

  //search for <LayerSensorObservationConstraints> node that is sibling of remoteOSW element
  //parent element of <remoteOWS> (normally <UserLayer>)
  QDomElement parentElem = remoteOWSElem.parentNode().toElement();
  if ( parentElem.isNull() )
  {
    return 0;
  }


  //Root element of the request (can be 'GetObservation' or 'GetObservationById' at the moment, probably also 'GetFeatureOfInterest' or 'GetFeatureOfInterestTime' in the future)
  QDomElement requestRootElem;

  QDomNodeList getObservationNodeList = parentElem.elementsByTagName( "GetObservation" );
  if ( getObservationNodeList.size() > 0 )
  {
    requestRootElem = getObservationNodeList.at( 0 ).toElement();
  }
  else //GetObservationById?
  {
    QDomNodeList getObservationByIdNodeList = parentElem.elementsByTagName( "GetObservationById" );
    if ( getObservationByIdNodeList.size() > 0 )
    {
      requestRootElem = getObservationByIdNodeList.at( 0 ).toElement();
    }
  }

  if ( requestRootElem.isNull() )
  {
    return 0;
  }

  QDomDocument requestDoc;
  QDomNode newDocRoot = requestDoc.importNode( requestRootElem, true );
  requestDoc.appendChild( newDocRoot );

  QString providerUrl = "url=" + url + " method=" + method + " xml=" + requestDoc.toString();

  //check if layer is already in cache
  QgsVectorLayer* sosLayer = 0;
  if ( allowCaching )
  {
    sosLayer = dynamic_cast<QgsVectorLayer*>( QgsMSLayerCache::instance()->searchLayer( providerUrl, layerName ) );
    if ( sosLayer )
    {
      return sosLayer;
    }
  }

  sosLayer = new QgsVectorLayer( providerUrl, "Sensor layer", "SOS" );

  if ( !sosLayer->isValid() )
  {
    delete sosLayer;
    return 0;
  }
  else
  {
    if ( allowCaching )
    {
      QgsMSLayerCache::instance()->insertLayer( providerUrl, layerName, sosLayer );
    }
    else
    {
      layersToRemove.push_back( sosLayer );
    }
  }
  return sosLayer;
}
开发者ID:Br1ndavoine,项目名称:QGIS,代码行数:73,代码来源:qgsremoteowsbuilder.cpp

示例7: filterProperties

void CDiagramItem::toXml(QDomElement &n)
{
	QMetaObject				*meta = NULL;
  QMetaProperty			prop;
	QDomDocument			doc;
	QDomElement				ext, childNode;
	QList<QByteArray>		props;
  QStringList				filtersOut, filtersIn;
	CDiagramSerializable	*inst = NULL;

    filtersIn = filterProperties();
    filtersOut  << "width"
                << "height"
                << "x"
                << "y"
                << "z"
                << "pos"
                << "size"
                << "parent"
                << "effect"
                << "children"
                << "layout"
                << "palette";

	doc = n.ownerDocument();
	ext = doc.createElement( QString("ext") );
	childNode = doc.createElement( QString("children") );

	n.setAttribute( QString("type"), interType());
	n.setAttribute( QString("category"), category() );
	n.setAttribute( QString("name"), name() );
	n.setAttribute( QString("libCategory"), libraryCategory() );
	n.setAttribute( QString("libName"), libraryName() );
	n.setAttribute( QString("id"), QString::number(id()) );
	
	meta = const_cast<QMetaObject*>(metaObject());
	for (int i = 0; i < meta->propertyCount(); ++i)
	{
		QString		propName;
		QByteArray	b;
		QDataStream s(&b, QIODevice::WriteOnly);

		prop = meta->property(i);
		propName = QString(prop.name());
        if (filtersIn.isEmpty())
        {
            if (filtersOut.contains(propName, Qt::CaseInsensitive) || prop.userType() == 0)
            {
                continue;
            }
        }
        else
        {
            if (!filtersIn.contains(propName, Qt::CaseInsensitive))
            {
                continue;
            }
        }
		
		if (prop.isValid() && prop.isReadable())
		{
			s <<  prop.read(this);
			QDomElement	e = doc.createElement(QString("property"));
			e.setAttribute( QString("name"), QString(prop.name()) );
			e.setAttribute( QString("type"), QString(prop.typeName()) );
			e.appendChild( doc.createTextNode( QString(b.toBase64() ) ) );
			n.appendChild(e);
			// qDebug() << "save->name:" << prop.name() << " value:" << prop.read(this);
		}
	}
	
	props = dynamicPropertyNames();
	for (int i = 0; i < props.length(); ++i)
	{
		inst = RS_PROPERTY(props.at(i).constData());
		// inst = property(props.at(i).constData()).value<CDiagramSerializable*>();
		if (inst)
		{
			QDomElement	 c = doc.createElement(QString("child"));
			c.setAttribute( QString("dynamicProperty"), QString(props.at(i).constData()) );
			inst->toXml(c);
			childNode.appendChild(c);
		}
	}
	n.appendChild(childNode);

	extToXml( ext );
	n.appendChild( ext );
}
开发者ID:jetcodes,项目名称:JetMind,代码行数:89,代码来源:CDiagramItem.cpp

示例8: doc

void Mesa::importXML(const QString val) {

    QDomDocument doc ( "mydocument" );

    if ( !doc.setContent ( val ) ) {
	
        return;
    } // end if

    QDomElement docElem = doc.documentElement();
    QDomElement principal = docElem.firstChildElement ( "IMAGEN" );
    m_filename = principal.text();

    QDomElement nombre = docElem.firstChildElement ( "NOMBRE" );
    m_nombreMesa = nombre.text();

    QDomElement pantalla = docElem.firstChildElement ( "PANTALLA" );
    m_pantalla = pantalla.text();
    
    
    QDomElement posx = docElem.firstChildElement ( "POSX" );
    QDomElement posy = docElem.firstChildElement ( "POSY" );

    QDomElement xscale = docElem.firstChildElement ( "XSCALE" );
    QDomElement yscale = docElem.firstChildElement ( "YSCALE" );
    m_XScale = xscale.text().toInt();
    m_YScale = yscale.text().toInt();
    setGeometry(posx.text().toInt(),posy.text().toInt(),m_XScale+1 , m_YScale+1 );
    setFixedSize(m_XScale+10 ,m_YScale+10);

    repaint();
}
开发者ID:trifolio6,项目名称:Bulmages,代码行数:32,代码来源:mesas.cpp

示例9: saveGradient

static QDomElement saveGradient(QDomDocument &doc, const QGradient &gradient)
{
    QDomElement gradElem = doc.createElement(QLatin1String("gradientData"));

    const QGradient::Type type = gradient.type();
    gradElem.setAttribute(QLatin1String("type"), gradientTypeToString(type));
    gradElem.setAttribute(QLatin1String("spread"), gradientSpreadToString(gradient.spread()));
    gradElem.setAttribute(QLatin1String("coordinateMode"), gradientCoordinateModeToString(gradient.coordinateMode()));

    QGradientStops stops = gradient.stops();
    QVectorIterator<QGradientStop > it(stops);
    while (it.hasNext())
        gradElem.appendChild(saveGradientStop(doc, it.next()));

    if (type == QGradient::LinearGradient) {
        const QLinearGradient &g = *static_cast<const QLinearGradient *>(&gradient);
        gradElem.setAttribute(QLatin1String("startX"), QString::number(g.start().x()));
        gradElem.setAttribute(QLatin1String("startY"), QString::number(g.start().y()));
        gradElem.setAttribute(QLatin1String("endX"), QString::number(g.finalStop().x()));
        gradElem.setAttribute(QLatin1String("endY"), QString::number(g.finalStop().y()));
    } else if (type == QGradient::RadialGradient) {
        const QRadialGradient &g = *static_cast<const QRadialGradient *>(&gradient);
        gradElem.setAttribute(QLatin1String("centerX"), QString::number(g.center().x()));
        gradElem.setAttribute(QLatin1String("centerY"), QString::number(g.center().y()));
        gradElem.setAttribute(QLatin1String("focalX"), QString::number(g.focalPoint().x()));
        gradElem.setAttribute(QLatin1String("focalY"), QString::number(g.focalPoint().y()));
        gradElem.setAttribute(QLatin1String("radius"), QString::number(g.radius()));
    } else if (type == QGradient::ConicalGradient) {
        const QConicalGradient &g = *static_cast<const QConicalGradient*>(&gradient);
        gradElem.setAttribute(QLatin1String("centerX"), QString::number(g.center().x()));
        gradElem.setAttribute(QLatin1String("centerY"), QString::number(g.center().y()));
        gradElem.setAttribute(QLatin1String("angle"), QString::number(g.angle()));
    }

    return gradElem;
}
开发者ID:fluxer,项目名称:katie,代码行数:36,代码来源:qtgradientutils.cpp

示例10: clean

int LoadController::exec()
{
    clean();
    QFile zeus (filename());
    if(!zeus.open(QIODevice::ReadOnly))
    {
        return -1;
    }

    QDomDocument hera;
    if(!hera.setContent(&zeus))
    {
        return -2;
    }

    QDomElement athena = hera.documentElement();
    QDomNodeList hermes = athena.elementsByTagName("user");

    for(int appolon = 0; appolon < hermes.size(); appolon++)
    {
        QDomElement gaia = hermes.at(appolon).toElement();
        UserSPointer ares = UserController::user(cypher(gaia.elementsByTagName("username").at(0).toElement().text(), 57));
        if(ares)
            ares->setType((User::UserType)cypher(gaia.elementsByTagName("type").at(0).toElement().text(), 95).toInt());
    }


    hermes = athena.elementsByTagName("category");

    for(int apollon = 0; apollon < hermes.size(); apollon++)
    {
        if(hermes.at(apollon).parentNode().toElement().tagName() != "subCategory")
        {
            CategorySPointer ares(new Category);
            QDomElement aphrodite = hermes.at(apollon).toElement();
            ares->load(aphrodite);
            if(!categories().contains(ares->name()))
                addCategory(ares);
        }
    }
    hermes = athena.elementsByTagName("entry");

    for(int apollon = 0; apollon < hermes.size(); apollon++)
    {
        if(hermes.at(apollon).parentNode().toElement().tagName() != "subMedia")
        {
            MediaSPointer ares(new Media);
            QDomElement aphrodite = hermes.at(apollon).toElement();
            ares->load(aphrodite, AbstractController::categories());
            if(!medias().contains(qMakePair(ares->category()->name(),ares->name())))
            {
                ares->category()->addAssociations(ares);
                addMedia(ares);
            }
        }
    }

    zeus.close();

    return 0;
}
开发者ID:Chewnonobelix,项目名称:ProduitMedia,代码行数:61,代码来源:loadcontroller.cpp

示例11: file

void DistroMesas::importXML(const QString val) {
  QFile file ( g_confpr->value( CONF_DIR_USER ) + "distromesas_" + mainCompany()->dbName() + ".cfn" );

    if (file.exists()) {
        if ( !file.open ( QIODevice::ReadOnly ) ) {
            
            return;
        } // end if
        QString result (file.readAll());
        file.close(); 


    QDomDocument doc ( "mydocument" );

    if ( !doc.setContent ( result ) ) {
	
        return;
    } // end if

    QDomElement docElem = doc.documentElement();
    QDomElement principal = docElem.firstChildElement ( "BACKGROUND" );
    m_background = principal.text();

    principal = docElem.firstChildElement ( "ESCALA" );
    g_escala = principal.text().toInt();


    QDomNodeList nodos = docElem.elementsByTagName ( "MESA" );
    int i = 0;
    while (i < nodos.count() ) {
        QDomNode ventana = nodos.item ( i++ );
        QDomElement e1 = ventana.toElement(); /// try to convert the node to an element.
        if ( !e1.isNull() ) { /// the node was really an element.
            QString nodoText = e1.text();
            /// Pasamos el XML a texto para poder procesarlo como tal.
            QString result;
            QTextStream stream ( &result );
            ventana.save(stream,5);

            Mesa *mesa = new Mesa((BtCompany *) mainCompany(), mui_widget);
            mesa->importXML(result);
	    
	    if (! m_listapantallas.contains(mesa->m_pantalla)) {
	        if (m_pantallaactual == "") {
		    m_pantallaactual = mesa->m_pantalla;
		} // end if
		m_listapantallas.append(mesa->m_pantalla);
		QToolButton *but = new QToolButton(this);
		but->setObjectName("p_"+mesa->m_pantalla);
		but->setText(mesa->m_pantalla);
		but->setMinimumHeight(42);
		but->setMinimumWidth(42);
		but->setCheckable(TRUE);
		mui_espaciopantallas->addWidget(but);
		connect(but, SIGNAL(clicked()), this, SLOT(cambiarPantalla()));
	    } // end if
	    if (mesa->m_pantalla == m_pantallaactual) 
		mesa->show();

        } // end if
    } // end while

} // end if

}
开发者ID:trifolio6,项目名称:Bulmages,代码行数:65,代码来源:mesas.cpp

示例12: fromOpenIndyXML

/*!
 * \brief Ellipse::fromOpenIndyXML
 * \param xmlElem
 * \return
 */
bool Ellipse::fromOpenIndyXML(QDomElement &xmlElem){

    bool result = Geometry::fromOpenIndyXML(xmlElem);

    if(result){

        //set ellipse attributes
        QDomElement a = xmlElem.firstChildElement("a");
        QDomElement b = xmlElem.firstChildElement("b");
        QDomElement semiMajorAxis = xmlElem.firstChildElement("semiMajorAxis");
        QDomElement normal = xmlElem.firstChildElement("spatialDirection");
        QDomElement center = xmlElem.firstChildElement("coordinates");

        if(a.isNull() || b.isNull() || semiMajorAxis.isNull() || normal.isNull() || center.isNull()
                || !a.hasAttribute("value") || !b.hasAttribute("value") || semiMajorAxis.hasAttribute("i")
                || !semiMajorAxis.hasAttribute("j") || !semiMajorAxis.hasAttribute("k")
                || !normal.hasAttribute("i") || normal.hasAttribute("j") || normal.hasAttribute("k")
                || !center.hasAttribute("x") || !center.hasAttribute("y") || !center.hasAttribute("z")){
            return false;
        }

        this->a = a.attribute("value").toDouble();
        this->b = b.attribute("value").toDouble();
        this->semiMajorAxis.setVector(semiMajorAxis.attribute("i").toDouble(),
                                      semiMajorAxis.attribute("j").toDouble(),
                                      semiMajorAxis.attribute("k").toDouble());
        this->normal.setVector(normal.attribute("i").toDouble(),
                               normal.attribute("j").toDouble(),
                               normal.attribute("k").toDouble());
        this->center.setVector(center.attribute("x").toDouble(),
                               center.attribute("y").toDouble(),
                               center.attribute("z").toDouble());

    }

    return result;

}
开发者ID:OpenIndy,项目名称:OpenIndy-Core,代码行数:43,代码来源:ellipse.cpp

示例13: getGeometryTypeName

/*!
 * \brief Ellipse::toOpenIndyXML
 * \param xmlDoc
 * \return
 */
QDomElement Ellipse::toOpenIndyXML(QDomDocument &xmlDoc) const{

    QDomElement ellipse = Geometry::toOpenIndyXML(xmlDoc);

    if(ellipse.isNull()){
        return ellipse;
    }

    ellipse.setAttribute("type", getGeometryTypeName(eEllipseGeometry));

    //set semi-major axis length
    QDomElement a = xmlDoc.createElement("a");
    if(this->isSolved || this->isNominal){
        a.setAttribute("value", this->a);
    }else{
        a.setAttribute("value", 0.0);
    }
    ellipse.appendChild(a);

    //set semi-minor axis length
    QDomElement b = xmlDoc.createElement("b");
    if(this->isSolved || this->isNominal){
        b.setAttribute("value", this->b);
    }else{
        b.setAttribute("value", 0.0);
    }
    ellipse.appendChild(b);

    //set semi-major axis direction
    QDomElement semiMajorAxis = xmlDoc.createElement("semiMajorAxis");
    if(this->isSolved || this->isNominal){
        semiMajorAxis.setAttribute("i", this->semiMajorAxis.getVector().getAt(0));
        semiMajorAxis.setAttribute("j", this->semiMajorAxis.getVector().getAt(1));
        semiMajorAxis.setAttribute("k", this->semiMajorAxis.getVector().getAt(2));
    }else{
        semiMajorAxis.setAttribute("i", 0.0);
        semiMajorAxis.setAttribute("j", 0.0);
        semiMajorAxis.setAttribute("k", 0.0);
    }
    ellipse.appendChild(semiMajorAxis);

    return ellipse;

}
开发者ID:OpenIndy,项目名称:OpenIndy-Core,代码行数:49,代码来源:ellipse.cpp

示例14: File

void DistributionTables::build(const std::string& BasePath,
                               const std::string& SourcesFileName, const std::string& DistributionFileName)
{
  SourcesTable.clear();
  UnitsTable.clear();


  // Sources file

  QDomDocument Doc;
  QDomElement Root;

  std::string SourcesFilePath = BasePath+"/"+SourcesFileName;


  QFile File(QString(SourcesFilePath.c_str()));
  if (!File.open(QIODevice::ReadOnly))
  {
    throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
        "Error opening " + SourcesFilePath);
  }

  bool Parsed = Doc.setContent(&File);
  File.close();


  if (Parsed)
  {
    Root = Doc.documentElement();

    if (!Root.isNull())
    {
      if (Root.tagName() == QString("openfluid"))
      {
        for(QDomElement CurrNode = Root.firstChildElement(); !CurrNode.isNull();
            CurrNode = CurrNode.nextSiblingElement())
        {
          if (CurrNode.tagName() == QString("datasources"))
          {
            for(QDomElement CurrNode2 = CurrNode.firstChildElement(); !CurrNode2.isNull();
                CurrNode2 = CurrNode2.nextSiblingElement())
            {
              if (CurrNode2.tagName() == QString("filesource"))
              {
                QString xmlID = CurrNode2.attributeNode(QString("ID")).value();
                QString xmlFile = CurrNode2.attributeNode(QString("file")).value();

                if (!xmlID.isNull() && !xmlFile.isNull())
                {
                  SourcesTable[xmlID.toStdString()] = BasePath + "/" + xmlFile.toStdString();
                }
              }
            }
          }
        }
      }
      else
        throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                                  "Cannot find <openfluid> tag in sources file " +
                                                  SourcesFilePath);
    }
    else
      throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"Wrong formatted sources file " +
                                                SourcesFilePath);
  }
  else
    throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,"Cannot open sources file " +
                                              SourcesFilePath);


  // Units distribution file

  long UnitID;
  std::string DataSrcID;

  ColumnTextParser DistriFileParser("%");

  std::string DistributionFilePath = BasePath+"/"+DistributionFileName;

  if (openfluid::tools::Filesystem::isFile(DistributionFilePath))
  {
    if (DistriFileParser.loadFromFile(DistributionFilePath) &&
        DistriFileParser.getColsCount() == 2 &&
        DistriFileParser.getLinesCount() >0)
    {
      for (unsigned int i=0;i<DistriFileParser.getLinesCount();i++)
      {
        if (DistriFileParser.getLongValue(i,0,&UnitID) && DistriFileParser.getStringValue(i,1,&DataSrcID))
        {
          if (SourcesTable.find(DataSrcID) != SourcesTable.end())
            UnitsTable[UnitID] = DataSrcID;
          else
            throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                                      "Error in distribution file " + DistributionFilePath +
                                                      ", data source ID not found");
        }
        else
          throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
                                                    "Error in distribution file " + DistributionFilePath +
                                                    ", format error");
//.........这里部分代码省略.........
开发者ID:OpenFLUID,项目名称:openfluid,代码行数:101,代码来源:DistributionTables.cpp

示例15: file

bool Syntaxer::loadSyntax(const QString &filename)
 {
	QFile file(filename);

	QString errorStr;
	int errorLine;
	int errorColumn;

	QDomDocument domDocument;
	if (!domDocument.setContent(&file, true, &errorStr, &errorLine, &errorColumn)) {
		return false;
	}

	QDomElement root = domDocument.documentElement();
	if (root.isNull()) return false;
	if (root.tagName() != "language") return false;

	QDomElement highlighting = root.firstChildElement("highlighting");
	if (highlighting.isNull()) return false;

	QDomElement general = root.firstChildElement("general");
	if (general.isNull()) return false;

	QDomElement contexts = highlighting.firstChildElement("contexts");
	if (contexts.isNull()) return false;

	m_hlCStringChar = false;
	QDomElement context = contexts.firstChildElement("context");
	while (!context.isNull()) {
		if (context.attribute("attribute").compare("Normal Text") == 0) {
			m_stringDelimiter = getStringDelimiter(context);
			initListsToFormats(context);
		}
		else if (context.attribute("attribute").compare("String") == 0) {
			QDomElement HlCStringChar = context.firstChildElement("HlCStringChar");
			if (!HlCStringChar.isNull()) {
				m_hlCStringChar = true;
			}
		}
		context = context.nextSiblingElement("context");
	}

    m_canProgram = root.attribute("canProgram", "").compare("true", Qt::CaseInsensitive) == 0;
	m_name = root.attribute("name");
	QStringList extensions = root.attribute("extensions").split(";", QString::SkipEmptyParts);
	if (extensions.count() > 0) {
		m_extensionString = m_name + " " + QObject::tr("files") + " (";
		foreach (QString ext, extensions) {
			m_extensionString += ext + " ";
			int ix = ext.indexOf(".");
			if (ix > 0) {
				ext.remove(0, ix);
			}
			m_extensions.append(ext);
		}
开发者ID:BrainsoftLtd,项目名称:fritzing-app,代码行数:55,代码来源:syntaxer.cpp


注:本文中的QDomElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。