void IDefReader::processScriptItemNode( P_ITEM madeItem, QDomElement &Node )
{
	for( UI16 k = 0; k < Node.childNodes().count(); k++ )
	{
		QDomElement currChild = Node.childNodes().item( k ).toElement();
		if( currChild.nodeName() == "amount" )
		{
			QString Value = QString();
			UI16 i = 0;
			if( currChild.hasChildNodes() ) // <random> i.e.
				for( i = 0; i < currChild.childNodes().count(); i++ )
				{
					if( currChild.childNodes().item( i ).isText() )
						Value += currChild.childNodes().item( i ).toText().data();
					else if( currChild.childNodes().item( i ).isElement() )
						Value += processNode( currChild.childNodes().item( i ).toElement() );
				}
			else
				Value = currChild.nodeValue();

			if( Value.toInt() < 1 )
				Value = QString("1");

			if( madeItem->isPileable() )
				madeItem->setAmount( Value.toInt() );
			else
				for( i = 1; i < Value.toInt(); i++ ) //dupe it n-1 times
					Commands->DupeItem(-1, madeItem, 1);
		}
		else if( currChild.nodeName() == "color" ) //process <color> tags
		{
			QString Value = QString();
			if( currChild.hasChildNodes() ) // colorlist or random i.e.
				for( UI16 i = 0; i < currChild.childNodes().count(); i++ )
				{
					if( currChild.childNodes().item( i ).isText() )
						Value += currChild.childNodes().item( i ).toText().data();
					else if( currChild.childNodes().item( i ).isElement() )
						Value += processNode( currChild.childNodes().item( i ).toElement() );
				}
			else
				Value = currChild.nodeValue();
			
			if( Value.toInt() < 0 )
				Value = QString("0");

			madeItem->setColor( Value.toInt() );
		}
		else if( currChild.nodeName() == "inherit" && currChild.attributes().contains("id") )
		{
			QDomElement* derivalSection = DefManager->getSection( WPDT_ITEM, currChild.attribute("id") );
			if( !derivalSection->isNull() )
				this->applyNodes( madeItem, derivalSection );
		}
	}
}
static void recurseCreateTOC( QDomDocument &maindoc, const QDomNode &parent, QDomNode &parentDestination, KDjVu *djvu )
{
    QDomNode n = parent.firstChild();
    while( !n.isNull() )
    {
        QDomElement el = n.toElement();

        QDomElement newel = maindoc.createElement( el.attribute( "title" ) );
        parentDestination.appendChild( newel );

        QString dest;
        if ( !( dest = el.attribute( "PageNumber" ) ).isEmpty() )
        {
            Okular::DocumentViewport vp;
            vp.pageNumber = dest.toInt() - 1;
            newel.setAttribute( "Viewport", vp.toString() );
        }
        else if ( !( dest = el.attribute( "PageName" ) ).isEmpty() )
        {
            Okular::DocumentViewport vp;
            vp.pageNumber = djvu->pageNumber( dest );
            newel.setAttribute( "Viewport", vp.toString() );
        }
        else if ( !( dest = el.attribute( "URL" ) ).isEmpty() )
        {
            newel.setAttribute( "URL", dest );
        }

        if ( el.hasChildNodes() )
        {
            recurseCreateTOC( maindoc, n, newel, djvu );
        }
        n = n.nextSibling();
    }
}
Exemple #3
0
void TOC::addChildren( const QDomNode & parentNode, KListViewItem * parentItem )
{
    // keep track of the current listViewItem
    TOCItem * currentItem = 0;
    QDomNode n = parentNode.firstChild();
    while( !n.isNull() )
    {
        // convert the node to an element (sure it is)
        QDomElement e = n.toElement();

        // insert the entry as top level (listview parented) or 2nd+ level
        if ( !parentItem )
            currentItem = new TOCItem( this, currentItem, e );
        else
            currentItem = new TOCItem( parentItem, currentItem, e );

        // descend recursively and advance to the next node
        if ( e.hasChildNodes() )
            addChildren( n, currentItem );

        // open/keep close the item
        bool isOpen = false;
        if ( e.hasAttribute( "Open" ) )
            isOpen = QVariant( e.attribute( "Open" ) ).toBool();
        currentItem->setOpen( isOpen );

        n = n.nextSibling();
    }
}
Exemple #4
0
static void fillToc(Poppler::Document *doc, const QDomNode &parent, QTreeWidget *tree, QTreeWidgetItem *parentItem)
{
    QTreeWidgetItem *newitem = 0;
    for (QDomNode node = parent.firstChild(); !node.isNull(); node = node.nextSibling()) {
        QDomElement e = node.toElement();

		// for some unknown reason e.attribute("Destination") does not exist while Okular successfully uses it; so we cannot use Poppler::LinkDestination(e.attribute(QString::fromLatin1("Destination"))).pageNumber() and must use the following
//		const int pageNumber = doc->linkDestination(e.attribute(QString::fromLatin1("DestinationName")))->pageNumber();
		Poppler::LinkDestination *dest = doc->linkDestination(e.attribute(QString::fromLatin1("DestinationName")));
		const double pageNumber = dest->pageNumber() + dest->top();
		delete dest;

        if (!parentItem) {
            newitem = new QTreeWidgetItem(tree, newitem);
        } else {
            newitem = new QTreeWidgetItem(parentItem, newitem);
        }
        newitem->setText(0, e.tagName());
		newitem->setData(0, Qt::UserRole, pageNumber);

        bool isOpen = false;
        if (e.hasAttribute(QString::fromLatin1("Open"))) {
            isOpen = QVariant(e.attribute(QString::fromLatin1("Open"))).toBool();
        }
        if (isOpen) {
            tree->expandItem(newitem);
        }

        if (e.hasChildNodes()) {
            fillToc(doc, node, tree, newitem);
        }
    }
}
Exemple #5
0
static void fillToc(const QDomNode &parent, QTreeWidget *tree, QTreeWidgetItem *parentItem)
{
	QTreeWidgetItem *newitem = 0;
	for (QDomNode node = parent.firstChild(); !node.isNull(); node = node.nextSibling()) {
		QDomElement e = node.toElement();

		if (!parentItem)
			newitem = new QTreeWidgetItem(tree, newitem);
		else
			newitem = new QTreeWidgetItem(parentItem, newitem);
		newitem->setText(0, e.tagName());

		bool isOpen = false;
		if (e.hasAttribute("Open"))
			isOpen = QVariant(e.attribute("Open")).toBool();
		if (isOpen)
			tree->expandItem(newitem);

		if (e.hasAttribute("DestinationName"))
			newitem->setText(1, e.attribute("DestinationName"));

		if (e.hasChildNodes())
			fillToc(node, tree, newitem);
	}
}
Album ParserAlbum::getAlbumFromFile(const QString &_name)
{
    m_pFile->close();
    if(!m_pFile->open(QIODevice::ReadOnly))
    {
        qDebug() << "Can`t open file : " << m_pFile->fileName();
    }
    Album newAlbum;
    newAlbum.setName(_name);
    QDomElement element = m_pDoc->documentElement();
    QDomNode node = element.firstChild();
    while(!node.isNull())
    {
        if(node.isElement())
        {
            QDomElement domElement = node.toElement();
            if(domElement.nodeName() == "images")
            {
                if(domElement.hasChildNodes())
                {
                    getImages(newAlbum,domElement.childNodes());
                }
            }
            if(domElement.nodeName() == "current")
            {
                newAlbum.setCurrentIndex(domElement.text().toInt());
            }
            node = node.nextSibling().toElement();
        }
    } 
    m_pFile->close();
    return newAlbum;
}
void PackagesInfo::Private::addPackageFrom(const QDomElement& packageE)
{
    if( !packageE.hasChildNodes() )
        return;

    PackageInfo info;
    for( QDomNode childNode = packageE.firstChild(); !childNode.isNull(); childNode = childNode.nextSibling() )
    {
        const QDomElement childNodeE = childNode.toElement();
        if( childNodeE.isNull() )
            continue;

        if( childNodeE.tagName() == QLatin1String( "Name" ) )
            info.name = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Pixmap" ) )
            info.pixmap = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Title" ) )
            info.title = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Description" ) )
            info.description = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Version" ) )
            info.version = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Size" ) )
            info.uncompressedSize = childNodeE.text().toULongLong();
        else if( childNodeE.tagName() == QLatin1String( "Dependencies" ) )
            info.dependencies = childNodeE.text().split( QLatin1String( "," ), QString::SkipEmptyParts );
        else if( childNodeE.tagName() == QLatin1String( "LastUpdateDate" ) )
            info.lastUpdateDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
        else if( childNodeE.tagName() == QLatin1String( "InstallDate" ) )
            info.installDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
    }

    this->packageInfoList.append( info );
}
void SvgFlattener::unRotateChild(QDomElement & element, QMatrix transform) {

	// TODO: missing ellipse element

    if(!element.hasChildNodes()) {

		QString sw = element.attribute("stroke-width");
		if (!sw.isEmpty()) {
			bool ok;
			double strokeWidth = sw.toDouble(&ok);
			if (ok) {
                QLineF line(0, 0, strokeWidth, 0);
                QLineF newLine = transform.map(line);
				element.setAttribute("stroke-width", newLine.length());
			}
		}

		// I'm a leaf node.
		QString tag = element.nodeName().toLower();
		if(tag == "path"){
            QString data = element.attribute("d").trimmed();
            if (!data.isEmpty()) {
                const char * slot = SLOT(rotateCommandSlot(QChar, bool, QList<double> &, void *));
                PathUserData pathUserData;
                pathUserData.transform = transform;
                if (parsePath(data, slot, pathUserData, this, true)) {
                    element.setAttribute("d", pathUserData.string);
                }
            }
        }
void FeedList::parseChildNodes(QDomNode &node, Folder* parent)
{
    QDomElement e = node.toElement(); // try to convert the node to an element.

    if( !e.isNull() )
    {
        QString title = e.hasAttribute("text") ? e.attribute("text") : e.attribute("title");

        if (e.hasAttribute("xmlUrl") || e.hasAttribute("xmlurl") || e.hasAttribute("xmlURL") )
        {
            Feed* feed = Feed::fromOPML(e, d->storage);
            if (feed)
            {
                if (!d->urlMap[feed->xmlUrl()].contains(feed))
                    d->urlMap[feed->xmlUrl()].append(feed);
                parent->appendChild(feed);
            }
        }
        else
        {
            Folder* fg = Folder::fromOPML(e);
            parent->appendChild(fg);

            if (e.hasChildNodes())
            {
                QDomNode child = e.firstChild();
                while(!child.isNull())
                {
                    parseChildNodes(child, fg);
                    child = child.nextSibling();
                }
            }
        }
    }
}
Exemple #10
0
void SvgFlattener::unRotateChild(QDomElement & element, QMatrix transform) {

	// TODO: missing ellipse element

    if(!element.hasChildNodes()) {

		double scale = qMin(qAbs(transform.m11()), qAbs(transform.m22()));
		if (scale != 1 && transform.m21() == 0 && transform.m12() == 0) {
			QString sw = element.attribute("stroke-width");
			if (!sw.isEmpty()) {
				bool ok;
				double strokeWidth = sw.toDouble(&ok);
				if (ok) {
					element.setAttribute("stroke-width", QString::number(strokeWidth * scale));
				}
			}
		}

		// I'm a leaf node.
		QString tag = element.nodeName().toLower();
		if(tag == "path"){
            QString data = element.attribute("d").trimmed();
            if (!data.isEmpty()) {
                const char * slot = SLOT(rotateCommandSlot(QChar, bool, QList<double> &, void *));
                PathUserData pathUserData;
                pathUserData.transform = transform;
                if (parsePath(data, slot, pathUserData, this, true)) {
                    element.setAttribute("d", pathUserData.string);
                }
            }
        }
Exemple #11
0
void TOCModelPrivate::addChildren( const QDomNode & parentNode, TOCItem * parentItem )
{
    TOCItem * currentItem = 0;
    QDomNode n = parentNode.firstChild();
    while( !n.isNull() )
    {
        // convert the node to an element (sure it is)
        QDomElement e = n.toElement();

        // insert the entry as top level (listview parented) or 2nd+ level
        currentItem = new TOCItem( parentItem, e );

        // descend recursively and advance to the next node
        if ( e.hasChildNodes() )
            addChildren( n, currentItem );

        // open/keep close the item
        bool isOpen = false;
        if ( e.hasAttribute( "Open" ) )
            isOpen = QVariant( e.attribute( "Open" ) ).toBool();
        if ( isOpen )
            itemsToOpen.append( currentItem );

        n = n.nextSibling();
    }
}
QList<QDomElement> Exporter::searchForCheckedItems(QDomElement element)
{
    QList<QDomElement> list;

    if(element.tagName() == "plume-tree"){
        for(int i = 0 ; i < element.childNodes().size() ; ++i)
            list.append(searchForCheckedItems(element.childNodes().at(i).toElement()));

    }
    else if(element.attribute("exporterCheckState", "2").toInt() != 0){



        if(element.tagName() == "trash")
            return list;




        list.append(element);

        if(!element.hasChildNodes())
            return list;


        for(int i = 0 ; i < element.childNodes().size() ; ++i)
            list.append(searchForCheckedItems(element.childNodes().at(i).toElement()));



    }
    return list;
}
// 将销售记录写入文档
void Widget::writeXml()
{
    // 先从文件读取
    if (docRead()) {
            QString currentDate = getDateTime(Date);
            QDomElement root = doc.documentElement();
            // 根据是否有日期节点进行处理
            if (!root.hasChildNodes()) {
                    QDomElement date = doc.createElement(QString("日期"));
                    QDomAttr curDate = doc.createAttribute("date");
                    curDate.setValue(currentDate);
                    date.setAttributeNode(curDate);
                    root.appendChild(date);
                    createNodes(date);
            } else {
                    QDomElement date = root.lastChild().toElement();
                    // 根据是否已经有今天的日期节点进行处理
                    if (date.attribute("date") == currentDate) {
                            createNodes(date);
                    } else {
                            QDomElement date = doc.createElement(QString("日期"));
                            QDomAttr curDate = doc.createAttribute("date");
                            curDate.setValue(currentDate);
                            date.setAttributeNode(curDate);
                            root.appendChild(date);
                            createNodes(date);
                    }
            }
            // 写入到文件
            docWrite();
    }
}
Exemple #14
0
/**
 * Analyzes the given QDomElement for a reference to a stereotype.
 *
 * @param element   QDomElement to analyze.
 * @return          True if a stereotype reference was found, else false.
 */
bool UMLObject::loadStereotype(QDomElement & element)
{
    QString tag = element.tagName();
    if (!UMLDoc::tagEq(tag, QLatin1String("stereotype")))
        return false;
    QString stereo = element.attribute(QLatin1String("xmi.value"));
    if (stereo.isEmpty() && element.hasChildNodes()) {
        /* like so:
         <UML:ModelElement.stereotype>
           <UML:Stereotype xmi.idref = '07CD'/>
         </UML:ModelElement.stereotype>
         */
        QDomNode stereoNode = element.firstChild();
        QDomElement stereoElem = stereoNode.toElement();
        tag = stereoElem.tagName();
        if (UMLDoc::tagEq(tag, QLatin1String("Stereotype"))) {
            stereo = stereoElem.attribute(QLatin1String("xmi.idref"));
        }
    }
    if (stereo.isEmpty())
        return false;
    Uml::ID::Type stereoID = Uml::ID::fromString(stereo);
    UMLDoc *pDoc = UMLApp::app()->document();
    m_pStereotype = pDoc->findStereotypeById(stereoID);
    if (m_pStereotype)
        m_pStereotype->incrRefCount();
    else
        m_SecondaryId = stereo;  // leave it to resolveRef()
    return true;
}
Exemple #15
0
// static
EffectPointer Effect::createFromXml(EffectsManager* pEffectsManager,
                              const QDomElement& element) {
    // Empty <Effect/> elements are used to preserve chain order
    // when there are empty slots at the beginning of the chain.
    if (!element.hasChildNodes()) {
        return EffectPointer();
    }
    QString effectId = XmlParse::selectNodeQString(element, EffectXml::EffectId);
    EffectPointer pEffect = pEffectsManager->instantiateEffect(effectId);
    return pEffect;
}
Exemple #16
0
bool TPar::parse(QDomElement element)
{
    root_element   = element;
    setTimingAttributes();
    setBaseContainerAttributes();

    if (element.hasChildNodes())
    {
        setPlaylist();
    }
    return false;
}
QString cDefinable::getNodeValue( const QDomElement &Tag )
{
	QString Value = QString();
	
	if( !Tag.hasChildNodes() )
		return "";
	else
	{
		QDomNode childNode = Tag.firstChild();
		while( !childNode.isNull() )
		{
			if( !childNode.isElement() )
			{
				if( childNode.isText() )
					Value += childNode.toText().data();
				childNode = childNode.nextSibling();
				continue;
			}
			QDomElement childTag = childNode.toElement();
			if( childTag.nodeName() == "random" )
			{
				if( childTag.attributes().contains("min") && childTag.attributes().contains("max") )
					Value += QString("%1").arg( RandomNum( childTag.attributeNode("min").nodeValue().toInt(), childTag.attributeNode("max").nodeValue().toInt() ) );
				else if( childTag.attributes().contains("valuelist") )
				{
					QStringList RandValues = QStringList::split(",", childTag.attributeNode("list").nodeValue());
					Value += RandValues[ RandomNum(0,RandValues.size()-1) ];
				}
				else if( childTag.attributes().contains( "list" ) )
				{
					Value += DefManager->getRandomListEntry( childTag.attribute( "list" ) );
				}
				else if( childTag.attributes().contains("dice") )
					Value += QString("%1").arg(rollDice(childTag.attributeNode("dice").nodeValue()));
				else
					Value += QString("0");
			}

			// Process the childnodes
			QDomNodeList childNodes = childTag.childNodes();

			for( int i = 0; i < childNodes.count(); i++ )
			{
				if( !childNodes.item( i ).isElement() )
					continue;

				Value += this->getNodeValue( childNodes.item( i ).toElement() );
			}
			childNode = childNode.nextSibling();
		}
	}
	return hex2dec( Value );
}
Exemple #18
0
void PrivacyListItem::fromXml(const QDomElement& el)
{
	//qDebug("privacy.cpp: Parsing privacy list item");
	if (el.isNull() || el.tagName() != "item") {
		qWarning("privacy.cpp: Invalid root tag for privacy list item.");
		return;
	}

	QString type = el.attribute("type"); 
	if (type == "jid")
		type_ = JidType;
	else if (type == "group")
		type_ = GroupType;
	else if (type == "subscription")
		type_ = SubscriptionType;
	else
		type_ = FallthroughType;
	
	QString value = el.attribute("value");
	value_ = value;
	if (type_ == JidType && XMPP::Jid(value_).isEmpty()) 
		qWarning("privacy.cpp: Invalid value for item of type 'jid'.");
	else if (type_ == GroupType && value_.isEmpty()) 
		qWarning("privacy.cpp: Empty value for item of type 'group'.");
	else if (type_ == SubscriptionType && value_ != "from" && value != "to" && value_ != "both" && value_ != "none")
		qWarning("privacy.cpp: Invalid value for item of type 'subscription'.");
	else if (type_ == FallthroughType && !value_.isEmpty()) 
		qWarning("privacy.cpp: Value given for item of fallthrough type.");
		
	QString action = el.attribute("action");
	if (action == "allow") 
		action_ = Allow;
	else if (action == "deny")
		action_ = Deny;
	else
		qWarning("privacy.cpp: Invalid action given for item.");

	bool ok;
	order_ = el.attribute("order").toUInt(&ok);
	if (!ok)
		qWarning("privacy.cpp: Invalid order value for item.");

	if (el.hasChildNodes()) {
		findSubTag(el, "message", &message_);
		findSubTag(el, "presence-in", &presenceIn_);
		findSubTag(el, "presence-out", &presenceOut_);
		findSubTag(el, "iq", &iq_);
	}
	else {
		message_ = presenceIn_ = presenceOut_ = iq_ = true;
	}
}
void DemoControllerFactory::createFromDomElement(QDomElement element, drobot::robot::Robot *robot) {
    std::string name = element.attribute("name").toStdString();

    drobot::robot::Controller* controller = new DemoController(name);
    if (element.hasChildNodes()) {
        QDomNodeList children = element.childNodes();
        for (int i = 0; i < children.count(); i++) {
            QDomElement child = children.item(i).toElement();
            _channelFactories->get(child.nodeName().toStdString())->createFromDomElement(child, controller);
        }
    }
    robot->setController(controller);
}
Exemple #20
0
bool deletePackage( QDomDocument *list, QString path )
{
	QString map = findMapInDir( path );

	if( path.endsWith( "MoNav.ini" ) )
	{
		QDomElement mapElement = findPackageElement( *list, "map", map );

		if( mapElement.isNull() )
		{
			printf( "map not in list\n" );
			return false;
		}

		list->documentElement().removeChild( mapElement );
		printf( "deleted map entry\n" );
	}

	else if( path.endsWith( ".mmm" ) )
	{
		QString name = path.split("_")[1];

		QDomElement moduleElement = findPackageElement( *list, "module", name, map );

		if( moduleElement.isNull() )
		{
			printf("module not in list\n");
			return 1;
		}

		QDomElement parentElement = moduleElement.parentNode().toElement();
		parentElement.removeChild( moduleElement );

		while( !parentElement.hasChildNodes() )
		{
			moduleElement = parentElement;
			parentElement = parentElement.parentNode().toElement();
			parentElement.removeChild( moduleElement );
		}

		printf( "deleted module entry\n" );
	}

	else
	{
		printf( "unrecognized package format\n" );
		return false;
	}

	return true;
}
Exemple #21
0
void note::loadSettings( const QDomElement & _this )
{
	const int oldKey = _this.attribute( "tone" ).toInt() + _this.attribute( "oct" ).toInt() * KeysPerOctave;
	m_key = qMax( oldKey, _this.attribute( "key" ).toInt() );
	m_volume = _this.attribute( "vol" ).toInt();
	m_panning = _this.attribute( "pan" ).toInt();
	m_length = _this.attribute( "len" ).toInt();
	m_pos = _this.attribute( "pos" ).toInt();

	if( _this.hasChildNodes() )
	{
		createDetuning();
		m_detuning->loadSettings( _this );
	}
}
Exemple #22
0
QDomElement KeePass2XmlReader::findChildByTagName(const QDomElement &root, const QString &tagName)
{
  if (!root.isNull() && root.hasChildNodes()) {
    QDomNode child = root.firstChild();
    while (!child.isNull()) {
      QDomElement e = child.toElement();
      if (!e.isNull()) {
        if (e.tagName() == tagName) {
          return e;
        }
      }
      child = child.nextSibling();
    }
  }
  return QDomElement();
}
Exemple #23
0
static void convertFromDomElement(const QDomElement& dom_element, Device::Node &parentNode)
{
    QDomElement dom_child = dom_element.firstChildElement("");
    QString name;

    if(dom_element.hasAttribute("address"))
    {
        name = dom_element.attribute("address");
    }
    else
    {
        name = dom_element.tagName();
    }

    Device::AddressSettings addr;
    addr.name = name;

    if(dom_element.hasAttribute("type"))
    {
        const auto type = dom_element.attribute("type");
        addr.value = read_valueDefault(dom_element, type);
        addr.ioType = read_service(dom_element);

        addr.priority = dom_element.attribute("priority").toInt();
        addr.repetitionFilter = dom_element.attribute("repetitionsFilter").toInt();

        addr.domain = read_rangeBounds(dom_element, type);
        if(addr.value.val.which() != State::ValueType::NoValue)
        {
            if(addr.domain.min.val.which() == State::ValueType::NoValue)
                addr.domain.min = addr.value;
            if(addr.domain.max.val.which() == State::ValueType::NoValue)
                addr.domain.max = addr.value;
        }
        addr.clipMode = read_rangeClipmode(dom_element);
    }

    auto& childNode = parentNode.emplace_back(addr, &parentNode);

    while(!dom_child.isNull() && dom_element.hasChildNodes())
    {
        convertFromDomElement(dom_child, childNode);

        dom_child = dom_child.nextSibling().toElement();
    }
    return;
}
Exemple #24
0
//显示日销售清单
// 显示日销售清单
void Widget::showDailyList()
{
    ui->dailyList->clear();
    if (docRead()) 
    {
        QDomElement root = doc.documentElement();
        QString title = root.tagName();
        QListWidgetItem *titleItem = new QListWidgetItem;
        titleItem->setText(QString("-----%1-----").arg(title));
        titleItem->setTextAlignment(Qt::AlignCenter);
        ui->dailyList->addItem(titleItem);

        if (root.hasChildNodes()) {
            QString currentDate = getDateTime(Date);
            QDomElement dateElement = root.lastChild().toElement();
            QString date = dateElement.attribute("date");
            if (date == currentDate) {
                ui->dailyList->addItem("");
                ui->dailyList->addItem(QString("日期:%1").arg(date));
                ui->dailyList->addItem("");
                QDomNodeList children = dateElement.childNodes();
                // 遍历当日销售的所有商品
                for (int i=0; i<children.count(); i++) {
                    QDomNode node = children.at(i);
                    QString time = node.toElement().attribute("time");
                    QDomNodeList list = node.childNodes();
                    QString type = list.at(0).toElement().text();
                    QString brand = list.at(1).toElement().text();
                    QString price = list.at(2).toElement().text();
                    QString num = list.at(3).toElement().text();
                    QString sum = list.at(4).toElement().text();

                    QString str = time + " 出售 " + brand + type
                            + " " + num + "台, " + "单价:" + price
                            + "元, 共" + sum + "元";
                    QListWidgetItem *tempItem = new QListWidgetItem;
                    tempItem->setText("**************************");
                    tempItem->setTextAlignment(Qt::AlignCenter);
                    ui->dailyList->addItem(tempItem);
                    ui->dailyList->addItem(str);
                }
            }
        }
    }
}
void EffectButtonParameterSlot::loadParameterSlotFromXml(const QDomElement&
                                                  parameterElement) {
    if (m_pEffectParameter == nullptr) {
        return;
    }
    if (!parameterElement.hasChildNodes()) {
        m_pControlValue->reset();
    } else {
        bool conversionWorked = false;
        double value = XmlParse::selectNodeDouble(parameterElement,
                                                  EffectXml::ParameterValue,
                                                  &conversionWorked);
        if (conversionWorked) {
            m_pControlValue->set(value);
        }
        // If the conversion failed, the default value is kept.
    }
}
Exemple #26
0
bool TextRegExp::load( QDomElement top, const QString& /*version*/)
{
    Q_ASSERT( top.tagName() == QString::fromLocal8Bit( "Text" ) );
    if ( top.hasChildNodes() ) {
        QDomNode child = top.firstChild();
        if ( ! child.isText() ) {
            KMessageBox::sorry( 0, i18n("<p>Element <b>Text</b> did not contain any textual data.</p>"),
                                i18n("Error While Loading From XML File") ) ;
            return false;
        }
        QDomText txtNode = child.toText();
        _text = txtNode.data();
    } else {
        _text = QString::fromLatin1( "" );
    }

    return true;
}
void KEduVocConjugation::toKVTML2(QDomElement & parent, const QString &tense)
{
    if (isEmpty()) {
        return;
    }

    QMap<int, KEduVocWordFlag::Flags> numbers;
    numbers[0] = KEduVocWordFlag::Singular;
    numbers[1] = KEduVocWordFlag::Dual;
    numbers[2] = KEduVocWordFlag::Plural;
    QMap<int, KEduVocWordFlag::Flags> persons;
    persons[0] = KEduVocWordFlag::First;
    persons[1] = KEduVocWordFlag::Second;
    persons[2] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Masculine);
    persons[3] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Feminine);
    persons[4] = (KEduVocWordFlag::Flags)((int)KEduVocWordFlag::Third | (int)KEduVocWordFlag::Neuter);

    QDomDocument domDoc = parent.ownerDocument();

    // write the tense tag
    if (!tense.isEmpty()) {
        QDomElement tenseElement = domDoc.createElement( KVTML_TENSE );
        tenseElement.appendChild( domDoc.createTextNode(tense) );
        parent.appendChild(tenseElement);
    } else {
        qDebug() << "Saving conjugation with empty tense";
    }

    for ( int num = 0; num <= 2; ++num) {
        QDomElement numberElement = domDoc.createElement( KVTML_GRAMMATICAL_NUMBER[num] );
        for ( int person = 0; person < 5; ++person) {
            KEduVocWordFlags curFlags = numbers[num] | persons[person];

            if (keys().contains(curFlags) && !conjugation(curFlags).isEmpty()) {
                QDomElement personElement = domDoc.createElement( KVTML_GRAMMATICAL_PERSON[person] );
                numberElement.appendChild(personElement);
                conjugation(curFlags).toKVTML2(personElement);
            }
        }
        if (numberElement.hasChildNodes()) {
            parent.appendChild( numberElement );
        }
    }
}
    void addSynopsisChildren(QDomNode *parent, int level)
    {
        if (!parent || parent->isNull())
            return;

        // keep track of the current listViewItem
        QDomNode n = parent->firstChild();
        while (!n.isNull()) {
            PDFTocEntry *tocEntry = new PDFTocEntry;
            tocEntry->level = level;
            // convert the node to an element (sure it is)
            QDomElement e = n.toElement();
            tocEntry->title = e.tagName();

            // Apparently we can have external links in the ToC.
            // Not doing this for now, but leave it in here as a note to self
            // if (!e.attribute("ExternalFileName").isNull()) item.setAttribute("ExternalFileName", e.attribute("ExternalFileName"));
            if (!e.attribute("DestinationName").isNull()) {
                Poppler::LinkDestination *dest = document->linkDestination(e.attribute("DestinationName"));
                if (dest) {
                    tocEntry->pageNumber = dest->pageNumber();
                    delete dest;
                }
                //item.setAttribute("ViewportName", e.attribute("DestinationName"));
            }
            if (!e.attribute("Destination").isNull()) {
                //fillViewportFromLinkDestination( vp, Poppler::LinkDestination(e.attribute("Destination")) );
                //item.setAttribute( "Viewport", vp.toString() );
                Poppler::LinkDestination dest(e.attribute("Destination"));
                tocEntry->pageNumber = dest.pageNumber();
            }
            // if (!e.attribute("Open").isNull()) item.setAttribute("Open", e.attribute("Open"));
            // if (!e.attribute("DestinationURI").isNull()) item.setAttribute("URL", e.attribute("DestinationURI"));

            // Add the entry to the list of ToC entries
            entries.append(tocEntry);
            // descend recursively and advance to the next node
            ++level;
            if (e.hasChildNodes())
                addSynopsisChildren(&n, level);
            --level;
            n = n.nextSibling();
        }
    }
Exemple #29
0
bool TBody::parse(QDomElement element)
{
    bool ret = false;
    root_element   = element;
    active_element = element;
    setTimingAttributes();
    id = "body";  // useful for debug
    if (element.hasChildNodes())
    {
        active_element = element.firstChildElement();
        setPlaylist();
        iterator       = dom_list.begin();
        active_element = *iterator;
        ret = true;
    }
    else
       finishedActiveDuration();
    return ret;
}
Exemple #30
0
/*!
	\overload
	\param elem Source element to scan
	\param ignoreNewIds whether unknown format identifiers should be ignored
	
	The given dom element must contain a proper version attribute and format
	data as child elements (&lt;format&gt; tags)
	
	\note Previous content is not discarded
*/
void QFormatScheme::load(const QDomElement& elem, bool ignoreNewIds)
{
	if (!elem.hasAttributes() && !elem.hasChildNodes()) return;

	if ( elem.attribute("version") < QFORMAT_VERSION )
	{
		qWarning("Format encoding version mismatch : [found]%s != [expected]%s",
				qPrintable(elem.attribute("version")),
				QFORMAT_VERSION);
		
		return;
	}
	
	QDomElement e, c;
	QDomNodeList l, f = elem.elementsByTagName("format");
	
	for ( int i = 0; i < f.count(); i++ )
	{
		e = f.at(i).toElement();
		
		if ( ignoreNewIds && !m_formatKeys.contains(e.attribute("id")) )
			continue;
		
		l = e.childNodes();
		
		QFormat fmt;
		
		for ( int i = 0; i < l.count(); i++ )
		{
			c = l.at(i).toElement();
			
			if ( c.isNull() )
				continue;
			
			QString field = c.tagName(),
					value = c.firstChild().toText().data();
			setFormatOption(fmt,field,value);
		}
		fmt.setPriority(fmt.priority); //update priority if other values changed

		setFormat(e.attribute("id"), fmt);
	}
}