本文整理汇总了C++中QXmlAttributes::index方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlAttributes::index方法的具体用法?C++ QXmlAttributes::index怎么用?C++ QXmlAttributes::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlAttributes
的用法示例。
在下文中一共展示了QXmlAttributes::index方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
PercussionMap::startElement(const QString& /*namespaceURI*/,
const QString& /*localName*/,
const QString& qName,
const QXmlAttributes& atts)
{
if (qName.toLower() == "percussion-map") {
m_data.clear();
} else if (qName.toLower() == "instrument") {
m_xmlPitchIn = atts.value("pitch").toInt();
m_xmlPitchOut = m_xmlPitchIn;
m_xmlNotehead = "normal";
m_xmlStemUp = true;
} else if (qName.toLower() == "display") {
if (atts.index("pitch") >= 0) {
m_xmlPitchOut = atts.value("pitch").toInt();
}
if (atts.index("notehead") >= 0) {
m_xmlNotehead = atts.value("notehead").toStdString();
}
if (atts.index("stem") >= 0) {
m_xmlStemUp = (atts.value("stem") == "down") ? false : true;
}
}
return true;
}
示例2: startElement
bool ChordXmlHandler::startElement(const QString& /* namespaceURI */,
const QString& /* localName */,
const QString& qName,
const QXmlAttributes& atts)
{
QString lcName = qName.toLower();
if (lcName == "chordset") {
// start new chord set
m_currentRoot = atts.value("root").trimmed();
} else if (lcName == "chord") {
m_currentChord = Guitar::Chord(m_currentRoot);
if (atts.index("ext") >= 0)
m_currentChord.setExt(atts.value("ext").trimmed());
if (atts.index("user") >= 0) {
QString userVal = atts.value("user").trimmed().toLower();
bool res = (userVal == "yes" || userVal == "1" || userVal == "true");
m_currentChord.setUserChord(res);
} else {
m_currentChord.setUserChord(false);
}
} else if (lcName == "fingering") {
m_inFingering = true;
}
return true;
}
示例3: convertAttributesToColor
bool QtSkin::convertAttributesToColor(const QString& aName, const QXmlAttributes& theAttributes, QColor& aColor)
{
int redIndex=theAttributes.index("red");
int greenIndex=theAttributes.index("green");
int blueIndex=theAttributes.index("blue");
if(redIndex<0 || greenIndex<0 || blueIndex<0)
{
setErrorMessage("Invalid attributes for color "+aName);
return false;
}
else
{
int red, green, blue;
if(!convertStringToInteger(theAttributes.value(redIndex), red))
{
setErrorMessage("Invalid red: "+theAttributes.value(redIndex)+" for "+aName);
return false;
}
if(!convertStringToInteger(theAttributes.value(greenIndex), green))
{
setErrorMessage("Invalid green: "+theAttributes.value(greenIndex)+" for "+aName);
return false;
}
if(!convertStringToInteger(theAttributes.value(blueIndex), blue))
{
setErrorMessage("Invalid blue: "+theAttributes.value(blueIndex)+" for "+aName);
return false;
}
aColor.setRgb(red, green, blue);
}
return true;
}
示例4: startElement
bool LoadXmlContentHandler::startElement(const QString&,
const QString&,
const QString& name,
const QXmlAttributes& attr)
{
if (name == "oldfilter")
{
// clear information about the current filter
m_currentFilterPattern = "";
m_currentMinLevel = 0;
m_currentMaxLevel = 0;
return true;
}
if (name == "regex")
{
m_inRegex =true;
return true;
}
if (name == "level")
{
int index;
// first check for a min
index = attr.index("min");
// if min attribute was found, use it
if (index != -1)
m_currentMinLevel = uint8_t(attr.value(index).toUShort());
// then check for a max
index = attr.index("max");
// if max attribute was found, use it
if (index != -1)
m_currentMaxLevel = uint8_t(attr.value(index).toUShort());
// done
return true;
}
if (name == "section")
{
int index = attr.index("name");
// section is only valid if a name is specified
if (index == -1)
return false;
// get the current type for the name
m_currentType = m_types.type(attr.value(index));
return true;
}
return true;
}
示例5: startElement
bool HelperXmlHandler_EpubTOC::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &atts)
{
// qDebug() << "startElement " << " " << localName;
// for ( int i = 0; i < atts.count(); i++ )
// qDebug() << " " << atts.localName(i) << " " << atts.value(i);
if ( localName == "navMap" )
{
m_inNavMap = true;
return true;
}
if ( !m_inNavMap )
return true;
if ( localName == "navPoint" )
m_indent++;
if ( localName == "text" )
m_inText = true;
if ( localName == "content" )
{
int idx = atts.index( "src" );
if ( idx == -1 )
return false;
m_lastId = atts.value( idx );
checkNewTocEntry();
}
return true;
}
示例6: getAtt
bool XmlParser::getAtt( const QString &name, double *value, bool required,
const QString &elementName, const QXmlAttributes& attribute )
{
// Find the attribute name
int id;
if ( ( id = attribute.index( name ) ) < 0 )
{
if ( required )
{
m_error = QString( "<%1> element is missing the required "
"\"%2=\" attribute." ).arg( elementName ).arg( name ) ;
}
return( false );
}
// Get and return its integer value
bool ok;
*value = attribute.value( id ).toDouble( &ok );
if ( ! ok )
{
m_error = QString( "<%1 %2=\"%3\" > element must be a real number." )
.arg( elementName ).arg( name ).arg( attribute.value( id ) );
return( false );
}
return( true );
}
示例7: indexOf
int indexOf(const QXmlAttributes & attributes, const QString & name,
const QString & type = "CDATA", const bool mandatory = true)
{
const int idx(attributes.index(name));
if (idx < 0 || idx > attributes.length()) { return -1; }
if (attributes.type(idx) != type) { return -1; }
if (mandatory && attributes.value(idx).isEmpty()) { return -1; }
return idx;
}
示例8: handleProperty
bool PropertyParser::handleProperty( const QString &elementName,
const QXmlAttributes& attribute )
{
int id;
QString name, value;
// "name" attribute is required
if ( ( id = attribute.index( "name" ) ) < 0 )
{
trError( "PropertyParser:missingName", elementName, "name" );
return( false );
}
name = attribute.value( id );
// "value" attribute is required
if ( ( id = attribute.index( "value" ) ) < 0 )
{
trError( "PropertyParser:missingAttribute", elementName, name, "value" );
return( false );
}
if ( ( value = attribute.value( id ) ) == "(null)" )
{
value = "";
}
// Find this property in the local Property directory and update it
Property *property;
if ( ( property = m_propDict->find( name ) ) > 0 )
{
if ( ! m_propDict->update( name, value ) )
{
trError( "PropertyParser:badValue",
elementName, name, "value", value );
return( false );
}
}
// Report unknown <property> names here.
else
{
trError( "PropertyParser:badValue", elementName, name, "name", name );
return( false );
}
return( true );
}
示例9: convertAttributesToRectangle
bool QtSkin::convertAttributesToRectangle(const QString& aName, const QXmlAttributes& theAttributes, QRect& aRectangle)
{
int xIndex = theAttributes.index("x");
int yIndex = theAttributes.index("y");
int widthIndex = theAttributes.index("width");
int heightIndex = theAttributes.index("height");
if (xIndex<0 || yIndex<0 || widthIndex < 0 || heightIndex < 0)
{
setErrorMessage("Invalid rectangle attributes for "+aName);
return false;
}
else
{
int x;
if (!convertStringToInteger(theAttributes.value(xIndex), x))
{
setErrorMessage("Invalid x " + theAttributes.value(xIndex)+ " for "+aName);
return false;
}
int y;
if (!convertStringToInteger(theAttributes.value(yIndex), y))
{
setErrorMessage("Invalid y " + theAttributes.value(yIndex)+ " for "+aName);
return false;
}
int width;
if (!convertStringToInteger(theAttributes.value(widthIndex), width))
{
setErrorMessage("Invalid witdh " + theAttributes.value(widthIndex)+ " for "+aName);
return false;
}
int height;
if (!convertStringToInteger(theAttributes.value(heightIndex), height))
{
setErrorMessage("Invalid height " + theAttributes.value(heightIndex)+ " for "+aName);
return false;
}
aRectangle.setRect(x, y, width, height);
return true;
}
}
示例10: startElement
virtual bool startElement(const QString &, const QString &, const QString &qName, const QXmlAttributes &atts)
{
kdDebug(26001) << "CharacterDataSearcher::startElement, qName " << qName << endl;
int pos = atts.index("id");
if(pos > -1 && atts.value(pos) == m_id)
{
m_foundCount++;
m_tagFound = qName;
}
return true;
}
示例11: GetValue
QString GetValue(const QXmlAttributes &pProperties, QString pName, QString pDefault, QString pAlias)
{
//If not found return default value if was defined
if (pProperties.index(pName) == -1 && pDefault != "") return pDefault;
//Define some Variables
if (pAlias == "") pAlias = pName;
QStringList validValues = ValidValues(pAlias);
QString value = pProperties.value(pName);
int index = -1;
//Return original value if not defined valid values
if (validValues.size() == 0) return value;
//Search most correct index of value in validValues array
if (IsEncriptedProperty(pName)) //Get proposed index
{
index = value.toInt();
}
else if (IsNumberProperty(pName)) //Get most proximal valid index to proposed value as number
{
//Temp
float valueFloat = QVariant(value).toFloat();
float diference;
float minimal = std::numeric_limits<float>::max();
//Find most proximal numeric value and it index
QListIterator<QString> i(validValues);
while (i.hasNext())
{
diference = qAbs(valueFloat - i.next().toFloat());
if (minimal > diference)
{
minimal = diference;
index++;
}
else break;
}
}
else //Get index of value
{
index = validValues.indexOf(value);
}
//Return extreme value if index not match with valid one
if (index < 0) return validValues.first(); //First
else if (index > validValues.size() - 1) index = validValues.size() - 1; //Last
//Return correct value
return validValues.value(index);
}
示例12: startElement
bool startElement( const QString & namespaceURI, const QString & localName,
const QString & qName, const QXmlAttributes & atts )
{
std::string id = localName.toUtf8().operator const char *();
auto actionData = std::unique_ptr< QtActionData >( new QtActionData );
auto index = atts.index( "text" );
if (index >= 0)
{
actionData->text_ = atts.value( index ).toUtf8().operator const char *();
}
else
{
actionData->text_ = id;
}
index = atts.index( "icon" );
if (index >= 0)
{
actionData->icon_ = atts.value( index ).toUtf8().operator const char *();
}
index = atts.index( "window" );
if (index >= 0)
{
actionData->windowId_ = atts.value( index ).toUtf8().operator const char *();
}
index = atts.index( "path" );
if (index >= 0)
{
actionData->path_ = atts.value( index ).toUtf8().operator const char *();
}
index = atts.index( "shortcut" );
if (index >= 0)
{
actionData->shortcut_ = atts.value( index ).toUtf8().operator const char *();
}
actionManager_.registerActionData( id.c_str(), actionData );
return true;
}
示例13: startElement
bool GpxParser::startElement( const QString&, const QString&,
const QString& qName,
const QXmlAttributes& qAttributes)
{
buffer.clear();
if(metadata)
return true;
if(qName == "metadata")
{
metadata = true;
}
else if(qName == "trkpt")
{
int i = qAttributes.index("lat");
if(i >= 0)
{
lat = qAttributes.value(i).toDouble();
}
else
{
lat = lastLat;
}
i = qAttributes.index("lon");
if( i >= 0)
{
lon = qAttributes.value(i).toDouble();
}
else
{
lon = lastLon;
}
}
return true;
}
示例14: startElement
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
{
if(depth == 0) {
Parser::Event *e = new Parser::Event;
QXmlAttributes a;
for(int n = 0; n < atts.length(); ++n) {
QString uri = atts.uri(n);
QString ln = atts.localName(n);
if(a.index(uri, ln) == -1)
a.append(atts.qName(n), uri, ln, atts.value(n));
}
e->setDocumentOpen(namespaceURI, localName, qName, a, nsnames, nsvalues);
nsnames.clear();
nsvalues.clear();
e->setActualString(in->lastString());
in->resetLastData();
eventList.append(e);
in->pause(true);
}
else {
QDomElement e = doc->createElementNS(namespaceURI, qName);
for(int n = 0; n < atts.length(); ++n) {
QString uri = atts.uri(n);
QString ln = atts.localName(n);
bool have;
if(!uri.isEmpty()) {
have = e.hasAttributeNS(uri, ln);
if(qt_bug_have)
have = !have;
}
else
have = e.hasAttribute(ln);
if(!have)
e.setAttributeNS(uri, atts.qName(n), atts.value(n));
}
if(depth == 1) {
elem = e;
current = e;
}
else {
current.appendChild(e);
current = e;
}
}
++depth;
return true;
}
示例15: startElement
bool Remote::startElement(const QString &, const QString &, const QString &name, const QXmlAttributes &attributes)
{
if(name == "remote")
theId = theName = attributes.value("id");
else if(name == "button")
{
curRB = new RemoteButton();
curRB->setId(attributes.value("id"));
curRB->setClass(attributes.value("id"));
if(attributes.index("class") > -1)
curRB->setClass(attributes.value("class"));
curRB->setParameter(attributes.value("parameter"));
curRB->setName(attributes.value("id"));
}
charBuffer = "";
return true;
}