本文整理汇总了C++中QDomNode::nextSibling方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::nextSibling方法的具体用法?C++ QDomNode::nextSibling怎么用?C++ QDomNode::nextSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::nextSibling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processMuc
bool StopSpam::processMuc(int account, const QDomElement& stanza) {
if(stanza.tagName() == "presence") {
QStringList jidList = stanza.attribute("from").split("/");
int i = mucUsers_.size();
if(findMuc(jidList.first(),jidList.last(), i)) {
MucUser &mu = mucUsers_[i];
QDomNodeList nodeList = stanza.elementsByTagName("x");
for(int i = nodeList.size(); i> 0;) {
QDomNode node = nodeList.at(--i).firstChild();
while(!node.isNull()) {
QDomElement item = node.toElement();
if(item.tagName() == "item") {
mu.affiliation = item.attribute("affiliation");
mu.role = item.attribute("role");
mu.jid = item.attribute("jid");
break;
}
node = node.nextSibling();
}
}
}
else {
MucUser mu;
mu.mucJid = jidList.first();
mu.nick = jidList.last();
QDomNodeList nodeList = stanza.elementsByTagName("x");
for(int i = nodeList.size(); i> 0;) {
QDomNode node = nodeList.at(--i).firstChild();
while(!node.isNull()) {
QDomElement item = node.toElement();
if(item.tagName() == "item") {
mu.affiliation = item.attribute("affiliation");
mu.role = item.attribute("role");
mu.jid = item.attribute("jid");
break;
}
node = node.nextSibling();
}
}
mucUsers_ << mu;
}
}
else if(stanza.tagName() == "message" && stanza.attribute("type") == "chat") {
QDomElement subj = stanza.firstChildElement("subject");
if (subj.text() == "StopSpam" || subj.text() == "StopSpam Question") return false;
QString valF = stanza.attribute("from");
if (contactInfo->isConference(account, valF)) return false;
MucUser mu;
QStringList jidList = valF.split("/");
int i = mucUsers_.size();
if(findMuc(jidList.first(),jidList.last(), i)) {
mu = mucUsers_[i];
} else {
mu.affiliation = "";
mu.jid = "";
mu.mucJid = "";
mu.nick = "";
mu.role = "";
}
bool find = false;
if(mu.affiliation == "owner" && !Owner)
find = true;
else if( mu.affiliation == "admin" && !Admin)
find = true;
else if(mu.affiliation == "none" && !None)
find = true;
else if(mu.affiliation == "member" && !Member)
find = true;
if(find)
return false;
if(mu.role == "moderator" && !Moder)
find = true;
else if(mu.role == "participant" && !Participant)
find = true;
else if(mu.role == "visitor" && !Visitor)
find = true;
if(find)
return false;
QStringList UnblockedJids = Unblocked.split("\n");
if(UnblockedJids.contains(valF, Qt::CaseInsensitive))
return false;
for(int i = 0; i < Jids.size(); i++) {
QString jid_ = Jids.at(i);
if(jid_.isEmpty())
continue;
if(mu.jid.contains(jid_, Qt::CaseInsensitive)
|| mu.nick.contains(jid_, Qt::CaseInsensitive)
|| mu.mucJid.contains(jid_, Qt::CaseInsensitive)) {
if(!selected[i].toBool())
return false;
break;
}
}
//.........这里部分代码省略.........
示例2: main
int main(int argc, char *argv[])
{
QCoreApplication application(argc, argv);
application.addLibraryPath(".");
QTextStream out(stdout, QIODevice::WriteOnly);
if (application.argc() > 1)
{
QString databaseURL;
QString username;
QString passwd;
QString arguments;
QString xml_file = QString::null;
int report_grade = 0;
for (int counter = 1; counter < application.argc(); counter++)
{
QString arguments(application.argv()[counter]);
if (arguments.startsWith("-databaseURL=", Qt::CaseInsensitive))
databaseURL = arguments.right(arguments.length() - 13);
else if (arguments.startsWith("-username=", Qt::CaseInsensitive))
username = arguments.right(arguments.length() - 10);
else if (arguments.startsWith("-passwd=", Qt::CaseInsensitive))
passwd = arguments.right(arguments.length() - 8);
else if (arguments.startsWith("-f=", Qt::CaseInsensitive))
xml_file = arguments.right(arguments.length() - 3);
else if (arguments.startsWith("-grade=", Qt::CaseInsensitive))
report_grade = (arguments.right(arguments.length() - 7)).toInt();
else if(!arguments.startsWith("-"))
xml_file = arguments;
}
QString report_name = QString::null;
QString report_desc = QString::null;
QString report_src = QString::null;
if(xml_file != "") {
QFile file(xml_file);
if(file.open( QIODevice::ReadOnly )) {
QDomDocument doc;
QString errMsg;
int errLine, errCol;
if(doc.setContent(&file, &errMsg, &errLine, &errCol)) {
QDomElement root = doc.documentElement();
if(root.tagName() == "report") {
for(QDomNode n = root.firstChild();
!n.isNull(); n = n.nextSibling() ) {
if(n.nodeName() == "name") {
report_name = n.firstChild().nodeValue();
} else if(n.nodeName() == "description") {
report_desc = n.firstChild().nodeValue();
}
}
report_src = doc.toString();
if(report_name == "") {
out << "The document " << xml_file << " does not have a report name defined." << endl;
}
} else {
out << "XML Document " << xml_file << " does not have root node of report." << endl;
}
} else {
out << "Error parsing file " << xml_file << ": " << errMsg << " on line " << errLine << " column " << errCol << endl;
}
} else {
out << "Could not open the specified file: " << xml_file << endl;
}
} else {
out << "You must specify an XML file to load by using the -f= parameter." << endl;
}
if(report_name == "" || report_src == "") {
// an error message already should have been displayed to the user
exit(-1);
}
if ( (databaseURL != "") &&
(username != "") &&
(passwd != "") ) {
QSqlDatabase db;
// Open the Database Driver
db = databaseFromURL( databaseURL );
if (!db.isValid())
{
out << "Could not load the specified database driver." << endl;
exit(-1);
}
// Try to connect to the Database
db.setUserName(username);
db.setPassword(passwd);
if (!db.open())
{
out << "Host=" << db.hostName() << ", Database=" << db.databaseName() << ", port=" << db.port() << endl;
out << "Could not log into database. System Error: "
<< db.lastError().text() << endl;
//.........这里部分代码省略.........
示例3: parseGroup
//.........这里部分代码省略.........
m_Doc->Items->at(z)->setLineJoin(LineJoin);
m_Doc->Items->at(z)->setLineEnd(LineEnd);
finishItem(m_Doc->Items->at(z));
}
else if ((STag == "svg:polygon") || (STag == "svg:polyline"))
{
bool bFirst = true;
double x = 0.0;
double y = 0.0;
QString points = pg.attribute( "points" ).simplified().replace(',', " ");
QStringList pointList = points.split(' ', QString::SkipEmptyParts);
FirstM = true;
for( QStringList::Iterator it = pointList.begin(); it != pointList.end(); it++ )
{
if( bFirst )
{
x = ScCLocale::toDoubleC(*(it++));
y = ScCLocale::toDoubleC(*it);
svgMoveTo(x * Conversion, y * Conversion);
bFirst = false;
WasM = true;
}
else
{
x = ScCLocale::toDoubleC(*(it++));
y = ScCLocale::toDoubleC(*it);
svgLineTo(&PoLine, x * Conversion, y * Conversion);
}
}
if (STag == "svg:polygon")
svgClosePath(&PoLine);
if (PoLine.size() < 4)
{
DOC = DOC.nextSibling();
continue;
}
int z;
if (STag == "svg:polygon")
z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, FillCol, StrokeCol, true);
else
z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, CommonStrings::None, StrokeCol, true);
m_Doc->Items->at(z)->PoLine = PoLine.copy();
finishItem(m_Doc->Items->at(z));
}
else if ((STag == "svg:circle") || (STag == "svg:ellipse"))
{
x1 = ScCLocale::toDoubleC(pg.attribute("r")) * Conversion;
y1 = ScCLocale::toDoubleC(pg.attribute("r")) * Conversion;
x2 = ScCLocale::toDoubleC(pg.attribute("cx")) * Conversion - x1;
y2 = ScCLocale::toDoubleC(pg.attribute("cy")) * Conversion - y1;
x1 *= 2.0;
y1 *= 2.0;
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, baseX + x1, baseY + y1, x2, y2, strokewidth, FillCol, StrokeCol, true);
m_Doc->Items->at(z)->setLineJoin(LineJoin);
m_Doc->Items->at(z)->setLineEnd(LineEnd);
finishItem(m_Doc->Items->at(z));
}
else if (STag == "svg:path")
{
poly = parseSVG( pg.attribute( "d" ), &PoLine );
if (PoLine.size() < 4)
{
DOC = DOC.nextSibling();
continue;
}
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, FillCol, StrokeCol, true);
示例4: loadProperties
//.........这里部分代码省略.........
/* Grid X resolution */
str = tag.attribute(KXMLQLCVCPropertiesGridXResolution);
setGridX(str.toInt());
/* Grid Y resolution */
str = tag.attribute(KXMLQLCVCPropertiesGridYResolution);
setGridY(str.toInt());
/* Grid enabled */
str = tag.attribute(KXMLQLCVCPropertiesGridEnabled);
if (str == KXMLQLCTrue)
setGridEnabled(true);
else
setGridEnabled(false);
}
else if (tag.tagName() == KXMLQLCVCPropertiesKeyboard)
{
/* Keyboard grab */
str = tag.attribute(KXMLQLCVCPropertiesKeyboardGrab);
if (str == KXMLQLCTrue)
setGrabKeyboard(true);
else
setGrabKeyboard(false);
/* Key repeat */
str = tag.attribute(KXMLQLCVCPropertiesKeyboardRepeatOff);
if (str == KXMLQLCTrue)
setKeyRepeatOff(true);
else
setKeyRepeatOff(false);
}
else if (tag.tagName() == KXMLQLCVCPropertiesDefaultSlider)
{
t_bus_value low = 0;
t_bus_value high = 10;
t_input_universe universe = KInputUniverseInvalid;
t_input_channel channel = KInputChannelInvalid;
QDomElement subtag;
/* Bus low limit */
str = tag.attribute(KXMLQLCVCPropertiesLowLimit);
if (str.isNull() == false)
low = t_bus_value(str.toInt());
/* Bus high limit */
str = tag.attribute(KXMLQLCVCPropertiesHighLimit);
if (str.isNull() == false)
high = t_bus_value(str.toInt());
/* Sliders' visibility (on by default) */
str = tag.attribute(KXMLQLCVCPropertiesDefaultSliderVisible);
if (str == KXMLQLCFalse)
setSlidersVisible(false);
else
setSlidersVisible(true);
/* External input */
subtag = tag.firstChild().toElement();
if (subtag.isNull() == false &&
subtag.tagName() == KXMLQLCVCPropertiesInput)
{
/* Universe */
str = subtag.attribute(KXMLQLCVCPropertiesInputUniverse);
if (str.isNull() == false)
universe = str.toInt();
/* Channel */
str = subtag.attribute(KXMLQLCVCPropertiesInputChannel);
if (str.isNull() == false)
channel = str.toInt();
}
/* Set the gathered properties to the correct slider */
if (tag.attribute(KXMLQLCBusRole) == KXMLQLCBusFade)
{
setFadeLimits(low, high);
setFadeInputSource(universe, channel);
}
else
{
setHoldLimits(low, high);
setHoldInputSource(universe, channel);
}
}
else if (tag.tagName() == KXMLQLCWidgetProperties)
{
QLCWidgetProperties::loadXML(&tag);
}
else
{
qDebug() << "Unknown virtual console property tag:"
<< tag.tagName();
}
/* Next node */
node = node.nextSibling();
}
return true;
}
示例5: loadXML
bool VCSpeedDialPreset::loadXML(const QDomElement &root)
{
QDomNode node;
QDomElement tag;
if (root.tagName() != KXMLQLCVCSpeedDialPreset)
{
qWarning() << Q_FUNC_INFO << "Speed Dial Preset node not found";
return false;
}
if (root.hasAttribute(KXMLQLCVCSpeedDialPresetID) == false)
{
qWarning() << Q_FUNC_INFO << "Speed Dial Preset ID not found";
return false;
}
m_id = root.attribute(KXMLQLCVCSpeedDialPresetID).toUInt();
/* Children */
node = root.firstChild();
while (node.isNull() == false)
{
tag = node.toElement();
if (tag.tagName() == KXMLQLCVCSpeedDialPresetName)
{
m_name = tag.text();
}
else if (tag.tagName() == KXMLQLCVCSpeedDialPresetShowName)
{
m_showName = (tag.text() == KXMLQLCTrue);
}
else if (tag.tagName() == KXMLQLCVCSpeedDialPresetValue)
{
m_value = tag.text().toInt();
}
else if (tag.tagName() == KXMLQLCVCSpeedDialPresetInput)
{
if (tag.hasAttribute(KXMLQLCVCSpeedDialPresetInputUniverse) &&
tag.hasAttribute(KXMLQLCVCSpeedDialPresetInputChannel))
{
quint32 uni = tag.attribute(KXMLQLCVCSpeedDialPresetInputUniverse).toUInt();
quint32 ch = tag.attribute(KXMLQLCVCSpeedDialPresetInputChannel).toUInt();
m_inputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(uni, ch));
uchar min = 0, max = UCHAR_MAX;
if (tag.hasAttribute(KXMLQLCVCWidgetInputLowerValue))
min = uchar(tag.attribute(KXMLQLCVCWidgetInputLowerValue).toUInt());
if (tag.hasAttribute(KXMLQLCVCWidgetInputUpperValue))
max = uchar(tag.attribute(KXMLQLCVCWidgetInputUpperValue).toUInt());
m_inputSource->setRange(min, max);
}
}
else if (tag.tagName() == KXMLQLCVCSpeedDialPresetKey)
{
m_keySequence = VCWidget::stripKeySequence(QKeySequence(tag.text()));
}
else
{
qWarning() << Q_FUNC_INFO << "Unknown VCSpeedDialPreset tag:" << tag.tagName();
}
node = node.nextSibling();
}
return true;
}
示例6: loadDetailsFromXML
static bool loadDetailsFromXML(const QString &filename, FileDetails *details)
{
QDomDocument doc("mydocument");
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
return false;
if (!doc.setContent(&file))
{
file.close();
return false;
}
file.close();
QString docType = doc.doctype().name();
if (docType == "MYTHARCHIVEITEM")
{
QDomNodeList itemNodeList = doc.elementsByTagName("item");
QString type, dbVersion;
if (itemNodeList.count() < 1)
{
LOG(VB_GENERAL, LOG_ERR,
"Couldn't find an 'item' element in XML file");
return false;
}
QDomNode n = itemNodeList.item(0);
QDomElement e = n.toElement();
type = e.attribute("type");
dbVersion = e.attribute("databaseversion");
if (type == "recording")
{
QDomNodeList nodeList = e.elementsByTagName("recorded");
if (nodeList.count() < 1)
{
LOG(VB_GENERAL, LOG_ERR,
"Couldn't find a 'recorded' element in XML file");
return false;
}
n = nodeList.item(0);
e = n.toElement();
n = e.firstChild();
while (!n.isNull())
{
e = n.toElement();
if (!e.isNull())
{
if (e.tagName() == "title")
details->title = e.text();
if (e.tagName() == "subtitle")
details->subtitle = e.text();
if (e.tagName() == "starttime")
details->startTime = MythDate::fromString(e.text());
if (e.tagName() == "description")
details->description = e.text();
}
n = n.nextSibling();
}
// get channel info
n = itemNodeList.item(0);
e = n.toElement();
nodeList = e.elementsByTagName("channel");
if (nodeList.count() < 1)
{
LOG(VB_GENERAL, LOG_ERR,
"Couldn't find a 'channel' element in XML file");
details->chanID = "";
details->chanNo = "";
details->chanName = "";
details->callsign = "";
return false;
}
n = nodeList.item(0);
e = n.toElement();
details->chanID = e.attribute("chanid");
details->chanNo = e.attribute("channum");
details->chanName = e.attribute("name");
details->callsign = e.attribute("callsign");
return true;
}
else if (type == "video")
{
QDomNodeList nodeList = e.elementsByTagName("videometadata");
if (nodeList.count() < 1)
{
LOG(VB_GENERAL, LOG_ERR,
"Couldn't find a 'videometadata' element in XML file");
return false;
}
n = nodeList.item(0);
e = n.toElement();
//.........这里部分代码省略.........
示例7: save
void Fixture_Test::save()
{
QLCFixtureDef* fixtureDef;
fixtureDef = m_doc->fixtureDefCache()->fixtureDef("Martin", "MAC250+");
Q_ASSERT(fixtureDef != NULL);
QLCFixtureMode* fixtureMode;
fixtureMode = fixtureDef->modes().at(0);
Q_ASSERT(fixtureMode != NULL);
Fixture fxi(this);
fxi.setID(1337);
fxi.setName("Test Fixture");
fxi.setUniverse(2);
fxi.setAddress(438);
fxi.setFixtureDefinition(fixtureDef, fixtureMode);
QDomDocument doc;
QDomElement root = doc.createElement("TestRoot");
QVERIFY(fxi.saveXML(&doc, &root) == true);
QDomNode node = root.firstChild();
QVERIFY(node.toElement().tagName() == "Fixture");
bool manufacturer = false, model = false, mode = false, name = false,
channels = false, universe = false, address = false, id = false;
node = node.firstChild();
while (node.isNull() == false)
{
QDomElement e = node.toElement();
if (e.tagName() == "Manufacturer")
{
QVERIFY(e.text() == "Martin");
manufacturer = true;
}
else if (e.tagName() == "Model")
{
QVERIFY(e.text() == "MAC250+");
model = true;
}
else if (e.tagName() == "Mode")
{
QVERIFY(e.text() == fixtureMode->name());
mode = true;
}
else if (e.tagName() == "ID")
{
QVERIFY(e.text() == "1337");
id = true;
}
else if (e.tagName() == "Name")
{
QVERIFY(e.text() == "Test Fixture");
name = true;
}
else if (e.tagName() == "Universe")
{
QVERIFY(e.text() == "2");
universe = true;
}
else if (e.tagName() == "Address")
{
QVERIFY(e.text() == "438");
address = true;
}
else if (e.tagName() == "Channels")
{
QVERIFY(e.text().toInt()
== fixtureMode->channels().count());
channels = true;
}
else
{
QFAIL(QString("Unexpected tag: %1").arg(e.tagName())
.toLatin1());
}
node = node.nextSibling();
}
QVERIFY(manufacturer == true);
QVERIFY(model == true);
QVERIFY(mode == true);
QVERIFY(id == true);
QVERIFY(name == true);
QVERIFY(universe == true);
QVERIFY(address == true);
QVERIFY(channels == true);
}
示例8: buttonSaveClicked
void QERecipe::buttonSaveClicked()
{
QDomElement rootElement;
QDomElement recipeElement;
QDomElement processVariableElement;
QDomNode rootNode;
_Field *fieldInfo;
QString currentName;
QString name;
int count;
int i;
currentName = qComboBoxRecipeList->currentText();
if (QMessageBox::question(this, "Info", "Do you want to save the values in recipe '" + currentName + "'?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{
count = 0;
rootElement = document.documentElement();
if (rootElement.tagName() == "epicsqt")
{
rootNode = rootElement.firstChild();
while (rootNode.isNull() == false)
{
recipeElement = rootNode.toElement();
if (recipeElement.tagName() == "recipe")
{
if (recipeElement.attribute("name").isEmpty())
{
name= "Recipe #" + QString::number(count);
count++;
}
else
{
name = recipeElement.attribute("name");
}
if (currentName.compare(name) == 0)
{
break;
}
}
rootNode = rootNode.nextSibling();
}
}
while (recipeElement.hasChildNodes())
{
recipeElement.removeChild(recipeElement.lastChild());
}
for(i = 0; i < qEConfiguredLayoutRecipeFields->currentFieldList.size(); i++)
{
fieldInfo = qEConfiguredLayoutRecipeFields->currentFieldList.at(i);
processVariableElement = document.createElement("processvariable");
processVariableElement.setAttribute("name", fieldInfo->getProcessVariable());
if (fieldInfo->getType() == BUTTON)
{
}
else if (fieldInfo->getType() == LABEL)
{
}
else if (fieldInfo->getType() == SPINBOX)
{
processVariableElement.setAttribute("value", ((QESpinBox *) fieldInfo->qeWidget)->text());
}
else if (fieldInfo->getType() == COMBOBOX)
{
processVariableElement.setAttribute("value", ((QEComboBox *) fieldInfo->qeWidget)->currentText());
}
else
{
processVariableElement.setAttribute("value", ((QELineEdit *) fieldInfo->qeWidget)->text());
}
recipeElement.appendChild(processVariableElement);
}
if (saveRecipeList())
{
QMessageBox::information(this, "Info", "The recipe '" + currentName + "' was successfully saved!");
}
else
{
// TODO: restore original document if there is an error
QMessageBox::critical(this, "Error", "Unable to save recipe '" + currentName + "' in file '" + filename + "'!");
}
}
}
示例9: refreshRecipeList
void QERecipe::refreshRecipeList()
{
QDomElement rootElement;
QDomElement recipeElement;
QDomNode rootNode;
QString visible;
QString tmp;
bool flag;
int count;
int i;
qComboBoxRecipeList->blockSignals(true);
tmp = qComboBoxRecipeList->currentText();
qComboBoxRecipeList->clear();
rootElement = document.documentElement();
if (rootElement.tagName() == "epicsqt")
{
count = 0;
rootNode = rootElement.firstChild();
while (rootNode.isNull() == false)
{
recipeElement = rootNode.toElement();
if (recipeElement.tagName() == "recipe")
{
visible = recipeElement.attribute("visible").toUpper();
if (visible.isEmpty())
{
flag = true;
}
else
{
if (visible == "USER")
{
flag = true;
}
else if (visible == "SCIENTIST")
{
flag = (currentUserType > 0);
}
else if (visible == "ENGINEER")
{
flag = (currentUserType > 1);
}
else
{
flag = false;
}
}
if (flag)
{
if (recipeElement.attribute("name").isEmpty())
{
qComboBoxRecipeList->addItem("Recipe #" + QString::number(count));
count++;
}
else
{
qComboBoxRecipeList->addItem(recipeElement.attribute("name"));
}
}
}
rootNode = rootNode.nextSibling();
}
}
i = qComboBoxRecipeList->findText(tmp);
if (i == -1)
{
qComboBoxRecipeList->setCurrentIndex(0);
}
else
{
qComboBoxRecipeList->setCurrentIndex(i);
}
refreshButton();
qComboBoxRecipeList->blockSignals(false);
}
示例10: 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" );
// 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();
}
unlock();
}
示例11: buttonNewClicked
void QERecipe::buttonNewClicked()
{
QDomElement rootElement;
QDomElement recipeElement;
QDomElement processVariableElement;
QDomNode rootNode;
_Field *fieldInfo;
QString currentName;
QString name;
QString visible;
bool flag;
int count;
int i;
do
{
name = QInputDialog::getText(this, "New Recipe", "Name:", QLineEdit::Normal , "", &flag);
}
while(flag && name.isEmpty());
if (name.isEmpty() == false)
{
flag = true;
count = 0;
rootElement = document.documentElement();
if (rootElement.tagName() == "epicsqt")
{
rootNode = rootElement.firstChild();
while (rootNode.isNull() == false)
{
recipeElement = rootNode.toElement();
if (recipeElement.tagName() == "recipe")
{
if (recipeElement.attribute("name").isEmpty())
{
currentName = "Recipe #" + QString::number(count);
count++;
}
else
{
currentName = recipeElement.attribute("name");
}
if (currentName.compare(name) == 0)
{
flag = false;
break;
}
}
rootNode = rootNode.nextSibling();
}
}
if (flag == false)
{
visible = recipeElement.attribute("visible").toUpper();
if (visible.isEmpty())
{
flag = true;
}
else if (visible == "USER")
{
flag = true;
}
else if (visible == "SCIENTIST")
{
flag = (currentUserType > 0);
}
else if (visible == "ENGINEER")
{
flag = (currentUserType > 1);
}
else
{
flag = false;
}
if (flag)
{
flag = (QMessageBox::question(this, "Info", "Do you want to replace existing recipe '" + name + "'?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes);
if (flag)
{
rootElement.removeChild(rootNode);
}
}
else
{
QMessageBox::warning(this, "Warning", "Unable to create recipe '" + name + "' since it already exists and belongs to another user type with more priviledges!");
}
}
else
{
switch (currentUserType)
{
case userLevelTypes::USERLEVEL_USER:
visible = "USER";
break;
case userLevelTypes::USERLEVEL_SCIENTIST:
visible = "SCIENTIST";
break;
default:
//.........这里部分代码省略.........
示例12: setDocument
void RenderWindow::setDocument(const QDomDocument & doc)
{
QDomElement root = doc.documentElement();
if(root.tagName() != "report")
{
QMessageBox::critical(this, tr("Not a Valid Report"),
tr("The report definition does not appear to be a valid report."
"\n\nThe root node is not 'report'."));
return;
}
_doc = doc;
_reportInfo->setEnabled(true);
_reportName->setText(QString::null);
_reportTitle->setText(QString::null);
_reportDescription->setText(QString::null);
for(QDomNode n = root.firstChild(); !n.isNull(); n = n.nextSibling())
{
if(n.nodeName() == "name")
_reportName->setText(n.firstChild().nodeValue());
else if(n.nodeName() == "title")
_reportTitle->setText(n.firstChild().nodeValue());
else if(n.nodeName() == "description")
_reportDescription->setText(n.firstChild().nodeValue());
else if(n.nodeName() == "parameter")
{
QDomElement elemSource = n.toElement();
ORParameter param;
param.name = elemSource.attribute("name");
if(param.name.isEmpty())
continue;
param.type = elemSource.attribute("type");
param.defaultValue = elemSource.attribute("default");
param.active = (elemSource.attribute("active") == "true");
param.listtype = elemSource.attribute("listtype");
QList<QPair<QString,QString> > pairs;
if(param.listtype.isEmpty())
param.description = elemSource.text();
else
{
QDomNodeList section = elemSource.childNodes();
for(int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++)
{
QDomElement elemThis = section.item(nodeCounter).toElement();
if(elemThis.tagName() == "description")
param.description = elemThis.text();
else if(elemThis.tagName() == "query")
param.query = elemThis.text();
else if(elemThis.tagName() == "item")
param.values.append(qMakePair(elemThis.attribute("value"), elemThis.text()));
else
qDebug("While parsing parameter encountered an unknown element: %s",elemThis.tagName().toLatin1().data());
}
}
QVariant defaultVar;
if(!param.defaultValue.isEmpty())
defaultVar = QVariant(param.defaultValue);
if("integer" == param.type)
defaultVar = defaultVar.toInt();
else if("double" == param.type)
defaultVar = defaultVar.toDouble();
else if("bool" == param.type)
defaultVar = QVariant(defaultVar.toBool());
else
defaultVar = defaultVar.toString();
updateParam(param.name, defaultVar, param.active);
QList<QPair<QString, QString> > list;
if("static" == param.listtype)
list = param.values;
else if("dynamic" == param.listtype && !param.query.isEmpty())
{
//qDebug() << "RenderWindow::setDocument :" << param.query; // MANU
QSqlQuery qry(param.query);
while(qry.next())
list.append(qMakePair(qry.value(0).toString(), qry.value(1).toString()));
}
if(!list.isEmpty())
_lists.insert(param.name, list);
}
}
}
示例13: fstatus
SVNHandler::FileStatus SVNHandler::fstatus( const QString& filename ) const
{
// no valid repository
if ( !_isPORepository )
return NO_REPOSITORY;
QString fn( filename );
fn = fn.remove( QRegExp( "/$" ) );
QFileInfo info( fn );
// check if '.svn/entries' exists.
QFile entries( info.dir( true ).path( ) + "/.svn/entries" );
if ( !entries.exists() )
return NOT_IN_SVN;
KProcess proc;
SVNOutputCollector out( &proc );
proc << "svn" << "status" << "-v" << "--xml" << info.absFilePath();
if( !proc.start( KProcess::Block, KProcess::Stdout ) )
return ERROR_IN_WC;
QDomDocument doc;
QString errorMsg;
int errorLine, errorCol;
QDomNodeList nodelist;
QDomNode node;
QDomElement entry, wcStatus;
// Parse the output.
if ( !doc.setContent( out.getOutput(), &errorMsg, &errorLine, &errorCol ) ) {
kdDebug(8109) << "Cannot parse \"svn status -v --xml\" output for"
<< filename << endl << "Line: " << errorLine << " Column: "
<< errorCol << " Error: " << errorMsg << endl;
goto no_status_xml;
}
// There should be only one "entry" element. If it doesn't exist, path
// isn't repo path at all.
nodelist = doc.elementsByTagName("entry");
if (nodelist.count() < 1)
return NOT_IN_SVN;
entry = nodelist.item(0).toElement();
// Shouldn't fail, but just in case there is some weird error.
if ( entry.attributeNode("path").value() != info.absFilePath() )
return ERROR_IN_WC;
for ( node = entry.firstChild(); !node.isNull(); node = node.nextSibling() ) {
if ( !node.isElement() )
continue;
if (node.toElement().tagName() == "wc-status")
break;
}
if ( node.isNull() )
return ERROR_IN_WC;
wcStatus = node.toElement();
if ( wcStatus.attributeNode("item").value() == "normal" )
return UP_TO_DATE;
if ( wcStatus.attributeNode("item").value() == "modified" )
return LOCALLY_MODIFIED;
if ( wcStatus.attributeNode("item").value() == "conflicted" )
return CONFLICT;
if ( wcStatus.attributeNode("item").value() == "unversioned" )
return NOT_IN_SVN;
// TODO Ignored entry should have separate return value probably.
if ( wcStatus.attributeNode("item").value() == "ignored" )
return NOT_IN_SVN;
if ( wcStatus.attributeNode("item").value() == "added" )
return LOCALLY_ADDED;
if ( wcStatus.attributeNode("item").value() == "deleted" )
return LOCALLY_REMOVED;
// TODO What to do with "missing", "incomplete", "replaced", "merged",
// "obstructed", "external"? Can these appear at all in our case?
return ERROR_IN_WC;
no_status_xml:
if ( !entries.open( IO_ReadOnly ) )
return ERROR_IN_WC; // we already know that it is a repository
// Parse the entries file
if ( !doc.setContent( &entries, &errorMsg, &errorLine, &errorCol ) ) {
kdDebug() << "Cannot parse .svn/entries file for " << filename << endl
<< "Line: " << errorLine << " Column: " << errorCol << " Error: " << errorMsg << endl;
return ERROR_IN_WC;
}
entries.close();
QDomElement element;
// File name that we are searching
const QString findName = info.fileName();
// The entries are <entry> elements, so we have to check them
//.........这里部分代码省略.........
示例14: loadXML
bool VCMatrix::loadXML(const QDomElement *root)
{
QDomNode node;
QDomElement tag;
QString str;
Q_ASSERT(root != NULL);
if (root->tagName() != KXMLQLCVCMatrix)
{
qWarning() << Q_FUNC_INFO << "Matrix node not found";
return false;
}
/* Widget commons */
loadXMLCommon(root);
/* Children */
node = root->firstChild();
while (node.isNull() == false)
{
tag = node.toElement();
if (tag.tagName() == KXMLQLCWindowState)
{
bool visible = false;
int x = 0;
int y = 0;
int w = 0;
int h = 0;
loadXMLWindowState(&tag, &x, &y, &w, &h, &visible);
setGeometry(x, y, w, h);
}
else if (tag.tagName() == KXMLQLCVCWidgetAppearance)
{
loadXMLAppearance(&tag);
}
else if (tag.tagName() == KXMLQLCVCMatrixFunction)
{
str = tag.attribute(KXMLQLCVCMatrixFunctionID);
setFunction(str.toUInt());
if (tag.hasAttribute(KXMLQLCVCMatrixInstantApply))
setInstantChanges(true);
}
else if (tag.tagName() == KXMLQLCVCWidgetInput)
{
loadXMLInput(&tag);
}
else if(tag.tagName() == KXMLQLCVCMatrixControl)
{
VCMatrixControl *control = new VCMatrixControl(0xFF);
if (control->loadXML(tag) == false)
delete control;
else
addCustomControl(control);
}
else
{
qWarning() << Q_FUNC_INFO << "Unknown VCMatrix tag:" << tag.tagName();
}
node = node.nextSibling();
}
return true;
}
示例15: fromXml
void TupProject::fromXml(const QString &xml)
{
QDomDocument document;
if (!document.setContent(xml))
return;
QDomElement root = document.documentElement();
QDomNode n = root.firstChild();
int i = 0;
while (!n.isNull()) {
QDomElement e = n.toElement();
if (!e.isNull()) {
if (e.tagName() == "project") {
setProjectName(e.attribute("name", projectName()));
QDomNode n1 = e.firstChild();
e = n1.toElement();
if (e.tagName() == "meta") {
QDomNode n1 = e.firstChild();
while (!n1.isNull()) {
QDomElement e1 = n1.toElement();
if (e1.tagName() == "author") {
if (e1.firstChild().isText())
setAuthor(e1.text());
} else if (e1.tagName() == "bgcolor") {
if (e1.text().isEmpty())
setBgColor(QColor("#ffffff"));
else
setBgColor(QColor(e1.text()));
} else if (e1.tagName() == "description") {
if (e1.firstChild().isText())
setDescription(e1.text());
} else if (e1.tagName() == "dimension") {
if (e1.firstChild().isText()) {
QStringList list = e1.text().split(",");
int x = list.at(0).toInt();
int y = list.at(1).toInt();
QSize size(x,y);
setDimension(size);
}
} else if (e1.tagName() == "fps") {
if (e1.firstChild().isText())
setFPS(e1.text().toInt());
}
n1 = n1.nextSibling();
}
}
}
}
n = n.nextSibling();
i++;
}
}