Ejemplo n.º 1
0
ConstraintTypes::PlaylistLength::PlaylistLength( QDomElement& xmlelem, ConstraintNode* p )
        : Constraint( p )
        , m_length( 30 )
        , m_comparison( CompareNumEquals )
        , m_strictness( 1.0 )
{
    QDomAttr a;

    a = xmlelem.attributeNode( "length" );
    if ( !a.isNull() ) {
        m_length = a.value().toInt();
        /* after 2.3.2, what was the PlaylistLength constraint became the
         * PlaylistDuration constraint, so this works around the instance when
         * a user loads an XML file generated with the old code -- sth*/
        if ( m_length > 1000 )
            m_length /= 240000;
    }

    a = xmlelem.attributeNode( "comparison" );
    if ( !a.isNull() )
        m_comparison = a.value().toInt();

    a = xmlelem.attributeNode( "strictness" );
    if ( !a.isNull() )
        m_strictness = a.value().toDouble();
}
Ejemplo n.º 2
0
ConstraintTypes::PlaylistDuration::PlaylistDuration( QDomElement& xmlelem, ConstraintNode* p )
        : Constraint( p )
        , m_duration( 0 )
        , m_comparison( CompareNumEquals )
        , m_strictness( 1.0 )
{
    QDomAttr a;

    a = xmlelem.attributeNode( "duration" );
    if ( !a.isNull() ) {
        m_duration = a.value().toInt();
    } else {
        // Accommodate schema change when PlaylistLength became PlaylistDuration
        a = xmlelem.attributeNode( "length" );
        if ( !a.isNull() )
            m_duration = a.value().toInt();
    }


    a = xmlelem.attributeNode( "comparison" );
    if ( !a.isNull() )
        m_comparison = a.value().toInt();

    a = xmlelem.attributeNode( "strictness" );
    if ( !a.isNull() )
        m_strictness = a.value().toDouble();
}
void
Pattern::xmlAddTransition(QDomElement _element)
{
    // a transition must have a message tag
    QDomAttr attrMessage = _element.attributeNode("message");
    if (attrMessage.isNull() ||
            attrMessage.value().isEmpty()) {
        throw BehaviourEngine::
        EMalformedPolicy(CORBA::string_dup("Transition without message."));
    }
    std::string message = attrMessage.value().latin1();

    // a transition must have a target tag
    QDomAttr attrPattern = _element.attributeNode("target");
    if (attrPattern.isNull() ||
            attrPattern.value().isEmpty()) {
        throw BehaviourEngine::
        EMalformedPolicy(CORBA::string_dup("Transition without target."));
    }
    std::string target = attrPattern.value().latin1();

    // internal transitions are only possible within some policy
    if (parent_ == NULL)
        throw BehaviourEngine::
        EMalformedPolicy(CORBA::string_dup("Internal transition at top level."));

    parent_->transitions_.insert(std::make_pair(std::make_pair(getName(),
                                 message),
                                 target));
}
Ejemplo n.º 4
0
void LevelLoader::loadLine(QDomElement lineNode)
{
    // Reading the line number
    QDomAttr attribute = lineNode.attributeNode(QStringLiteral("Number"));
    QDomElement attributeNode = lineNode.firstChildElement(QStringLiteral("Number"));
    if (!attribute.isNull()) {
        m_lineNumber = attribute.value().toInt();
    } else if (!attributeNode.isNull()) {
        m_lineNumber = attributeNode.text().toInt();
    } else {
        // Standard line numbering: load next line
        m_lineNumber++;
    }

    // Reading the brick information
    attribute = lineNode.attributeNode(QStringLiteral("Bricks"));
    attributeNode = lineNode.firstChildElement(QStringLiteral("Bricks"));
    QString line;
    if (!attribute.isNull()) {
        line = attribute.value();
    } else if (!attributeNode.isNull()) {
        line = attributeNode.text();
    } else {
        line = lineNode.text();
    }

    if (line.size() > WIDTH) {
        qCritical() << "Invalid levelset " << m_levelname << ": too many bricks in line "
                    << m_lineNumber << endl;
    }

    emit newLine(line, m_lineNumber);
}
Ejemplo n.º 5
0
ConstraintTypes::PlaylistFileSize::PlaylistFileSize( QDomElement& xmlelem, ConstraintNode* p )
        : Constraint( p )
        , m_size( 700 )
        , m_unit( 1 )
        , m_comparison( CompareNumEquals )
        , m_strictness( 1.0 )
{
    QDomAttr a;

    a = xmlelem.attributeNode( "size" );
    if ( !a.isNull() )
        m_size = a.value().toInt();

    a = xmlelem.attributeNode( "unit" );
    if ( !a.isNull() )
        m_unit = a.value().toInt();

    a = xmlelem.attributeNode( "comparison" );
    if ( !a.isNull() )
        m_comparison = a.value().toInt();

    a = xmlelem.attributeNode( "strictness" );
    if ( !a.isNull() )
        m_strictness = a.value().toDouble();
}
Ejemplo n.º 6
0
void Block::Unmarshall( QDomElement& blockElement, Level* level )
{
  QDomAttr blockRowAttr = blockElement.attributeNode(BLOCK_ROW_ATTR);
  QDomAttr blockColumnAttr = blockElement.attributeNode(BLOCK_COLUMN_ATTR);

  UrAsset::setRow( blockRowAttr.value().toUInt() );
  UrAsset::setColumn( blockColumnAttr.value().toUInt() );
  UrAsset::calculateLevelEditorPosition(level->Row);
}
Ejemplo n.º 7
0
void Language::setAttribute( QDomAttr &attr) {
  if(attr.localName().compare("Value", Qt::CaseInsensitive)==0) {
    setValue(attr.value());
    return;
  }
  if(attr.localName().compare("Lang", Qt::CaseInsensitive)==0) {
    setLang(attr.value());
    return;
  }
}
Ejemplo n.º 8
0
void PreviouslyShown::setAttribute( QDomAttr &attr) {
  if(attr.localName().compare("Channel", Qt::CaseInsensitive)==0) {
    setChannel(attr.value());
    return;
  }
  if(attr.localName().compare("Start", Qt::CaseInsensitive)==0) {
    setStart(attr.value());
    return;
  }
}
  void
  operator <<= (Miro::SensorGroupIDL& group, const QDomNode& node)
  {
    if (!node.isNull()) {

      // set sensor defaults
      Miro::SensorPositionIDL sensor;
      sensor.masked = false;
      QDomNamedNodeMap map = node.attributes();
      QDomNode n;
      n = map.namedItem("height");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.height = attr.value().toInt();
      }
      n = map.namedItem("distance");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.distance =attr.value().toInt();
      }
      n = map.namedItem("alpha");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.alpha = deg2Rad(attr.value().toDouble());
      }
      n = map.namedItem("beta");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.beta = deg2Rad(attr.value().toDouble());
      }
      n = map.namedItem("gamma");
      if (!n.isNull()) {
	QDomAttr attr = n.toAttr();
	if (!attr.isNull()) 
	  sensor.gamma = deg2Rad(attr.value().toDouble());
      }
      QDomNode n1 = node.firstChild();
      while(!n1.isNull() ) {
	if (n1.nodeName() == "description") {
	  group.description <<= n1;
	}
	else if (n1.nodeName() == "sensor") {
	  group.sensor.length(group.sensor.length() + 1);
	  group.sensor[group.sensor.length() - 1] = sensor;
	  group.sensor[group.sensor.length() - 1] <<= n1;
	}
	n1 = n1.nextSibling();
      }
    }
  }
Ejemplo n.º 10
0
void Prefs_KeyboardShortcuts::importKeySet(QString filename)
{
	searchTextLineEdit->clear();
	QFileInfo fi = QFileInfo(filename);
	if (fi.exists())
	{
		//import the file into qdomdoc
		QDomDocument doc( "keymapentries" );
		QFile file1( filename );
		if ( !file1.open( QIODevice::ReadOnly ) )
			return;
		QTextStream ts(&file1);
		ts.setCodec("UTF-8");
		QString errorMsg;
		int eline;
		int ecol;
		if ( !doc.setContent( ts.readAll(), &errorMsg, &eline, &ecol ))
		{
			qDebug("%s", QString("Could not open key set file: %1\nError:%2 at line: %3, row: %4").arg(filename).arg(errorMsg).arg(eline).arg(ecol).toLatin1().constData());
			file1.close();
			return;
		}
		file1.close();
		//load the file now
		QDomElement docElem = doc.documentElement();
		if (docElem.tagName()=="shortcutset" && docElem.hasAttribute("name"))
		{
			QDomAttr keysetAttr = docElem.attributeNode( "name" );

			//clear current menu entries
			for (QMap<QString,Keys>::Iterator it=keyMap.begin(); it!=keyMap.end(); ++it)
				it.value().keySequence = QKeySequence();

			//load in new set
			QDomNode n = docElem.firstChild();
			while( !n.isNull() )
			{
				QDomElement e = n.toElement(); // try to convert the node to an element.
				if( !e.isNull() )
				{
					if (e.hasAttribute("name")  && e.hasAttribute( "shortcut" ))
					{
						QDomAttr nameAttr = e.attributeNode( "name" );
						QDomAttr shortcutAttr = e.attributeNode( "shortcut" );
						if (keyMap.contains(nameAttr.value()))
							keyMap[nameAttr.value()].keySequence=QKeySequence(shortcutAttr.value());
					}
				}
				n = n.nextSibling();
			}
		}
	}
	insertActions();
}
Ejemplo n.º 11
0
void LevelLoader::loadGift(QDomElement giftNode)
{
    bool nodeTextRead = false;
    // Reading the brick type
    QDomAttr attribute = giftNode.attributeNode(QStringLiteral("Type"));
    QDomElement attributeNode = giftNode.firstChildElement(QStringLiteral("Type"));
    QString giftType;
    if (!attribute.isNull()) {
        giftType = attribute.value();
    } else if (!attributeNode.isNull()) {
        giftType = attributeNode.text();
        nodeTextRead = true;
    } else {
        giftType = giftNode.text();
        nodeTextRead = true;
    }

    // Reading number of gifts to be distributed. If not specified one gift is placed.
    attribute = giftNode.attributeNode(QStringLiteral("Count"));
    attributeNode = giftNode.firstChildElement(QStringLiteral("Count"));
    int times = 1;
    bool ok = true;
    if (!attribute.isNull()) {
        times = attribute.value().toInt(&ok);
    } else if (!attributeNode.isNull()) {
        times = attributeNode.text().toInt(&ok);
        nodeTextRead = true;
    } else if (!nodeTextRead) {
        times = giftNode.text().toInt(&ok);
        if (!ok) {
            times = 1;
        }
    }

    // If only one brick to be placed: see if position is given
    QString position;
    if (times == 1) {
        attribute = giftNode.attributeNode(QStringLiteral("Position"));
        attributeNode = giftNode.firstChildElement(QStringLiteral("Position"));
        if (!attribute.isNull()) {
            position = attribute.value();
        } else if (!attributeNode.isNull()) {
            position = attributeNode.text();
            nodeTextRead = true;
        } else if (!nodeTextRead && giftNode.text().contains(QLatin1Char(','))) {
            position = giftNode.text();
            nodeTextRead = true;
        }
    }

    emit newGift(giftType, times, position);
}
Ejemplo n.º 12
0
void UBOEmbedParser::parse(const QString& html)
{
    mContents.clear();
    QString query = "<link([^>]*)>";
    QRegExp exp(query);
    QStringList results;
    int count = 0;
    int pos = 0;
    while ((pos = exp.indexIn(html, pos)) != -1) {
        ++count;
        pos += exp.matchedLength();
        QStringList res = exp.capturedTexts();
        if("" != res.at(1)) {
            results << res.at(1);
        }
    }

    QVector<QString> oembedUrls;

    if(2 <= results.size()) {
        for(int i=1; i<results.size(); i++) {
            if("" != results.at(i)) {
                QString qsNode = QString("<link%0>").arg(results.at(i));
                QDomDocument domDoc;
                domDoc.setContent(qsNode);
                QDomNode linkNode = domDoc.documentElement();

                //  At this point, we have a node that is the <link> element. Now we have to parse its attributes
                //  in order to check if it is a oEmbed node or not
                QDomAttr typeAttribute = linkNode.toElement().attributeNode("type");
                if(typeAttribute.value().contains("oembed")) {
                    // The node is an oembed one! We have to get the url and the type of oembed encoding
                    QDomAttr hrefAttribute = linkNode.toElement().attributeNode("href");
                    QString url = hrefAttribute.value();
                    oembedUrls.append(url);
                }
            }
        }
    }

    mPending = oembedUrls.size();

    if(0 == mPending) {
        emit oembedParsed(mContents);
    } else {
        // Here we start the parsing (finally...)!
        for(int i=0; i<oembedUrls.size(); i++) {
            emit parseContent(oembedUrls.at(i));
        }
    }
}
Ejemplo n.º 13
0
void Programme::setAttribute( QDomAttr &attr) {
  if(attr.localName().compare("VpsStart", Qt::CaseInsensitive)==0) {
    setVpsStart(attr.value());
    return;
  }
  if(attr.localName().compare("Channel", Qt::CaseInsensitive)==0) {
    setChannel(attr.value());
    return;
  }
  if(attr.localName().compare("Showview", Qt::CaseInsensitive)==0) {
    setShowview(attr.value());
    return;
  }
  if(attr.localName().compare("Start", Qt::CaseInsensitive)==0) {
    setStart(attr.value());
    return;
  }
  if(attr.localName().compare("Stop", Qt::CaseInsensitive)==0) {
    setStop(attr.value());
    return;
  }
  if(attr.localName().compare("Clumpidx", Qt::CaseInsensitive)==0) {
    setClumpidx(attr.value());
    return;
  }
  if(attr.localName().compare("PdcStart", Qt::CaseInsensitive)==0) {
    setPdcStart(attr.value());
    return;
  }
  if(attr.localName().compare("Videoplus", Qt::CaseInsensitive)==0) {
    setVideoplus(attr.value());
    return;
  }
}
Ejemplo n.º 14
0
void PrefPortaudio::writeConfig()
{
    /* We can do better error control here, can't we? */
    ISettings *_settings = new ISettings();
    QDomElement cfg = _settings->getConfigNode("portaudio.conf");
    QDomNodeList nl = cfg.elementsByTagName("param");
    for (int i = 0; i < nl.count(); i++) {
        QDomAttr var = nl.at(i).toElement().attributeNode("name");
        QDomAttr val = nl.at(i).toElement().attributeNode("value");
        if (var.value() == "indev") {
            val.setValue(QString::number(_ui->PaIndevCombo->itemData(_ui->PaIndevCombo->currentIndex(), Qt::UserRole).toInt()));
        }
        if (var.value() == "outdev") {
            val.setValue(QString::number(_ui->PaOutdevCombo->itemData(_ui->PaOutdevCombo->currentIndex(), Qt::UserRole).toInt()));
        }
        if (var.value() == "ringdev") {
            val.setValue(QString::number(_ui->PaRingdevCombo->itemData(_ui->PaRingdevCombo->currentIndex(), Qt::UserRole).toInt()));
        }
        if (var.value() == "ring-file") {
            val.setValue(_ui->PaRingFileEdit->text());
        }
        if (var.value() == "ring-interval") {
            val.setValue(QString::number(_ui->PaRingIntervalSpin->value()));
        }
        if (var.value() == "hold-file") {
            val.setValue(_ui->PaHoldFileEdit->text());
        }
        if (var.value() == "cid-name") {
            val.setValue(_ui->PaCallerIdNameEdit->text());
        }
        if (var.value() == "cid-num") {
            val.setValue(_ui->PaCallerIdNumEdit->text());
        }
        if (var.value() == "sample-rate") {
            val.setValue(_ui->PaSampleRateEdit->text());
        }
        if (var.value() == "codec-ms") {
            val.setValue(_ui->PaCodecMSEdit->text());
        }
        /* Not used currently
        if (var.value() == "dialplan") {
            val.setValue();
        }
        if (var.value() == "timer-name") {
            val.setValue();
        }*/
    }
    /* Save the config to the file */
    _settings->setConfigNode(cfg, "portaudio.conf");
}
Ejemplo n.º 15
0
void XSchemaSimpleTypeUnion::scanForAttributes(QDomAttr &attribute, void * /*context*/)
{
    QString name = attribute.nodeName();

    if(name == IO_GENERIC_ID) {
        _id = attribute.value() ;
    } else if(name == IO_SIMPLETYPE_UNION_ATTR_MEMBERTYPES) {
        _memberTypes = attribute.value() ;
    } else {
        if(!readOtherAttributes(attribute)) {
            raiseError(this, attribute, false);
        }
    }
}
Ejemplo n.º 16
0
void XSchemaSimpleTypeRestriction::scanForAttributes(QDomAttr &attribute, void * /*context*/)
{
    QString name = attribute.nodeName();

    if(name == IO_GENERIC_ID) {
        _id = attribute.value() ;
    } else if(name == IO_GENERIC_BASE) {
        _base = attribute.value() ;
    } else {
        if(!readOtherAttributes(attribute)) {
            raiseError(this, attribute, false);
        }
    }
}
Ejemplo n.º 17
0
void OnError::processNodeAttributes(const QDomElement &nodeElement)
{
    // process attributes
    QDomNamedNodeMap namedNodeMap = nodeElement.attributes();
    QDomNode domNode = namedNodeMap.item(0);

    if (domNode.nodeType() == QDomNode::AttributeNode) {
        QDomAttr domElement = domNode.toAttr();

        if (domElement.name() == QLatin1String("Condition"))
            m_condition = domElement.value();
        else if (domElement.name() == QLatin1String("ExecuteTargets"))
            m_executeTargets = domElement.value().split(QLatin1Char(';'));
    }
}
Ejemplo n.º 18
0
bool OsisData::ProcessAttributes(QDomElement& xmlElement)
{
   // Parse and save attributes
   QDomNamedNodeMap attr = xmlElement.attributes();
   int size = attr.size();
   if (!size)
   {
      return false; // Error
   }

   for (int i = 0; i < size; i++)
   {
      QDomAttr at = attr.item(i).toAttr();
      QString value(at.value());
      int key = getEnumKey("OsisElementAttributes", at.name().toLocal8Bit().constData());

      if (key != -1)
      {
         if (Attribute.contains(key))
         {
            Attribute.remove(key);
         }
         Attribute[key] = value;
      }
      else
      {
         qCritical() << "<" << ElementName << ">:  Unknown attribute: " << at.name() << "=" << value << endl;
      }
   }

   return true;
}
Ejemplo n.º 19
0
void Level::Unmarshall( QDomElement& levelElement )
{
  QDomAttr idAttr = levelElement.attributeNode(LEVEL_ID_ATTR);
  QDomAttr nameAttr = levelElement.attributeNode(LEVEL_NAME_ATTR);

  QDomElement descriptionElement = levelElement.firstChildElement(LEVEL_DESCRIPTION_TAG);
  QDomElement sizeElement = levelElement.firstChildElement(LEVEL_SIZE_TAG);
  QDomAttr sizeColumnAttr = sizeElement.attributeNode(LEVEL_SIZE_COLUMN_ATTR);
  QDomAttr sizeRowAttr = sizeElement.attributeNode(LEVEL_SIZE_ROW_ATTR);

  Id = idAttr.value().toUInt();
  Name = nameAttr.value();
  Description = descriptionElement.text();
  Row = sizeRowAttr.value().toUInt();
  Column = sizeColumnAttr.value().toUInt();
}
Ejemplo n.º 20
0
/** 
 * \en
 * insert new row in table and replace tag to value
 * \_en
 * \ru
 * Вставляет новую строку в таблицу, заменяет теги на значения, удаляет тег секции из строки таблицы.
 * Выполняет рекурсивный поиск узла, содержащего строку таблицы. У этого узла есть
 * специальное имя(w:r), которое распознается функцией. После того, как узел найден, строка строка дублируется, 
 * а из текущей строки удаляются все теги секции, чтобы избежать мнократного размножения строк таблицы.
 * \_ru
 * \param node - \en context for inserting \_en \ru узел, в который происходит вставка \_ru 
 * \see searchTags()
 */
void 
aMSOTemplate::insertRowValues(QDomNode node)
{
	QDomNode n = node;
	while(!n.parentNode().isNull())
	{
		n = n.parentNode();
		QDomElement e = n.toElement();
		if( n.nodeName()=="Row" ) 
		{	
			QDomAttr a = n.toElement().attributeNode( "ss:Index" );
			n.parentNode().insertAfter(n.cloneNode(true),n);
			clearTags(n,true);
			
			QMap<QString,QString>::Iterator it;
			for ( it = values.begin(); it != values.end(); ++it )
			{
				searchTags(n,it.key());
			}
			int rowIndex = a.value().toInt();
			if (rowIndex == 0) 
			{
				rowIndex = getRowIndex(n);
				n.toElement().setAttribute("ss:Index",rowIndex);	
			}
			n.nextSibling().toElement().setAttribute("ss:Index",rowIndex+1);	
		}
	}
}
Ejemplo n.º 21
0
static void helperToXmlAddDomElement(QXmlStreamWriter* stream, const QDomElement& element, const QStringList &omitNamespaces)
{
    stream->writeStartElement(element.tagName());

    /* attributes */
    QString xmlns = element.namespaceURI();
    if (!xmlns.isEmpty() && !omitNamespaces.contains(xmlns))
        stream->writeAttribute("xmlns", xmlns);
    QDomNamedNodeMap attrs = element.attributes();
    for (int i = 0; i < attrs.size(); i++)
    {
        QDomAttr attr = attrs.item(i).toAttr();
        stream->writeAttribute(attr.name(), attr.value());
    }

    /* children */
    QDomNode childNode = element.firstChild();
    while (!childNode.isNull())
    {
        if (childNode.isElement())
        {
            helperToXmlAddDomElement(stream, childNode.toElement(), QStringList() << xmlns);
        } else if (childNode.isText()) {
            stream->writeCharacters(childNode.toText().data());
        }
        childNode = childNode.nextSibling();
    }
    stream->writeEndElement();
}
Ejemplo n.º 22
0
QString QDomAttrProto:: value()        const
{
  QDomAttr *item = qscriptvalue_cast<QDomAttr*>(thisObject());
  if (item)
    return item->value();
  return QString();
}
Ejemplo n.º 23
0
QString QDomAttrProto:: toString()     const
{
  QDomAttr *item = qscriptvalue_cast<QDomAttr*>(thisObject());
  if (item)
    return QString("[QDomAttr %1='%2']").arg(item->name()).arg(item->value());
  return QString();
}
BorderDrawerInterface * BorderDrawersLoader::getDrawerFromSvg(QDomElement & drawerElement)
{
    QMap<QString,QString> properties;
    QDomNamedNodeMap attributes = drawerElement.attributes();
    for (int j = attributes.count()-1; j >= 0; --j)
    {
        QDomAttr attr = attributes.item(j).toAttr();
        if (attr.isNull())
            continue;
        properties.insert(attr.name(), attr.value());
    }
    QString drawerName = properties.take("name");
    if (!instance()->registeredDrawers().contains(drawerName))
        return 0;
    BorderDrawerInterface * drawer = getDrawerByName(drawerName);
    const QMetaObject * meta = drawer->metaObject();
    int count = meta->propertyCount();
    for (int i = 0; i < count; ++i)
    {
        QMetaProperty p = meta->property(i);
        QString value = properties.take(p.name());
        if (value.isEmpty())
            continue;
        p.write(drawer, QVariant(QByteArray::fromBase64(value.toAscii())));
    }
    return drawer;
}
Ejemplo n.º 25
0
void NewsSite::parseAtom(QDomDocument domDoc)
{
    QDomNodeList entries = domDoc.elementsByTagName("entry");

    for (unsigned int i = 0; i < (unsigned) entries.count(); i++)
    {
        QDomNode itemNode = entries.item(i);
        QString title =  ReplaceHtmlChar(itemNode.namedItem("title").toElement()
                                         .text().simplified());

        QDomNode summNode = itemNode.namedItem("summary");
        QString description = QString::null;
        if (!summNode.isNull())
        {
            description = ReplaceHtmlChar(
                summNode.toElement().text().simplified());
        }

        QDomNode linkNode = itemNode.namedItem("link");
        QString url = QString::null;
        if (!linkNode.isNull())
        {
            QDomAttr linkHref = linkNode.toElement().attributeNode("href");
            if (!linkHref.isNull())
                url = linkHref.value();
        }

        insertNewsArticle(NewsArticle(title, description, url));
    }
}
Ejemplo n.º 26
0
// Register the various playgrounds
bool PlayGround::registerPlayGrounds(QDomDocument &layoutDocument)
{
  QDomNodeList playGroundsList, menuItemsList, labelsList;
  QDomElement playGroundElement, menuItemElement, labelElement;
  QDomAttr actionAttribute;

  playGroundsList = layoutDocument.elementsByTagName("playground");
  if (playGroundsList.count() < 1)
    return false;

  for (uint i = 0; i < playGroundsList.count(); i++)
  {
    playGroundElement = (const QDomElement &) playGroundsList.item(i).toElement();

    menuItemsList = playGroundElement.elementsByTagName("menuitem");
    if (menuItemsList.count() != 1)
      return false;

    menuItemElement = (const QDomElement &) menuItemsList.item(0).toElement();

    labelsList = menuItemElement.elementsByTagName("label");
    if (labelsList.count() != 1)
      return false;

    labelElement = (const QDomElement &) labelsList.item(0).toElement();
    actionAttribute = menuItemElement.attributeNode("action");
    topLevel->registerGameboard(labelElement.text(), actionAttribute.value().latin1()); 
  }
 
  return true;
}
Ejemplo n.º 27
0
/**
 * This method is designed to parse the object config file
 * and to initialize the required objects in the UIObjectHandler
 */
bool ConfigParser::buildObjects(const QString object_cfgv)
    {
    this->getNodeList(object_cfgv,OBJECT_CFG_TAG);
    /*if at least 1 tag was found proceed otherwise return false*/
    if(!this->temp_node_list->count() > 0)
		{
        this->core->configLogError(QString(MISSING_OBJ_TAG));
		return false;
		}
    /*iterate through the dom nodes*/
    for(int i = 0;i <this->temp_node_list->count();i++)
		{
		QDomNode node = this->temp_node_list->item(i);
		QDomNamedNodeMap map = node.attributes();
		/*iterate through the attributes*/
		for(uint i = 1; i <= map.length();i++)
			{
			if(map.item(i-1).isAttr())
				{
				QDomAttr attr = map.item(i-1).toAttr();
				/* handle the different object types */
				if(attr.name() == OBJECT_CFG_TYPE_ATTR)
					{
					if(attr.value() == OBJECT_TYPE_SCREEN)
						{
						ScreenObject* temp_screen = new ScreenObject();
						temp_screen->buildScreenObject(this,map);
						this->screen_list_ref->append(temp_screen);
						this->core->configLogInfo(this->screen_list_ref->last()->getObjLogEntry());
						}
					else if(attr.value() == OBJECT_TYPE_BUTTON_C)
						{
						ButtonCObject *temp_buttonc = new ButtonCObject();
						temp_buttonc->buildButtonCObject(this,map);
						this->buttonc_list_ref->append(temp_buttonc);
						this->core->configLogInfo(this->buttonc_list_ref->last()->getObjLogEntry());
						}
					else
						{
						this->core->configLogWarning(QString(UNHA_OBJ_TYPE_MSG).replace("#_1",attr.value())+"in "+object_cfgv+" on line "+QString::number(node.lineNumber()));
						}
					}
				}
			}
		}
    return true;
    }
Ejemplo n.º 28
0
void ConfigGuiSunbird::load( const QString &xml )
{
  QString path;
  QString url;
  QString username;
  QString password;
  QString defaultcal;
  QString days;

  QDomDocument doc;
  doc.setContent( xml );
  QDomElement docElement = doc.documentElement();
  QDomNode node;
  for( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
    QDomElement element = node.toElement();
    if ( element.tagName() == "file" ) {
      QDomAttr pathAttr = element.attributeNode( "path" );
      path = pathAttr.value();
      QDomAttr defaultAttr = element.attributeNode( "default" );
      defaultcal = defaultAttr.value();
      QDomAttr daysAttr = element.attributeNode( "deletedaysold" );
      days = daysAttr.value();

      LocalCalendar *cal = new LocalCalendar( path, defaultcal, days, mLocalWidget );
      mLocalLayout->removeItem( mLocalSpacer );
      cal->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
      mLocalLayout->addWidget( cal );
      mLocalLayout->addItem( mLocalSpacer );
      mLocalList.append( cal );

      connect( cal, SIGNAL( deleteRequest( LocalCalendar* ) ), SLOT( delLocalCalendar( LocalCalendar* ) ) );
      cal->show();
    } else if ( element.tagName() == "webdav" ) {
      QDomAttr urlAttr = element.attributeNode( "url" );
      url = urlAttr.value();
      QDomAttr unameAttr = element.attributeNode( "username" );
      username = unameAttr.value();
      QDomAttr pwordAttr = element.attributeNode( "password" );
      password = pwordAttr.value();
      QDomAttr defaultAttr = element.attributeNode( "default" );
      defaultcal = defaultAttr.value();
      QDomAttr daysAttr = element.attributeNode( "deletedaysold" );
      days = daysAttr.value();

      WebdavCalendar *cal = new WebdavCalendar( username, password,
                                                url, defaultcal, days, mWebdavWidget );
      mWebdavLayout->removeItem( mWebdavSpacer );
      cal->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
      mWebdavLayout->addWidget( cal );
      mWebdavLayout->addItem( mWebdavSpacer );
      mWebdavList.append( cal );

      connect( cal, SIGNAL( deleteRequest( WebdavCalendar* ) ), SLOT( delWebdavCalendar( WebdavCalendar* ) ) );
      cal->show();
    }
  }
}
Ejemplo n.º 29
0
    bool operator()(QDomNode node) {
	QDomElement elem = node.toElement();
	QDomAttr attr = elem.attributeNode("id");
	if(!attr.isNull() && attr.value() == m_value) {
	    return true;
	}
	return false;
    }
Ejemplo n.º 30
0
bool checkIDAttribute( const QDomNamedNodeMap& map, const QString& value )
{
    QDomNode attrElement = map.namedItem( "id" );
    if ( attrElement.isAttr() )
    {
        QDomAttr attr = attrElement.toAttr();
        return attr.value() == value;
    }
    return false;
}