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


C++ QDomNode::isElement方法代码示例

本文整理汇总了C++中QDomNode::isElement方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::isElement方法的具体用法?C++ QDomNode::isElement怎么用?C++ QDomNode::isElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDomNode的用法示例。


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

示例1: processYourPay


//.........这里部分代码省略.........
  QString whyMe;
  
  if (_metrics->boolean("CCTest"))
  {
    whyMe = _ccard_number + "  " + _response;
    _metrics->set("CCTestMe", whyMe);
    _metrics->set("CCOrder", saved_order);
  }
  
  /*if (_metrics->boolean("CCTest"))
  {
    QMessageBox::information(this, tr("YourPay"), tr("The return code was ") + _response, QMessageBox::Ok);
  }*/
  QDomDocument doc;
  doc.setContent(_response);
  QDomNode node;
  root = doc.documentElement();
  
  QString _r_avs;
  QString _r_ordernum;
  QString _r_error;
  QString _r_approved;
  QString _r_code;
  QString _r_score;
  QString _r_shipping;
  QString _r_tax;
  QString _r_tdate;
  QString _r_ref;
  QString _r_message;
  QString _r_time;
  
  node = root.firstChild();
  while ( !node.isNull() ) {
    if ( node.isElement() && node.nodeName() == "r_avs" ) {
      QDomElement r_avs = node.toElement();
      _r_avs = r_avs.text();
    }
    if ( node.isElement() && node.nodeName() == "r_ordernum" ) {
      QDomElement r_ordernum = node.toElement();
      _r_ordernum = r_ordernum.text();
    }
    if ( node.isElement() && node.nodeName() == "r_error" ) {
      QDomElement r_error = node.toElement();
      _r_error = r_error.text();
    }
    if ( node.isElement() && node.nodeName() == "r_approved" ) {
      QDomElement r_approved = node.toElement();
      _r_approved = r_approved.text();
    }
    if ( node.isElement() && node.nodeName() == "r_code" ) {
      QDomElement r_code = node.toElement();
      _r_code = r_code.text();
    }
    if ( node.isElement() && node.nodeName() == "r_message" ) {
      QDomElement r_message = node.toElement();
      _r_message = r_message.text();
    }
    if ( node.isElement() && node.nodeName() == "r_time" ) {
      QDomElement r_time = node.toElement();
      _r_time = r_time.text();
    }
    if ( node.isElement() && node.nodeName() == "r_ref" ) {
      QDomElement r_ref = node.toElement();
      _r_ref = r_ref.text();
    }
    if ( node.isElement() && node.nodeName() == "r_tdate" ) {
开发者ID:,项目名称:,代码行数:67,代码来源:

示例2: loadSettings

void AutomatableModel::loadSettings( const QDomElement& element, const QString& name )
{
	// compat code
	QDomNode node = element.namedItem( AutomationPattern::classNodeName() );
	if( node.isElement() )
	{
		node = node.namedItem( name );
		if( node.isElement() )
		{
			AutomationPattern * p = AutomationPattern::globalAutomationPattern( this );
			p->loadSettings( node.toElement() );
			setValue( p->valueAt( 0 ) );
			// in older projects we sometimes have odd automations
			// with just one value in - eliminate if necessary
			if( !p->hasAutomation() )
			{
				delete p;
			}
			return;
		}
		// logscales were not existing at this point of time
		// so they can be ignored
	}

	QDomNode connectionNode = element.namedItem( "connection" );
	// reads controller connection
	if( connectionNode.isElement() )
	{
		QDomNode thisConnection = connectionNode.toElement().namedItem( name );
		if( thisConnection.isElement() )
		{
			setControllerConnection( new ControllerConnection( (Controller*)NULL ) );
			m_controllerConnection->loadSettings( thisConnection.toElement() );
			//m_controllerConnection->setTargetName( displayName() );
		}
	}

	// models can be stored as elements (port00) or attributes (port10):
	// <ladspacontrols port10="4.41">
	//   <port00 value="4.41" id="4249278"/>
	// </ladspacontrols>
	// element => there is automation data, or scaletype information
	node = element.namedItem( name );
	if( node.isElement() )
	{
			changeID( node.toElement().attribute( "id" ).toInt() );
			setValue( node.toElement().attribute( "value" ).toFloat() );
			if( node.toElement().hasAttribute( "scale_type" ) )
			{
				if( node.toElement().attribute( "scale_type" ) == "linear" )
				{
					setScaleType( Linear );
				}
				else if( node.toElement().attribute( "scale_type" ) == "log" )
				{
					setScaleType( Logarithmic );
				}
			}
	}
	else if( element.hasAttribute( name ) )
	// attribute => read the element's value from the attribute list
	{
		setInitValue( element.attribute( name ).toFloat() );
	}
	else
	{
		reset();
	}
}
开发者ID:Frankenwolfe,项目名称:lmms,代码行数:69,代码来源:AutomatableModel.cpp

示例3: loadFromDom

	void ThymioVisualProgramming::loadFromDom(const QDomDocument& document, bool fromFile) 
	{
		scene->clear();

		QDomNode domNode = document.documentElement().firstChild();

		while (!domNode.isNull())
		{
			if (domNode.isElement())
			{
				QDomElement element = domNode.toElement();
				if (element.tagName() == "settings") 
				{
					if( element.attribute("advanced-mode") == "true" )
						advancedMode();
					else
					{
						advancedButton->setEnabled(true);
						actionButtons.last()->hide(); // state button
						scene->setAdvanced(false);
					}
					
					colorComboButton->setCurrentIndex(element.attribute("color-scheme").toInt());
				}
				else if(element.tagName() == "buttonset")
				{
					QString buttonName;
					ThymioButton *eventButton = 0;
					ThymioButton *actionButton = 0;
					
					if( !(buttonName = element.attribute("event-name")).isEmpty() )
					{
						
						if ( buttonName == "button" )
							eventButton = new ThymioButtonsEvent(0,scene->getAdvanced());
						else if ( buttonName == "prox" )
							eventButton = new ThymioProxEvent(0,scene->getAdvanced());
						else if ( buttonName == "proxground" )
							eventButton = new ThymioProxGroundEvent(0,scene->getAdvanced());
						else if ( buttonName == "tap" )
						{					
							eventButton = new ThymioTapEvent(0,scene->getAdvanced());
							eventButton->setSharedRenderer(tapSvg);
						}
						else if ( buttonName == "clap" )
						{
							eventButton = new ThymioClapEvent(0,scene->getAdvanced());
							eventButton->setSharedRenderer(clapSvg);
						}
						else
						{
							QMessageBox::warning(this,tr("Loading"),
												 tr("Error in XML source file: %0 unknown event type").arg(buttonName));
							return;
						}

						for(int i=0; i<eventButton->getNumButtons(); ++i)
							eventButton->setClicked(i,element.attribute(QString("eb%0").arg(i)).toInt());

						eventButton->setState(element.attribute("state").toInt());
					}
					
					if( !(buttonName = element.attribute("action-name")).isEmpty() )
					{
						if ( buttonName == "move" )
							actionButton = new ThymioMoveAction();
						else if ( buttonName == "color" )
							actionButton = new ThymioColorAction();
						else if ( buttonName == "circle" )
							actionButton = new ThymioCircleAction();
						else if ( buttonName == "sound" )
							actionButton = new ThymioSoundAction();
						else if ( buttonName == "memory" )
							actionButton = new ThymioMemoryAction();
						else
						{
							QMessageBox::warning(this,tr("Loading"),
												 tr("Error in XML source file: %0 unknown event type").arg(buttonName));
							return;
						}

						for(int i=0; i<actionButton->getNumButtons(); ++i)
							actionButton->setClicked(i,element.attribute(QString("ab%0").arg(i)).toInt());
					}

					scene->addButtonSet(eventButton, actionButton);
				}
			}
			domNode = domNode.nextSibling();
		}
		
		scene->setModified(!fromFile);
		
		if (!scene->isEmpty())
			QTimer::singleShot(0, this, SLOT(exec()));
	}
开发者ID:ardiny,项目名称:aseba,代码行数:96,代码来源:ThymioVisualProgramming.cpp

示例4: parseResponseCheckToken

void FlickrTalker::parseResponseCheckToken(const QByteArray& data)
{
    bool         success = false;
    QString      errorString;
    QString      username;
    QString      transReturn;
    QDomDocument doc("checktoken");

    if (!doc.setContent(data))
    {
        return;
    }

    QDomElement docElem = doc.documentElement();
    QDomNode node       = docElem.firstChild();
    QDomElement e;

    while (!node.isNull())
    {
        if (node.isElement() && node.nodeName() == "auth")
        {
            e                = node.toElement(); // try to convert the node to an element.
            QDomNode details = e.firstChild();

            while (!details.isNull())
            {
                if (details.isElement())
                {
                    e = details.toElement();

                    if (details.nodeName() == "token")
                    {
                        kDebug() << "Token=" << e.text();
                        m_token = e.text();//this is what is obtained from data.
                    }

                    if (details.nodeName() == "perms")
                    {
                        kDebug() << "Perms=" << e.text();
                        QString perms = e.text();//this is what is obtained from data.

                        if (perms == "write")
                        {
                            transReturn = i18nc("As in the permission to", "write");
                        }
                        else if (perms == "read")
                        {
                            transReturn = i18nc("As in the permission to", "read");
                        }
                        else if (perms == "delete")
                        {
                            transReturn = i18nc("As in the permission to", "delete");
                        }
                    }

                    if (details.nodeName() == "user")
                    {
                        kDebug() << "nsid=" << e.attribute("nsid");
                        m_userId   = e.attribute("nsid");
                        username   = e.attribute("username");
                        m_username = username;
                        kDebug() << "username=" << e.attribute("username");
                        kDebug() << "fullname=" << e.attribute("fullname");
                    }
                }

                details = details.nextSibling();
            }

            m_authProgressDlg->hide();
            emit signalTokenObtained(m_token);
            success = true;
        }

        if (node.isElement() && node.nodeName() == "err")
        {
            kDebug() << "Checking Error in response";
            errorString = node.toElement().attribute("code");
            kDebug() << "Error code=" << errorString;
            kDebug() << "Msg=" << node.toElement().attribute("msg");

            int valueOk = KMessageBox::questionYesNo(kapp->activeWindow(),
                                                     i18n("Your token is invalid. Would you like to "
                                                          "get a new token to proceed?\n"));

            if (valueOk == KMessageBox::Yes)
            {
                getFrob();
                return;
            }
            else
            {
                m_authProgressDlg->hide(); //will popup the result for the checktoken failure below
            }

        }

        node = node.nextSibling();
    }

//.........这里部分代码省略.........
开发者ID:rickysarraf,项目名称:digikam,代码行数:101,代码来源:flickrtalker.cpp

示例5: parseResponseListPhotoSets

void FlickrTalker::parseResponseListPhotoSets(const QByteArray& data)
{
    kDebug() << "parseResponseListPhotosets" << data;
    bool success = false;
    QDomDocument doc("getListPhotoSets");

    if (!doc.setContent(data))
    {
        return;
    }

    QDomElement docElem = doc.documentElement();
    QDomNode    node    = docElem.firstChild();
    QDomElement e;

    QString photoSet_id, photoSet_title, photoSet_description;
    m_photoSetsList = new QLinkedList <FPhotoSet> ();

    while (!node.isNull())
    {
        if (node.isElement() && node.nodeName() == "photosets")
        {
            e                    = node.toElement();
            QDomNode details     = e.firstChild();
            FPhotoSet fps;
            QDomNode detailsNode = details;

            while (!detailsNode.isNull())
            {
                if (detailsNode.isElement())
                {
                    e = detailsNode.toElement();

                    if (detailsNode.nodeName() == "photoset")
                    {
                        kDebug() << "id=" << e.attribute("id");
                        photoSet_id              = e.attribute("id");     // this is what is obtained from data.
                        fps.id                   = photoSet_id;
                        QDomNode photoSetDetails = detailsNode.firstChild();
                        QDomElement e_detail;

                        while (!photoSetDetails.isNull())
                        {
                            e_detail = photoSetDetails.toElement();

                            if (photoSetDetails.nodeName() == "title")
                            {
                                kDebug() << "Title=" << e_detail.text();
                                photoSet_title = e_detail.text();
                                fps.title      = photoSet_title;
                            }
                            else if (photoSetDetails.nodeName() == "description")
                            {
                                kDebug() << "Description =" << e_detail.text();
                                photoSet_description = e_detail.text();
                                fps.description      = photoSet_description;
                            }

                            photoSetDetails = photoSetDetails.nextSibling();
                        }

                        m_photoSetsList->append(fps);
                    }
                }

                detailsNode = detailsNode.nextSibling();
            }

            details = details.nextSibling();
            success = true;
        }

        if (node.isElement() && node.nodeName() == "err")
        {
            kDebug() << "Checking Error in response";
            QString code = node.toElement().attribute("code");
            kDebug() << "Error code=" << code;
            kDebug() << "Msg=" << node.toElement().attribute("msg");
            emit signalError(code);
        }

        node = node.nextSibling();
    }

    kDebug() << "GetPhotoList finished";

    if (!success)
    {
        emit signalListPhotoSetsFailed(i18n("Failed to fetch list of photo sets."));
    }
    else
    {
        emit signalListPhotoSetsSucceeded();
	maxAllowedFileSize();
    }
}
开发者ID:rickysarraf,项目名称:digikam,代码行数:96,代码来源:flickrtalker.cpp

示例6: processGraph_Nodes

bool GraphMLImporter::processGraph_Nodes(
	QDomElement& graphElement
)
{
	bool ok = true;

	iColor_ = 0;

	// nodes
	for ( QDomElement nodeElement = graphElement.firstChildElement( "node" ); ok && !nodeElement.isNull(); nodeElement = nodeElement.nextSiblingElement( "node" ) ) {
		QString nameId = nodeElement.attribute( "id" );
		QString name = NULL;
		// pozerame sa na data ktore nesie
		Data::Type* newNodeType;
		newNodeType = NULL;
		QDomNodeList nodeDataList = nodeElement.elementsByTagName( "data" );
		for ( unsigned int j = 0; j < nodeDataList.length(); j++ ) {
			QDomNode nodeData = nodeDataList.item( static_cast<int>( j ) );
			if ( !nodeData.isNull() && nodeData.isElement() ) {
				QDomElement nodeDataElement = nodeData.toElement();
				QString dataName = nodeDataElement.attribute( "key" );
				QString dataValue = nodeDataElement.text();
				// rozpoznavame typy
				if ( dataName == nodeTypeAttribute_ ) {
					// overime ci uz dany typ existuje v grafe
					QList<Data::Type*> types = context_->getGraph().getTypesByName( dataValue );
					if ( types.isEmpty() ) {
						QMap<QString, QString>* settings = new QMap<QString, QString>;

						settings->insert( "color.R", QString::number( colors_[iColor_][0] ) );
						settings->insert( "color.G", QString::number( colors_[iColor_][1] ) );
						settings->insert( "color.B", QString::number( colors_[iColor_][2] ) );
						settings->insert( "color.A", QString::number( colors_[iColor_][3] ) );
						settings->insert( "scale",		Util::ApplicationConfig::get()->getValue( "Viewer.Textures.DefaultNodeScale" ) );
						settings->insert( "textureFile", Util::ApplicationConfig::get()->getValue( "Viewer.Textures.Node" ) );

						newNodeType = context_->getGraph().addType( dataValue, settings );

						iColor_++;
						if ( iColor_ == colors_.size() ) {
							iColor_ = 0;
						}
					}
					else {
						newNodeType = types.first();
					}

				}
				else {
					// kazde dalsie data nacitame do nosica dat - Node.name
					// FIXME potom prerobit cez Adamove Node.settings
					if ( name == NULL ) {
						name = dataName+":"+dataValue;
					}
					else {
						name += " | "+dataName+":"+dataValue;
					}
				}
			}
		}

		// ak sme nenasli name, tak ako name pouzijeme aspon ID
		if ( name == NULL ) {
			name = nameId;
		}

		// ak nebol najdeny ziaden typ, tak pouzijeme defaultny typ
		osg::ref_ptr<Data::Node> node;
		if ( newNodeType == NULL ) {
			node = context_->getGraph().addNode( name, nodeType_ );
		}
		else {
			node = context_->getGraph().addNode( name, newNodeType );
		}
		readNodes_->addNode( nameId, node );

		// subgraphs
		for ( QDomElement subgraphElement = nodeElement.firstChildElement( "graph" ); ok && !subgraphElement.isNull(); subgraphElement = subgraphElement.nextSiblingElement( "graph" ) ) {
			if ( ok ) {
				context_->getGraph().createNestedGraph( node );
			}

			if ( ok ) {
				ok = processGraph( subgraphElement );
			}

			if ( ok ) {
				context_->getGraph().closeNestedGraph();
			}
		}

		entitiesProcessed_++;
		context_->getInfoHandler().setProgress( static_cast<unsigned int>( entitiesProcessed_ * 100 / entitiesCount_ ) );
	}

	return ok;
}
开发者ID:kapecp,项目名称:3dsoftviz,代码行数:97,代码来源:GraphMLImporter.cpp

示例7: loadProject

// load given song
void Song::loadProject( const QString & fileName )
{
	QDomNode node;

	m_loadingProject = true;

	Engine::projectJournal()->setJournalling( false );

	m_fileName = fileName;
	m_oldFileName = fileName;

	DataFile dataFile( m_fileName );
	// if file could not be opened, head-node is null and we create
	// new project
	if( dataFile.validate( fileName.right( fileName.lastIndexOf(".") ) ) )
	{
		return;
	}

	clearProject();

	clearErrors();

	DataFile::LocaleHelper localeHelper( DataFile::LocaleHelper::ModeLoad );

	Engine::mixer()->lock();

	// get the header information from the DOM
	m_tempoModel.loadSettings( dataFile.head(), "bpm" );
	m_timeSigModel.loadSettings( dataFile.head(), "timesig" );
	m_masterVolumeModel.loadSettings( dataFile.head(), "mastervol" );
	m_masterPitchModel.loadSettings( dataFile.head(), "masterpitch" );

	if( m_playPos[Mode_PlaySong].m_timeLine )
	{
		// reset loop-point-state
		m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 );
	}

	if( !dataFile.content().firstChildElement( "track" ).isNull() )
	{
		m_globalAutomationTrack->restoreState( dataFile.content().
						firstChildElement( "track" ) );
	}

	//Backward compatibility for LMMS <= 0.4.15
	PeakController::initGetControllerBySetting();

	// Load mixer first to be able to set the correct range for FX channels
	node = dataFile.content().firstChildElement( Engine::fxMixer()->nodeName() );
	if( !node.isNull() )
	{
		Engine::fxMixer()->restoreState( node.toElement() );
		if( gui )
		{
			// refresh FxMixerView
			gui->fxMixerView()->refreshDisplay();
		}
	}

	node = dataFile.content().firstChild();
	while( !node.isNull() )
	{
		if( node.isElement() )
		{
			if( node.nodeName() == "trackcontainer" )
			{
				( (JournallingObject *)( this ) )->restoreState( node.toElement() );
			}
			else if( node.nodeName() == "controllers" )
			{
				restoreControllerStates( node.toElement() );
			}
			else if( gui )
			{
				if( node.nodeName() == gui->getControllerRackView()->nodeName() )
				{
					gui->getControllerRackView()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->pianoRoll()->nodeName() )
				{
					gui->pianoRoll()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->automationEditor()->m_editor->nodeName() )
				{
					gui->automationEditor()->m_editor->restoreState( node.toElement() );
				}
				else if( node.nodeName() == gui->getProjectNotes()->nodeName() )
				{
					 gui->getProjectNotes()->SerializingObject::restoreState( node.toElement() );
				}
				else if( node.nodeName() == m_playPos[Mode_PlaySong].m_timeLine->nodeName() )
				{
					m_playPos[Mode_PlaySong].m_timeLine->restoreState( node.toElement() );
				}
			}
		}
		node = node.nextSibling();
	}
//.........这里部分代码省略.........
开发者ID:HDDigitizerMusic,项目名称:lmms-alt-theme,代码行数:101,代码来源:Song.cpp

示例8: loadProject

// load given song
void Song::loadProject( const QString & fileName )
{
	QDomNode node;

	m_loadingProject = true;

	Engine::projectJournal()->setJournalling( false );

	m_oldFileName = m_fileName;
	setProjectFileName(fileName);

	DataFile dataFile( m_fileName );
	// if file could not be opened, head-node is null and we create
	// new project
	if( dataFile.head().isNull() )
	{
		if( m_loadOnLaunch )
		{
			createNewProject();
		}
		setProjectFileName(m_oldFileName);
		return;
	}

	m_oldFileName = m_fileName;

	clearProject();

	clearErrors();

	Engine::mixer()->requestChangeInModel();

	// get the header information from the DOM
	m_tempoModel.loadSettings( dataFile.head(), "bpm" );
	m_timeSigModel.loadSettings( dataFile.head(), "timesig" );
	m_masterVolumeModel.loadSettings( dataFile.head(), "mastervol" );
	m_masterPitchModel.loadSettings( dataFile.head(), "masterpitch" );

	if( m_playPos[Mode_PlaySong].m_timeLine )
	{
		// reset loop-point-state
		m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 );
	}

	if( !dataFile.content().firstChildElement( "track" ).isNull() )
	{
		m_globalAutomationTrack->restoreState( dataFile.content().
						firstChildElement( "track" ) );
	}

	//Backward compatibility for LMMS <= 0.4.15
	PeakController::initGetControllerBySetting();

	// Load mixer first to be able to set the correct range for FX channels
	node = dataFile.content().firstChildElement( Engine::fxMixer()->nodeName() );
	if( !node.isNull() )
	{
		Engine::fxMixer()->restoreState( node.toElement() );
		if( gui )
		{
			// refresh FxMixerView
			gui->fxMixerView()->refreshDisplay();
		}
	}

	node = dataFile.content().firstChild();

	QDomNodeList tclist=dataFile.content().elementsByTagName("trackcontainer");
	m_nLoadingTrack=0;
	for( int i=0,n=tclist.count(); i<n; ++i )
	{
		QDomNode nd=tclist.at(i).firstChild();
		while(!nd.isNull())
		{
			if( nd.isElement() && nd.nodeName() == "track" )
			{
				++m_nLoadingTrack;
				if( nd.toElement().attribute("type").toInt() == Track::BBTrack )
				{
					n += nd.toElement().elementsByTagName("bbtrack").at(0)
						.toElement().firstChildElement().childNodes().count();
				}
				nd=nd.nextSibling();
			}
		}
	}

	while( !node.isNull() && !isCancelled() )
	{
		if( node.isElement() )
		{
			if( node.nodeName() == "trackcontainer" )
			{
				( (JournallingObject *)( this ) )->restoreState( node.toElement() );
			}
			else if( node.nodeName() == "controllers" )
			{
				restoreControllerStates( node.toElement() );
			}
//.........这里部分代码省略.........
开发者ID:LMMS,项目名称:lmms,代码行数:101,代码来源:Song.cpp

示例9: QGraphicsView

WbWidget::WbWidget(SxeSession* session, QWidget *parent) : QGraphicsView(parent) {
	newWbItem_ = 0;
	adding_ = 0;
	addVertex_ = false;
	strokeColor_ = Qt::black;
	fillColor_ = Qt::transparent;
	strokeWidth_ = 1;
	session_ = session;

//	setCacheMode(CacheBackground);
	setRenderHint(QPainter::Antialiasing);
	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

	// Make the scroll bars always stay on because otherwise the resize event can cause
	// an infinite loop as the effective size of the widget changes when scroll bars are
	// added/removed
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

	// create the scene
	scene_ = new WbScene(session_, this);
	scene_->setItemIndexMethod(QGraphicsScene::NoIndex);
	setRenderHint(QPainter::Antialiasing);
	setTransformationAnchor(AnchorUnderMouse);
	setResizeAnchor(AnchorViewCenter);
	setScene(scene_);

	// render the initial document
	rerender();
	// rerender on update
	connect(session_, SIGNAL(documentUpdated(bool)), SLOT(handleDocumentUpdated(bool)));

	// add the initial items
	const QDomNodeList children = session_->document().documentElement().childNodes();
	for(int i = 0; i < (int)children.length(); i++) {
		const QDomNode node = children.at(i);
		if(node.isElement()) {
			queueNodeInspection(node.toElement());
		}
	}
	inspectNodes();

	// add new items as nodes are added
	// remove/add items if corresponding nodes are moved
	connect(session_, SIGNAL(nodeAdded(QDomNode, bool)), SLOT(queueNodeInspection(QDomNode)));
	connect(session_, SIGNAL(nodeMoved(QDomNode, bool)), SLOT(queueNodeInspection(QDomNode)));
	// remove items if corresponding nodes are deleted
	connect(session_, SIGNAL(nodeToBeRemoved(QDomNode, bool)), SLOT(removeWbItem(QDomNode)));
	connect(session_, SIGNAL(nodeToBeRemoved(QDomNode, bool)), SLOT(checkForRemovalOfId(QDomNode)));
	// adjust the viewBox as necessary
	connect(session_, SIGNAL(nodeAdded(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode)));
	connect(session_, SIGNAL(nodeMoved(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode)));
	connect(session_, SIGNAL(chdataChanged(QDomNode, bool)), SLOT(checkForViewBoxChange(QDomNode)));

	// set the default mode to select
	setMode(Select);

	// set the initial size
	if(session_->document().documentElement().hasAttribute("viewBox"))
		checkForViewBoxChange(session_->document().documentElement().attributeNode("viewBox"));
	else {
		QSize size;
		QRectF rect = scene_->sceneRect();
		size.setWidth(rect.x() + rect.width());
		size.setHeight(rect.y() + rect.height());
		if(size.width() > 0 && size.height() > 0)
			setSize(size);
		else
			setSize(QSize(400, 600));
	}
}
开发者ID:lyn1337,项目名称:PsiStorm,代码行数:71,代码来源:wbwidget.cpp

示例10: read_xml_file

void XMLHandler::read_xml_file()
{
	QDomDocument document;

	// load the file
	QFile file(filename);
	if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		qDebug() << "Unable to open file!";
		return;
	}
	else
	{
		if (!document.setContent(&file))
		{
			qDebug() << "Invalid XML file!";
			return;
		}
		file.close();
	}

	// get root element
	QDomElement docElem = document.documentElement();

	// check root tag
	QString rootTag = docElem.tagName();
	if (!rootTag.compare("\"StreXRD_Project\""))
	{
		qDebug() << "Not a StreXRD project file!";
	}

	QDomElement root = document.firstChildElement();


	// get the project name
	QDomNodeList items = root.elementsByTagName("Name");
	QDomNode itemnode = items.at(0);
	QDomElement itemEl = itemnode.toElement();
	project_name = itemEl.text();

	// get file names and locations
	QDomNodeList files = docElem.elementsByTagName("File");
	for (int i = 0; i < files.count(); i++)
	{
		QDomNode filenode = files.at(i);
		if (filenode.isElement())
		{
			QString file_ID = filenode.toElement().attribute("ID");
			int file_ID_number = file_ID.toInt();
			file_ID_list.append(file_ID_number);

			QDomNodeList file_names = filenode.toElement().elementsByTagName("Name");
			QDomNodeList file_locations = filenode.toElement().elementsByTagName("Location");

			QString file_name = file_names.at(0).toElement().text();
			QString file_location =  file_locations.at(0).toElement().text();

			this->file_names_locations.insert(file_name, file_location);

			file_name_list.append(file_name);
			file_location_list.append(file_location);
		}
	}
}
开发者ID:equack,项目名称:AutoXRD,代码行数:64,代码来源:xml_handler.cpp

示例11: loadProject

// load given song
void song::loadProject( const QString & _file_name )
{
	QDomNode node;

	m_loadingProject = true;

	clearProject();

	engine::projectJournal()->setJournalling( false );

	m_fileName = _file_name;
	m_oldFileName = _file_name;

	DataFile dataFile( m_fileName );
	// if file could not be opened, head-node is null and we create
	// new project
	if( dataFile.head().isNull() )
	{
		createNewProject();
		return;
	}

	engine::mixer()->lock();

	// get the header information from the DOM
	m_tempoModel.loadSettings( dataFile.head(), "bpm" );
	m_timeSigModel.loadSettings( dataFile.head(), "timesig" );
	m_masterVolumeModel.loadSettings( dataFile.head(), "mastervol" );
	m_masterPitchModel.loadSettings( dataFile.head(), "masterpitch" );

	if( m_playPos[Mode_PlaySong].m_timeLine )
	{
		// reset loop-point-state
		m_playPos[Mode_PlaySong].m_timeLine->toggleLoopPoints( 0 );
	}

	if( !dataFile.content().firstChildElement( "track" ).isNull() )
	{
		m_globalAutomationTrack->restoreState( dataFile.content().
						firstChildElement( "track" ) );
	}

	//Backward compatibility for LMMS <= 0.4.15
	PeakController::initGetControllerBySetting();

	// Load mixer first to be able to set the correct range for FX channels
	node = dataFile.content().firstChildElement( engine::fxMixer()->nodeName() );
	if( !node.isNull() )
	{
		engine::fxMixer()->restoreState( node.toElement() );
		if( engine::hasGUI() )
		{
			// refresh FxMixerView
			engine::fxMixerView()->refreshDisplay();
		}
	}

	node = dataFile.content().firstChild();
	while( !node.isNull() )
	{
		if( node.isElement() )
		{
			if( node.nodeName() == "trackcontainer" )
			{
				( (JournallingObject *)( this ) )->restoreState( node.toElement() );
			}
			else if( node.nodeName() == "controllers" )
			{
				restoreControllerStates( node.toElement() );
			}
			else if( engine::hasGUI() )
			{
				if( node.nodeName() == engine::getControllerRackView()->nodeName() )
				{
					engine::getControllerRackView()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == engine::pianoRoll()->nodeName() )
				{
					engine::pianoRoll()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == engine::automationEditor()->nodeName() )
				{
					engine::automationEditor()->restoreState( node.toElement() );
				}
				else if( node.nodeName() == engine::getProjectNotes()->nodeName() )
				{
					 engine::getProjectNotes()->SerializingObject::restoreState( node.toElement() );
				}
				else if( node.nodeName() == m_playPos[Mode_PlaySong].m_timeLine->nodeName() )
				{
					m_playPos[Mode_PlaySong].m_timeLine->restoreState( node.toElement() );
				}
			}
		}
		node = node.nextSibling();
	}

	// quirk for fixing projects with broken positions of TCOs inside
	// BB-tracks
//.........这里部分代码省略.........
开发者ID:hhalmet,项目名称:lmms,代码行数:101,代码来源:song.cpp

示例12: setup

void WPushButton::setup(QDomNode node, const SkinContext& context) {
    // Number of states
    int iNumStates = context.selectInt(node, "NumberStates");
    setStates(iNumStates);

    // Set background pixmap if available
    if (context.hasNode(node, "BackPath")) {
        QString mode_str = context.selectAttributeString(
                context.selectElement(node, "BackPath"), "scalemode", "TILE");
        setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")),
                            Paintable::DrawModeFromString(mode_str));
    }

    // Load pixmaps for associated states
    QDomNode state = context.selectNode(node, "State");
    while (!state.isNull()) {
        if (state.isElement() && state.nodeName() == "State") {
            int iState = context.selectInt(state, "Number");
            if (iState < m_iNoStates) {
                if (context.hasNode(state, "Pressed")) {
                    setPixmap(iState, true,
                              context.getSkinPath(context.selectString(state, "Pressed")));
                }
                if (context.hasNode(state, "Unpressed")) {
                    setPixmap(iState, false,
                              context.getSkinPath(context.selectString(state, "Unpressed")));
                }
                m_text.replace(iState, context.selectString(state, "Text"));
            }
        }
        state = state.nextSibling();
    }

    ControlParameterWidgetConnection* leftConnection = NULL;
    if (m_leftConnections.isEmpty()) {
        if (!m_connections.isEmpty()) {
            // If no left connection is set, the this is the left connection
            leftConnection = m_connections.at(0);
        }
    } else {
        leftConnection = m_leftConnections.at(0);
    }

    if (leftConnection) {
        bool leftClickForcePush = context.selectBool(node, "LeftClickIsPushButton", false);
        m_leftButtonMode = ControlPushButton::PUSH;
        if (!leftClickForcePush) {
            const ConfigKey& configKey = leftConnection->getKey();
            ControlPushButton* p = dynamic_cast<ControlPushButton*>(
                    ControlObject::getControl(configKey));
            if (p) {
                m_leftButtonMode = p->getButtonMode();
            }
        }
        if (leftConnection->getEmitOption() &
                ControlParameterWidgetConnection::EMIT_DEFAULT) {
            switch (m_leftButtonMode) {
                case ControlPushButton::PUSH:
                case ControlPushButton::LONGPRESSLATCHING:
                case ControlPushButton::POWERWINDOW:
                    leftConnection->setEmitOption(
                            ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE);
                    break;
                default:
                    leftConnection->setEmitOption(
                            ControlParameterWidgetConnection::EMIT_ON_PRESS);
                    break;
            }
        }
        if (leftConnection->getDirectionOption() &
                        ControlParameterWidgetConnection::DIR_DEFAULT) {
            if (m_pDisplayConnection == leftConnection) {
                leftConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_AND_TO_WIDGET);
            } else {
                leftConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_WIDGET);
                if (m_pDisplayConnection->getDirectionOption() &
                        ControlParameterWidgetConnection::DIR_DEFAULT) {
                    m_pDisplayConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_TO_WIDGET);
                }
            }
        }
    }

    if (!m_rightConnections.isEmpty()) {
        ControlParameterWidgetConnection* rightConnection = m_rightConnections.at(0);
        bool rightClickForcePush = context.selectBool(node, "RightClickIsPushButton", false);
        m_rightButtonMode = ControlPushButton::PUSH;
        if (!rightClickForcePush) {
            const ConfigKey configKey = rightConnection->getKey();
            ControlPushButton* p = dynamic_cast<ControlPushButton*>(
                    ControlObject::getControl(configKey));
            if (p) {
                m_rightButtonMode = p->getButtonMode();
                if (m_rightButtonMode != ControlPushButton::PUSH) {
                    qWarning()
                            << "WPushButton::setup: Connecting a Pushbutton not in PUSH mode is not implemented\n"
                            << "Please set <RightClickIsPushButton>true</RightClickIsPushButton>";
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:Gussss,项目名称:mixxx,代码行数:101,代码来源:wpushbutton.cpp

示例13: loadTrackSpecificSettings

void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement )
{
	silenceAllNotes( true );

	lock();

	m_volumeModel.loadSettings( thisElement, "vol" );
	m_panningModel.loadSettings( thisElement, "pan" );
	m_pitchRangeModel.loadSettings( thisElement, "pitchrange" );
	m_pitchModel.loadSettings( thisElement, "pitch" );
	m_effectChannelModel.setRange( 0, Engine::fxMixer()->numChannels()-1 );
	m_effectChannelModel.loadSettings( thisElement, "fxch" );
	m_baseNoteModel.loadSettings( thisElement, "basenote" );
	m_useMasterPitchModel.loadSettings( thisElement, "usemasterpitch");

	// clear effect-chain just in case we load an old preset without FX-data
	m_audioPort.effects()->clear();

	QDomNode node = thisElement.firstChild();
	while( !node.isNull() )
	{
		if( node.isElement() )
		{
			if( m_soundShaping.nodeName() == node.nodeName() )
			{
				m_soundShaping.restoreState( node.toElement() );
			}
			else if( m_noteStacking.nodeName() == node.nodeName() )
			{
				m_noteStacking.restoreState( node.toElement() );
			}
			else if( m_arpeggio.nodeName() == node.nodeName() )
			{
				m_arpeggio.restoreState( node.toElement() );
			}
			else if( m_midiPort.nodeName() == node.nodeName() )
			{
				m_midiPort.restoreState( node.toElement() );
			}
			else if( m_audioPort.effects()->nodeName() == node.nodeName() )
			{
				m_audioPort.effects()->restoreState( node.toElement() );
			}
			else if( node.nodeName() == "instrument" )
			{
				delete m_instrument;
				m_instrument = NULL;
				m_instrument = Instrument::instantiate( node.toElement().attribute( "name" ), this );
				m_instrument->restoreState( node.firstChildElement() );

				emit instrumentChanged();
			}
			// compat code - if node-name doesn't match any known
			// one, we assume that it is an instrument-plugin
			// which we'll try to load
			else if( AutomationPattern::classNodeName() != node.nodeName() &&
					ControllerConnection::classNodeName() != node.nodeName() &&
					!node.toElement().hasAttribute( "id" ) )
			{
				delete m_instrument;
				m_instrument = NULL;
				m_instrument = Instrument::instantiate( node.nodeName(), this );
				if( m_instrument->nodeName() == node.nodeName() )
				{
					m_instrument->restoreState( node.toElement() );
				}
				emit instrumentChanged();
			}
		}
		node = node.nextSibling();
	}
	updatePitchRange();
	unlock();
}
开发者ID:jasp00,项目名称:lmms,代码行数:74,代码来源:InstrumentTrack.cpp

示例14: read

bool MyMoneyStatement::read(const QDomElement& _e)
{
  bool result = false;

  if (_e.tagName() == "STATEMENT") {
    result = true;

    m_strAccountName = _e.attribute("accountname");
    m_strAccountNumber = _e.attribute("accountnumber");
    m_strRoutingNumber = _e.attribute("routingnumber");
    m_strCurrency = _e.attribute("currency");
    m_dateBegin = QDate::fromString(_e.attribute("begindate"), Qt::ISODate);
    m_dateEnd = QDate::fromString(_e.attribute("enddate"), Qt::ISODate);
    m_closingBalance = MyMoneyMoney(_e.attribute("closingbalance"));
    m_accountId = _e.attribute("accountid");
    m_skipCategoryMatching = _e.attribute("skipCategoryMatching").isEmpty();

    int i = kAccountTypeTxt.indexOf(_e.attribute("type", kAccountTypeTxt[1]));
    if (i != -1)
      m_eType = static_cast<EType>(i);

    QDomNode child = _e.firstChild();
    while (!child.isNull() && child.isElement()) {
      QDomElement c = child.toElement();

      if (c.tagName() == "TRANSACTION") {
        MyMoneyStatement::Transaction t;

        t.m_datePosted = QDate::fromString(c.attribute("dateposted"), Qt::ISODate);
        t.m_amount = MyMoneyMoney(c.attribute("amount"));
        t.m_strMemo = c.attribute("memo");
        t.m_strNumber = c.attribute("number");
        t.m_strPayee = c.attribute("payee");
        t.m_strBankID = c.attribute("bankid");
        t.m_reconcile = static_cast<MyMoneySplit::reconcileFlagE>(c.attribute("reconcile").toInt());
        int i = kActionText.indexOf(c.attribute("action", kActionText[1]));
        if (i != -1)
          t.m_eAction = static_cast<Transaction::EAction>(i);

        if (m_eType == etInvestment) {
          t.m_shares = MyMoneyMoney(c.attribute("shares"));
          t.m_strSecurity = c.attribute("security");
          t.m_strBrokerageAccount = c.attribute("brokerageaccount");
        }

        // process splits (if any)
        QDomNode child = c.firstChild();
        while (!child.isNull() && child.isElement()) {
          QDomElement c = child.toElement();
          if (c.tagName() == "SPLIT") {
            MyMoneyStatement::Split s;
            s.m_accountId = c.attribute("accountid");
            s.m_amount = MyMoneyMoney(c.attribute("amount"));
            s.m_reconcile = static_cast<MyMoneySplit::reconcileFlagE>(c.attribute("reconcile").toInt());
            s.m_strCategoryName = c.attribute("category");
            s.m_strMemo = c.attribute("memo");
            t.m_listSplits += s;
          }
          child = child.nextSibling();
        }
        m_listTransactions += t;
      } else if (c.tagName() == "PRICE") {
        MyMoneyStatement::Price p;

        p.m_date = QDate::fromString(c.attribute("dateposted"), Qt::ISODate);
        p.m_strSecurity = c.attribute("security");
        p.m_amount = MyMoneyMoney(c.attribute("amount"));

        m_listPrices += p;
      } else if (c.tagName() == "SECURITY") {
        MyMoneyStatement::Security s;

        s.m_strName = c.attribute("name");
        s.m_strSymbol = c.attribute("symbol");
        s.m_strId = c.attribute("id");

        m_listSecurities += s;
      }
      child = child.nextSibling();
    }
  }

  return result;
}
开发者ID:CGenie,项目名称:kmymoney,代码行数:84,代码来源:mymoneystatement.cpp

示例15: processGraph_Edges

bool GraphMLImporter::processGraph_Edges(
	QDomElement& graphElement
)
{
	bool ok = true;

	iColor_ = 0;

	// default direction
	bool defaultDirection;
	if ( graphElement.attribute( "edgedefault" ) == "directed" ) {
		defaultDirection = true;
	}
	else {
		defaultDirection = false;
	}

	// edges
	for ( QDomElement edgeElement = graphElement.firstChildElement( "edge" ); ok && !edgeElement.isNull(); edgeElement = edgeElement.nextSiblingElement( "edge" ) ) {
		QString sourceId = edgeElement.attribute( "source" );
		QString targetId = edgeElement.attribute( "target" );

		QString direction = NULL;
		bool directed = false;
		direction = edgeElement.attribute( "directed" );
		if ( direction == NULL ) {
			directed = defaultDirection;
			if ( directed ) {
				direction = "_directed";
			}
			else {
				direction = "";
			}
		}
		else {
			if ( direction == "true" ) {
				direction = "_directed";
				directed = true;
			}
			else {
				direction = "";
				directed = false;
			}
		}

		// pozerame sa na data ktore hrana nesie
		Data::Type* newEdgeType;
		newEdgeType = NULL;
		QDomNodeList edgeDataList = edgeElement.elementsByTagName( "data" );
		for ( unsigned int j = 0; j < edgeDataList.length(); j++ ) {
			QDomNode edgeData = edgeDataList.item( static_cast<int>( j ) );
			if ( !edgeData.isNull() && edgeData.isElement() ) {
				QDomElement edgeDataElement = edgeData.toElement();
				QString dataName = edgeDataElement.attribute( "key" );
				QString dataValue = edgeDataElement.text();
				// rozpoznavame typy deklarovane atributom relation
				if ( dataName == edgeTypeAttribute_ ) {
					// overime ci uz dany typ existuje v grafe
					QList<Data::Type*> types = context_->getGraph().getTypesByName( dataValue+direction );
					if ( types.isEmpty() ) {
						QMap<QString, QString>* settings = new QMap<QString, QString>;

						// FIXME spravit tak, aby to rotovalo po tom poli - palo az to budes prerabat tak pre hrany pouzi ine pole, take co ma alfu na 0.5.. a to sa tyka aj uzlov s defaultnym typom
						settings->insert( "color.R", QString::number( colors_[iColor_][0] ) );
						settings->insert( "color.G", QString::number( colors_[iColor_][1] ) );
						settings->insert( "color.B", QString::number( colors_[iColor_][2] ) );
						settings->insert( "color.A", QString::number( colors_[iColor_][3] ) );
						settings->insert( "scale",		Util::ApplicationConfig::get()->getValue( "Viewer.Textures.DefaultNodeScale" ) );

						if ( !directed ) {
							settings->insert( "textureFile", Util::ApplicationConfig::get()->getValue( "Viewer.Textures.Edge" ) );
						}
						else {
							settings->insert( "textureFile", Util::ApplicationConfig::get()->getValue( "Viewer.Textures.OrientedEdgePrefix" ) );
							settings->insert( "textureFile", Util::ApplicationConfig::get()->getValue( "Viewer.Textures.OrientedEdgeSuffix" ) );
						}

						newEdgeType = context_->getGraph().addType( dataValue+direction, settings );

						iColor_++;
						if ( iColor_ == colors_.size() ) {
							iColor_ = 0;
						}
					}
					else {
						newEdgeType = types.first();
					}

				}
				else {
					// kazde dalsie data nacitame do nosica dat - Edge.name
					// FIXME potom prerobit cez Adamove Node.settings
				}
			}
		}

		// ak nebol najdeny typ, tak pouzijeme defaulty
		if ( newEdgeType == NULL ) {
			newEdgeType = edgeType_;
		}
//.........这里部分代码省略.........
开发者ID:kapecp,项目名称:3dsoftviz,代码行数:101,代码来源:GraphMLImporter.cpp


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