예제 #1
0
bool XmlDataLayer::productsInsertData(ProductData& prodData, int type) {
	QDomDocument doc(sett().getProdutcsDocName());
	QDomElement root;
	QDomElement products, services;

	QFile file(sett().getProductsXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "New products file created";
		root = doc.createElement(sett().getProdutcsDocName());
		int lastId = root.attribute("last", "0").toInt();
		lastId++;
		root.setAttribute("last", sett().numberToString(lastId));
		doc.appendChild(root);
		products = doc.createElement(sett().getNameWithData(sett().getProductName()));
		root.appendChild(products);
		services = doc.createElement(sett().getNameWithData(sett().getServiceName()));
		root.appendChild(services);
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return false;
		} else {
			root = doc.documentElement();
			int lastId = root.attribute("last", "0").toInt();
			lastId++;
			root.setAttribute("last", sett().numberToString(lastId));
			products = root.firstChild().toElement();
			services = root.lastChild().toElement();
		}
	}

	root.lastChild();

	if (type == 0) {
		QDomElement elem = doc.createElement(sett().getProductName());
		productsDataToElem(prodData, elem);
		products.appendChild(elem);
	}

	if (type == 1) {
		QDomElement elem = doc.createElement(sett().getServiceName());
		productsDataToElem(prodData, elem);
		services.appendChild(elem);
	}

	QString xml = doc.toString();

	file.close();
	file.open(QIODevice::WriteOnly);
	QTextStream ts(&file);
	ts.setCodec(QTextCodec::codecForName(sett().getCodecName()));
	ts << xml;
	file.close();

	return true;
}
예제 #2
0
bool XmlDataLayer::kontrahenciInsertData(KontrData& kontrData, int type) {
	QDomDocument doc(sett().getCustomersDocName());
	QDomElement root;
	QDomElement office;
	QDomElement company;

	QFile file(sett().getCustomersXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug("can not open ");
		root = doc.createElement(sett().getCustomersDocName());
		doc.appendChild(root);
		office = doc.createElement(sett().getOfficeName());
		root.appendChild(office);
		company = doc.createElement(sett().getCompanyName());
		root.appendChild(company);
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			// return;
		} else {
			root = doc.documentElement();
			office = root.firstChild().toElement();
			company = root.lastChild().toElement();
		}
	}

	root.lastChild();

	// firma = 0; urzad = 1;
	if (type == 0) {
		QDomElement elem = doc.createElement(sett().getCompanyName());
		kontrahenciDataToElem(kontrData, elem);
		company.appendChild(elem);
	}

	if (type == 1) {
		QDomElement elem = doc.createElement(sett().getOfficeName());
		kontrahenciDataToElem(kontrData, elem);
		office.appendChild(elem);
	}

	QString xml = doc.toString();

	file.close();
	file.open(QIODevice::WriteOnly);
	QTextStream ts(&file);
	ts << xml;
	file.close();

	return true;
}
예제 #3
0
// 将销售记录写入文档
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();
    }
}
예제 #4
0
bool XmlDataLayer::productsDeleteData(QString name) {

	QDomDocument doc(sett().getProdutcsDocName());
	QDomElement root;
	QDomElement products;
	QDomElement services;

	QFile file(sett().getProductsXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "File" << file.fileName() << "doesn't exists";
		return false;
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return false;
		} else {
			root = doc.documentElement();
			products = root.firstChild().toElement();
			services = root.lastChild().toElement();
		}
		QString text;

		for (QDomNode n = services.firstChild(); !n.isNull(); n
				= n.nextSibling()) {
			if (n.toElement().attribute("idx"). compare(name) == 0) {
				services.removeChild(n);
				break;
			}
		}

		for (QDomNode n = products.firstChild(); !n.isNull(); n
				= n.nextSibling()) {
			if (n.toElement().attribute("idx"). compare(name) == 0) {
				products.removeChild(n);
				break;
			}
		}

		QString xml = doc.toString();
		file.close();
		file.open(QIODevice::WriteOnly);
		QTextStream ts(&file);
		ts << xml;

		file.close();
	}

	return true;
}
예제 #5
0
bool XmlDataLayer::kontrahenciDeleteData(QString name) {
	QDomDocument doc(sett().getCustomersDocName());
	QDomElement root;
	QDomElement urzad;
	QDomElement firma;

	QFile file(sett().getCustomersXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "File" << file.fileName() << "doesn't exists";
		return false;
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return false;
		} else {
			root = doc.documentElement();
			urzad = root.firstChild().toElement();
			firma = root.lastChild().toElement();
		}
		QString text;

		for (QDomNode n = firma.firstChild(); !n.isNull(); n = n.nextSibling()) {
			if (n.toElement().attribute("name"). compare(name) == 0) {
				firma.removeChild(n);
				break;
			}
		}

		for (QDomNode n = urzad.firstChild(); !n.isNull(); n = n.nextSibling()) {
			if (n.toElement().attribute("name"). compare(name) == 0) {
				urzad.removeChild(n);
				break;
			}
		}

		QString xml = doc.toString();
		file.close();
		file.open(QIODevice::WriteOnly);
		QTextStream ts(&file);
		ts << xml;

		file.close();
	}
	return true;
}
예제 #6
0
파일: widget.cpp 프로젝트: raojun/Manager
//显示日销售清单
// 显示日销售清单
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);
                }
            }
        }
    }
}
예제 #7
0
파일: mainwindow.cpp 프로젝트: gessd/my_qt
void MainWindow::on_btn_select_clicked()
{
    ui->listWidget->clear();
    ui->listWidget->addItem(tr("无法添加"));
    QFile file("my.xml");
    if(!file.open(QIODevice::ReadOnly()))
    {
        return;
    }
    QDomDocument doc;
    if(!doc.setContent(&file))
    {
        file.close();
        return ;
    }
    file.close();

    QDomElement root = doc.documentElement();
    QDomElement book = doc.documentElement(tr("图书"));
    QDomAttr id = doc.createAttribute(tr("编号"));
    QDomElement title = doc.documentElement(tr("书名"));
    QDomElement author = doc.documentElement(tr("作者"));
    QDomText text;

    QString num = root.lastChild().toElement().attribute(tr("编号"));
    int count = num.toInt() +1;
    id.setValue(QString::number(count));
    book.setAttributeNode(id);
    text = doc.createTextNode(ui->lineEdit_name->text());
    title.appendChild(text);
    text = doc.createTextNode(ui->lineEdit_author->text());
    author.appendChild(text);
    book.appendChild(title);
    book.appendChild(author);
    root.appendChild(book);
    if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
    {
        return;
    }
    QTextStream out(&file);
    doc.save(out, 4);
    file.close();
    ui->listWidget->clear();
    ui->listWidget->addItem(tr("添加成功"));
}
예제 #8
0
ProductData XmlDataLayer::productsSelectData(QString name, int type) {
	ProductData o_prodData;

	QDomDocument doc(sett().getProdutcsDocName());
	QDomElement root;
	QDomElement towar;
	QDomElement usluga;

	QFile file(sett().getProductsXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "File" << file.fileName() << "doesn't exists";
		return o_prodData;
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return o_prodData;
		} else {
			root = doc.documentElement();
			o_prodData.lastProdId = root.attribute("last", "1").toInt();
			towar = root.firstChild().toElement();
			usluga = root.lastChild().toElement();
		}

		if (type == 0) {
			for (QDomNode n = towar.firstChild(); !n.isNull(); n
					= n.nextSibling()) {
				if (n.toElement().attribute("idx").compare(name) == 0) {
					productsElemToData(o_prodData, n.toElement());
				}
			}
		} else {
			for (QDomNode n = usluga.firstChild(); !n.isNull(); n
					= n.nextSibling()) {
				if (n.toElement().attribute("idx").compare(name) == 0) {
					productsElemToData(o_prodData, n.toElement());
				}
			}
		}
	}

	return o_prodData;
}
예제 #9
0
 static bool  parseVerifyIq(const QString cmd,QString &code, QString &tojid)
 {
     QDomDocument  dom;
     QDomElement   elem;
     //QString scmd = QString("<iq from =\"\",to=\"123\" type=\"result\"><xmlns=\"123\"/><code>xuojfoamdfoaysdYQOEWJN232</code></iq>");
     if ( !dom.setContent(cmd))
     {
         return false;
     }
     elem = dom.firstChildElement(QString("iq"));
     tojid = elem.attribute(QString("from"),QString(""));
     if (elem.isNull())
         return false;
     elem = elem.firstChildElement(QString("code"));
     if (elem.isNull())
         return false;
     code = elem.lastChild().nodeValue();
     return true;
 }
예제 #10
0
QVector<ProductData> XmlDataLayer::productsSelectAllData() {
	QVector<ProductData> prodVec;

	QDomDocument doc(sett().getProdutcsDocName());
	QDomElement root;
	QDomElement products;
	QDomElement services;

	QFile file(sett().getProductsXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "File" << file.fileName() << "doesn't exists";
		return prodVec;
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can't set content ");
			file.close();
			return prodVec;
		} else {
			root = doc.documentElement();
			products = root.firstChild().toElement();
			services = root.lastChild().toElement();
		}

		for (QDomNode n = products.firstChild(); !n.isNull(); n = n.nextSibling()) {
			ProductData prodData;
			productsElemToData(prodData, n.toElement());
			prodData.type = QObject::trUtf8("Towar");
			prodVec.push_front(prodData);
		}

		for (QDomNode n = services.firstChild(); !n.isNull(); n = n.nextSibling()) {
			ProductData prodData;
			productsElemToData(prodData, n.toElement());
			prodData.type = QObject::trUtf8("Usługa");
			prodVec.push_front(prodData);
		}
	}

	return prodVec;
}
예제 #11
0
QVector<KontrData> XmlDataLayer::XmlDataLayer::kontrahenciSelectAllData() {
	QVector<KontrData> kontrVec;

	QDomDocument doc(sett().getCustomersDocName());
	QDomElement root;
	QDomElement office;
	QDomElement company;

	QFile file(sett().getCustomersXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "File" << file.fileName() << "doesn't exists";
		return kontrVec;
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return kontrVec;
		} else {
			root = doc.documentElement();
			office = root.firstChild().toElement();
			company = root.lastChild().toElement();
		}

		for (QDomNode n = company.firstChild(); !n.isNull(); n = n.nextSibling()) {
			KontrData kontrData;
			kontrahenciElemToData(kontrData, n.toElement());
			kontrData.type = QObject::trUtf8("Firma");
			kontrVec.push_front(kontrData);
		}

		for (QDomNode n = office.firstChild(); !n.isNull(); n = n.nextSibling()) {
			KontrData kontrData;
			kontrahenciElemToData(kontrData, n.toElement());
			kontrData.type = QObject::trUtf8("Urząd");
			kontrVec.push_front(kontrData);
		}
	}

	return kontrVec;
}
예제 #12
0
KontrData XmlDataLayer::kontrahenciSelectData(QString name, int type) {
	KontrData o_kontrData;

	QDomDocument doc(sett().getCustomersDocName());
	QDomElement root;
	QDomElement office;
	QDomElement company;

	QFile file(sett().getCustomersXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "File" << file.fileName() << "doesn't exists";
		return o_kontrData;
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return o_kontrData;
		} else {
			root = doc.documentElement();
			office = root.firstChild().toElement();
			company = root.lastChild().toElement();
		}

		if (type == 0) {
			for (QDomNode n = company.firstChild(); !n.isNull(); n = n.nextSibling()) {
				if (n.toElement().attribute("name").compare(name) == 0) {
					kontrahenciElemToData(o_kontrData, n.toElement());
				}
			}
		} else {
			for (QDomNode n = office.firstChild(); !n.isNull(); n = n.nextSibling()) {
				if (n.toElement().attribute("name").compare(name) == 0) {
					kontrahenciElemToData(o_kontrData, n.toElement());
				}
			}
		}
	}
	return o_kontrData;
}
예제 #13
0
QStringList XmlDataLayer::kontrahenciGetFirmList() {
	QStringList allNames;

	QDomDocument doc(sett().getCustomersDocName());
	QDomElement root;
	QDomElement office;
	QDomElement company;

	QFile file(sett().getCustomersXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "File" << file.fileName() << "doesn't exists";
		return allNames;
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return allNames;
		} else {
			root = doc.documentElement();
			office = root.firstChild().toElement();
			company = root.lastChild().toElement();
		}
		QString text;

		for (QDomNode n = company.firstChild(); !n.isNull(); n
				= n.nextSibling()) {
			text = n.toElement().attribute("name");
			allNames << text;
		}

		for (QDomNode n = office.firstChild(); !n.isNull(); n = n.nextSibling()) {
			text = n.toElement().attribute("name");
			allNames << text;
		}
	}
	return allNames;
}
예제 #14
0
/**
 * The data is returned from Open Street Map in a XML. This function translates the XML into a QMap.
 * @param xmlData The returned XML.
 */ 
QMap<QString,QString> BackendOsmRG::makeQMapFromXML(const QString& xmlData)
{
    QString resultString;
    QMap<QString, QString> mappedData;
    QDomDocument doc;
    doc.setContent(xmlData);

    QDomElement docElem =  doc.documentElement();
    QDomNode n = docElem.lastChild().firstChild();

    while (!n.isNull())
    {
        QDomElement e = n.toElement();
        if (!e.isNull())
        {
            if ( (e.tagName() == QString("country")) ||
                (e.tagName() == QString("state")) ||
                (e.tagName() == QString("state_district")) ||
                (e.tagName() == QString("county")) ||
                (e.tagName() == QString("city")) ||
                (e.tagName() == QString("city_district")) ||
                (e.tagName() == QString("suburb")) ||
                (e.tagName() == QString("town"))  ||
                (e.tagName() == QString("village")) ||
                (e.tagName() == QString("hamlet")) ||
                (e.tagName() == QString("place")) ||
                (e.tagName() == QString("road")) ||
                (e.tagName() == QString("house_number")))    
            {
                mappedData.insert(e.tagName(), e.text());
                resultString.append(e.tagName() + ':' + e.text() + '\n');
            }
        }
        n = n.nextSibling();
    }
    return mappedData;
}
예제 #15
0
bool XmlDataLayer::kontrahenciUpdateData(KontrData& kontrData, int type, QString name) {
	QDomDocument doc(sett().getCustomersDocName());
	QDomElement root;
	QDomElement office;
	QDomElement company;

	QFile file(sett().getCustomersXml());
	if (!file.open(QIODevice::ReadOnly)) {
		qDebug() << "File" << file.fileName() << "doesn't exists";
		root = doc.createElement(sett().getCustomersDocName());
		doc.appendChild(root);
		office = doc.createElement(sett().getOfficeName());
		root.appendChild(office);
		company = doc.createElement(sett().getCompanyName());
		root.appendChild(company);
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return false;
		} else {
			root = doc.documentElement();
			office = root.firstChild().toElement();
			company = root.lastChild().toElement();
		}
	}

	root.lastChild();
	QString text;

	// firma = 0; urzad = 1;
	if (type == 0) {
		QDomElement elem; // = doc.createElement ("firma");
		for (QDomNode n = company.firstChild(); !n.isNull(); n
				= n.nextSibling()) {
			if (n.toElement().attribute("name").compare(name) == 0) {
				elem = n.toElement();
				break;
			}
		}
		kontrahenciDataToElem(kontrData, elem);
		company.appendChild(elem);
	}

	if (type == 1) {
		QDomElement elem; //  = doc.createElement ("urzad");
		for (QDomNode n = office.firstChild(); !n.isNull(); n = n.nextSibling()) {
			if (n.toElement().attribute("name").compare(name) == 0) {
				elem = n.toElement();
				break;
			}
		}
		kontrahenciDataToElem(kontrData, elem);
		office.appendChild(elem);
	}

	QString xml = doc.toString();

	file.close();
	file.open(QIODevice::WriteOnly);
	QTextStream ts(&file);
	ts << xml;
	file.close();

	return true;
}
예제 #16
0
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 + "'!");
        }
    }

}
예제 #17
0
    /**
     * @brief parseRandCodeIq
     * @param cmd
     * @param identity
     * @return
     *
     * 解析随机码验证IQ,并返回认证结果
     */
    static bool parseRandCodeIq(const QString cmd,QString &result, int &ret,QString &result2)
    {
        QDomDocument  dom;
        QDomElement   elem;
        QString       tojid,xmlns,authcode,id;
        QString       data;
        ret = -1;

        if ( !dom.setContent(cmd )){
            ret = 2;
            return false;
        }
        //不是符合要求的IQ报文,直接丢弃
        elem = dom.firstChildElement("iq");
        ret = 3;
        if (elem.isNull())
            return false;
        tojid = elem.attribute("from");
        id = elem.attribute("id");
        QString myjid = elem.attribute("to");
        //Session::Instance()->setWholeJid(myjid);
        //Session::Instance()->setjid(QString::fromStdString(JID(myjid.toStdString()).toBare().toString()));
        Session::Instance()->setJID(myjid);
        /*
         *将JID中的用户名提取出来,返回给认证端
         */
        myjid = QXmppUtils::jidToUser(myjid);
        ret = 4;
        if (elem.isNull()) return false;
        ret = 5;
        elem = elem.firstChildElement("CZXP");
        if (elem.isNull()) return false;
        ret = 6;
        xmlns = elem.attribute("xmlns");
        elem = elem.firstChildElement("userAuth");
        if(elem.isNull()) return false;
        ret = 7;
        authcode = elem.lastChild().nodeValue();
        QString realCode = Session::Instance()->getCode("app");
        ret = 0;

        data  = QString("<iq to=\"") + tojid + QString("\" ");
        data += QString(" id=\"")+id + QString("\" type=\"result\">");
        data += QString("<CZXP xmlns=\"") + xmlns + QString("\">");
        data += QString("<userAuth>") + myjid + QString("</userAuth>");
        data += QString("</CZXP>");
        data += QString("</iq>");
        result2 = data;

        if(realCode.compare(authcode) != 0)
        {
            data  = QString("<iq to=\"") + tojid + QString("\" ");
            data += QString(" id=\"")+id + QString("\" type=\"result\">");
            data += QString("<CZXP xmlns=\"") + xmlns + QString("\">");
            data += QString("<userAuth>") + QString("error</userAuth>");
            data += QString("</CZXP>");
            data += QString("</iq>");
            result  = data;
            return false;
        }
        data  = QString("<iq to=\"") + tojid + QString("\" ");
        data += QString(" id=\"")+id + QString("\" type=\"result\">");
        data += QString("<CZXP xmlns=\"") + xmlns + QString("\">");
        data += QString("<userAuth>") + myjid + QString("</userAuth>");
        data += QString("</CZXP>");
        data += QString("</iq>");
        result = data;
        return true;
    }
예제 #18
0
bool ChartTableGen::saveChartTableToXML(QVector<LayerVisualInfo*> data, QString fileName) {
	XMLFile = new QFile(fileName);
	if (!XMLFile->exists()) this->createXML();
	QString xml;

	QDomElement root = this->getXMLRoot();
	QDomNode n = root.firstChild();
	bool found = false;
	while(!n.isNull()) {
		QDomElement e = n.toElement(); // try to convert the node to an element.
		if(!e.isNull()&&e.tagName()=="charttable") {
			found = true;
			break;
		}
		n = n.nextSibling();
	}

	// remove old layer visual info nodes
	QDomNode rn;
	do {
		rn = root.removeChild(root.lastChild());
	} while (!rn.isNull());

	QVectorIterator<LayerVisualInfo*> lviIt(data);
	LayerVisualInfo* lvi;

	while (lviIt.hasNext()) {
		lvi = lviIt.next();
		QDomElement lviElem = XMLDoc.createElement("layervisualinfo");

		root.appendChild(lviElem);

		QDomElement layerId = XMLDoc.createElement("layerid");
		lviElem.appendChild(layerId);
		layerId.appendChild(XMLDoc.createTextNode(lvi->getLayerId()));

		QDomElement minZoom = XMLDoc.createElement("minzoom");
		lviElem.appendChild(minZoom);
		minZoom.appendChild(XMLDoc.createTextNode(QString::number(lvi->getZoomMin())));

		QDomElement maxZoom = XMLDoc.createElement("maxzoom");
		lviElem.appendChild(maxZoom);
		maxZoom.appendChild(XMLDoc.createTextNode(QString::number(lvi->getZoomMax())));

		QDomElement styleId = XMLDoc.createElement("styleid");
		lviElem.appendChild(styleId);
		styleId.appendChild(XMLDoc.createTextNode(QString::number(lvi->getStyleId())));

		QDomElement simpLevel = XMLDoc.createElement("simplevel");
		lviElem.appendChild(simpLevel);
		simpLevel.appendChild(XMLDoc.createTextNode(QString::number(lvi->getSimpLevel())));

		QDomElement epsilon = XMLDoc.createElement("epsilon");
		lviElem.appendChild(epsilon);
		epsilon.appendChild(XMLDoc.createTextNode(QString::number(lvi->getEpsilon())));

		QDomElement srcTable = XMLDoc.createElement("srctable");
		lviElem.appendChild(srcTable);
		srcTable.appendChild(XMLDoc.createTextNode(lvi->getSrcTableName()));

	}

	xml = XMLDoc.toString(4);

	if (XMLFile->open(QIODevice::WriteOnly)) {
		QTextStream out(XMLFile);
		out << xml;
		XMLFile->close();
	}

	return true;
}
예제 #19
0
void StatusDialog::savePreset(const QString &preset_caption)
{
  QFile presets_file(m_preset_file);

  if ( presets_file.exists() )
  {
    if (presets_file.open(QIODevice::ReadOnly) )
    {
      QDomDocument doc;
      if ( doc.setContent(&presets_file) )
      {
        QDomElement rootElement = doc.documentElement();
        QDomElement preset_element = doc.createElement("preset");
        QDomElement caption_element = doc.createElement("caption");
        QDomText caption_text = doc.createTextNode(preset_caption);
        caption_element.appendChild(caption_text);
        QDomElement message_element = doc.createElement("message");
        QDomText message_text = doc.createTextNode(ui.statusTextEdit->toPlainText());
        message_element.appendChild(message_text);
        preset_element.appendChild(caption_element);
        preset_element.appendChild(message_element);
        rootElement.insertAfter(preset_element, rootElement.lastChild());

        presets_file.close();
        if ( presets_file.open(QIODevice::WriteOnly) )
        {
          QTextStream preset_stream(&presets_file);
          preset_stream.setCodec("UTF-8");
          preset_stream<<doc.toString();
          presets_file.close();
        }
      }
    }
  }
  else
  {
    if ( presets_file.open(QIODevice::WriteOnly) )
    {
      QDomDocument doc("stauspresets");
      QDomProcessingInstruction process = doc.createProcessingInstruction(
                                            "xml", "version=\"1.0\" encoding=\"utf-8\"");
      doc.appendChild(process);
      QDomElement rootElement = doc.createElement("stauspresets");
      doc.appendChild(rootElement);

      QDomElement preset_element = doc.createElement("preset");
      QDomElement caption_element = doc.createElement("caption");
      QDomText caption_text = doc.createTextNode(preset_caption);
      caption_element.appendChild(caption_text);
      QDomElement message_element = doc.createElement("message");
      QDomText message_text = doc.createTextNode(ui.statusTextEdit->toPlainText());
      message_element.appendChild(message_text);

      preset_element.appendChild(caption_element);
      preset_element.appendChild(message_element);
      rootElement.appendChild(preset_element);
      doc.appendChild(rootElement);

      QTextStream presets_stream(&presets_file);
      presets_stream.setCodec("UTF-8");
      presets_stream<<doc.toString();
      presets_file.close();
    }
  }
  ui.presetComboBox->addItem(preset_caption,ui.statusTextEdit->toPlainText());

}
예제 #20
0
bool XmlDataLayer::productsUpdateData(ProductData& prodData, int type, QString name) {
	QDomDocument doc(sett().getProdutcsDocName());
	QDomElement root;
	QDomElement towary;
	QDomElement uslugi;

	QFile file(sett().getProductsXml());
	if (!file.open(QIODevice::ReadOnly)) {
		root = doc.createElement(sett().getProdutcsDocName());
		doc.appendChild(root);
		towary = doc.createElement(sett().getProductName());
		root.appendChild(towary);
		uslugi = doc.createElement(sett().getServiceName());
		root.appendChild(uslugi);
	} else {
		QTextStream stream(&file);
		if (!doc.setContent(stream.readAll())) {
			qDebug("can not set content ");
			file.close();
			return false;
		} else {
			root = doc.documentElement();
			towary = root.firstChild().toElement();
			uslugi = root.lastChild().toElement();
		}
	}

	root.lastChild();

	if (type == 0) {
		QDomElement elem;
		for (QDomNode n = towary.firstChild(); !n.isNull(); n = n.nextSibling()) {
			if (n.toElement().attribute("idx").compare(name) == 0) {
				elem = n.toElement();
				break;
			}
		}
		productsDataToElem(prodData, elem);
		towary.appendChild(elem);
	}

	if (type == 1) {
		QDomElement elem;
		for (QDomNode n = uslugi.firstChild(); !n.isNull(); n = n.nextSibling()) {
			if (n.toElement().attribute("idx").compare(name) == 0) {
				elem = n.toElement();
				break;
			}
		}
		productsDataToElem(prodData, elem);
		uslugi.appendChild(elem);
	}

	QString xml = doc.toString();

	file.close();
	file.open(QIODevice::WriteOnly);
	QTextStream ts(&file);
	ts.setCodec(QTextCodec::codecForName(sett().getCodecName()));
	ts << xml;
	file.close();

	return true;
}
예제 #21
0
bool NetWorkEnviromentVariable::saveParametersToXMLDoc(const QMap <QString, QVariant> &parameters)
{
    if(!networkSettingFileIsSet)
    {
        return false;
    }
    if(networkSettingFile.isOpen())
        networkSettingFile.close();
    if(!networkSettingFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
    {
        return false;
    }
    QDomNodeList list = networkSettingXMLDoc->elementsByTagName("Parameters");

    if(list.count() == 0)
    {
        return false;
    }
    // print out the element names of all elements that are direct children
    // of the outermost element.
    QDomElement parameterElements = list.at(0).toElement();

    QMapIterator<QString, QVariant> i(parameters);
    while (i.hasNext()) {
        i.next();
        QDomElement aparameter;
        QDomNodeList matchingList = parameterElements.elementsByTagName(i.key());

        if(matchingList.count()>0)
            aparameter = matchingList.at(0).toElement();
        else
            aparameter = networkSettingXMLDoc->createElement(i.key());

        parameterElements.appendChild(aparameter);
        while(aparameter.childNodes().count() > 0)
        {
            aparameter.removeChild(aparameter.lastChild());
        }
        if(i.value().type() == QVariant::List)
        {
            QList<QVariant> valuelist = i.value().toList();
            for(int j = 0; j < valuelist.count(); j ++)
            {
                QDomElement listitemx = networkSettingXMLDoc->createElement("valuelistx");
                aparameter.appendChild(listitemx);
                QPointF apoint = valuelist.at(j).toPointF();
                QDomText xvalue = networkSettingXMLDoc->createTextNode(QVariant(apoint.x()).toString());
                listitemx.appendChild(xvalue);
                QDomElement listitemy = networkSettingXMLDoc->createElement("valuelisty");
                aparameter.appendChild(listitemy);
                QDomText yvalue = networkSettingXMLDoc->createTextNode(QVariant(apoint.y()).toString());
                listitemy.appendChild(yvalue);
            }
        }
        else
        {
            QDomText value = networkSettingXMLDoc->createTextNode(i.value().toString());
            aparameter.appendChild(value);
        }
     }

//    qDebug() << networkSettingXMLDoc->toString();
    QTextStream out(&networkSettingFile);
    networkSettingXMLDoc->save(out,IndentSize);
    networkSettingFile.close();
    return true;
}
예제 #22
0
// Author & Date: Ehsan Azar       3 April 2012
// Purpose: Begin a new Xml group or navigate to it if it exists
// Inputs:
//   nodeName  - the node tag (it can be in the form of relative/path/to/node)
//                node index (0-based) is enclosed (relative/path/to/node<2>/subnode)
//             Note: nodeName tags are always created if they do not exist
//   attribs   - attribute name, attribute value pairs
//   value     - new node value, if non-empty
// Outputs:
//  Returns true if nodeName is created
bool XmlFile::beginGroup(QString nodeName, const QMap<QString, QVariant> attribs, const QVariant & value)
{
    bool bRet = false;
    QDomElement set;

    if (nodeName.isEmpty())
        nodeName = firstChildKey();
    if (nodeName.isEmpty())
        nodeName = "XmlItem";
    // Get the node path
    QStringList nodepath = nodeName.split("/");
    int level = nodepath.count();
    m_levels.append(level);
    for (int i = 0; i < level; ++i)
    {
        QString strTagName = nodepath[i];
        // Extract index
        int index = 0;
        {
            int idx = strTagName.indexOf("<");
            if (idx >= 0)
            {
                index = strTagName.mid(idx + 1, strTagName.length() - idx - 2).toInt();
                strTagName = strTagName.left(idx);
                nodepath[i] = strTagName;
            }
        }
        // Look if the element (with given index) exists then get it
        QDomNode parent;
        if (!m_nodes.isEmpty())
        {
            // Get the current node
            parent = m_nodes.last();
        } else {
            parent = m_doc;
        }
        int count = 0;
        for(QDomElement elem = parent.firstChildElement(strTagName); !elem.isNull(); elem = elem.nextSiblingElement(strTagName))
        {
            count++;
            if (count == index + 1)
            {
                set = elem;
                break;
            }
        }
        // Create all new subnodes
        for (int j = 0; j < (index + 1 - count); ++j)
        {
            bRet = true;
            set = m_doc.createElement(strTagName);
            parent.appendChild(set);
        }
        // Add all the parent nodes without attribute or value
        if (i < level - 1)
            m_nodes.append(set);
    }
    
    // Now add the node to the end of the list
    m_nodes.append(set);

    // if there is some text/value to set
    if (value.isValid())
    {
        bool bTextLeaf = false;
        QVariantList varlst;
        switch (value.type())
        {
        case QVariant::StringList:
        case QVariant::List:
            varlst = value.toList();
            if (AddList(varlst, nodepath.last()))
                set.setAttribute("Type", "Array");
            break;
        default:
            QString text;
            if (value.type() == QVariant::UserType)
            {
                const XmlItem * item = static_cast<const XmlItem *>(value.data());
                QVariant subval = item->XmlValue();
                
                if (subval.type() == QVariant::UserType)
                {
                    const XmlItem * subitem = static_cast<const XmlItem *>(subval.data());
                    QString strSubKey = subitem->XmlName();
                    QMap<QString, QVariant> attribs = subitem->XmlAttribs();
                    // Recursively add this item
                    beginGroup(strSubKey, attribs, subval);
                    endGroup();
                } 
                else if (subval.type() == QVariant::List || subval.type() == QVariant::StringList)
                {
                    varlst = subval.toList();
                    if (AddList(varlst, nodepath.last()))
                        set.setAttribute("Type", "Array");
                } else {
                    text = subval.toString();
                    bTextLeaf = true;
                }
            } else {
                text = value.toString();
                bTextLeaf = true;
            }
            if (bTextLeaf)
            {
                // Remove all the children
                while (set.hasChildNodes())
                    set.removeChild(set.lastChild());
                // See if this is Xml fragment string
                XmlFile xml;
                if (!xml.setContent(text))
                {
                    QDomNode frag = m_doc.importNode(xml.getFragment(), true);
                    set.appendChild(frag);
                } else {
                    QDomText domText = m_doc.createTextNode(text);
                    set.appendChild(domText);
                }
            }
        }
    }

    // Add all the additional attributes
    QMap<QString, QVariant>::const_iterator iterator;
    for (iterator = attribs.begin(); iterator != attribs.end(); ++iterator)
    {
        QString attrName = iterator.key();
        QVariant attrValue = iterator.value();
        switch (attrValue.type())
        {
        case QVariant::String:
            set.setAttribute(attrName, attrValue.toString());
            break;
        case QVariant::Int:
            set.setAttribute(attrName, attrValue.toInt());
            break;
        case QVariant::UInt:
            set.setAttribute(attrName, attrValue.toUInt());
            break;
        case QVariant::LongLong:
            set.setAttribute(attrName, attrValue.toLongLong());
            break;
        case QVariant::ULongLong:
            set.setAttribute(attrName, attrValue.toULongLong());
            break;
        default:
            // everything else is treated as double floating point
            set.setAttribute(attrName, attrValue.toDouble());
            break;
        }
    }
    return bRet;
}
예제 #23
0
void PhonemeEditorWidget::parseXmlFile()
{
    // Clear old text boxes
    QList<TimeLineTextEdit *> oldText= m_text->findChildren<TimeLineTextEdit *>();
    while(!oldText.isEmpty())
        delete oldText.takeFirst();

    // Clear old phoneme comboboxes
    QList<TimeLineComboBox *> oldPhoneme = m_phonemes->findChildren<TimeLineComboBox *>();
    while(!oldPhoneme.isEmpty())
        delete oldPhoneme.takeFirst();

    // Get new items from phoneme xml
    QDomElement timings = m_phonemeXml.firstChildElement("PhonemeTimings");

    // Get length of phoneme timings
    QDomElement last = timings.lastChildElement("word");
    int sentenceLength = 0;
    if(!last.isNull()) sentenceLength = last.attribute("end", "0").toInt();
    last = timings.lastChildElement("phn");
    if( !last.isNull() ) sentenceLength = max(sentenceLength, last.attribute("end", "0").toInt() );

    // Get minimal phoneme width
    QDomNodeList phnlist = timings.elementsByTagName("phn");
    int minPhnWidth = 999999;
    for(unsigned int i=0; i<phnlist.length(); i++)
    {
        QDomElement phn = phnlist.item(i).toElement();
        // Skip silence
        if( phn.attribute("value").compare("x") == 0 ) continue;
        int start = phn.attribute("start", "0").toInt();
        int end = phn.attribute("end", "999999").toInt();
        if( end-start < minPhnWidth ) minPhnWidth = end-start;
    }
    int minWidth =  (int)( 39.5f / minPhnWidth * sentenceLength );

    // Get length of panels and enlarge them if too small
    if( m_text->width()-2 < minWidth)
    {
        m_text->setFixedWidth(minWidth+2);
        m_phonemes->setFixedWidth(minWidth+2);
        m_phonemeScrollArea->setFixedWidth(m_text->x()+minWidth+2);
    }

    // Add wordBoxes in reverse direction, because first nodes have higher priority
    // and should be printed above of the others
    QDomNode wordNode = timings.lastChild();
    while(!wordNode.isNull())
    {
        // Get words
        if( wordNode.nodeName().compare("word") == 0)
        {
            QDomElement word = wordNode.toElement();
            TimeLineTextEdit* wordBox = new TimeLineTextEdit(word, sentenceLength, m_text);
            connect(wordBox, SIGNAL(xmlNodeChanged()), this, SLOT(enableSaveButton()) );
            wordBox->setVisible(true);

            // Get phonemes of a word
            QDomNodeList phonemeList = word.elementsByTagName("phn");
            // also reverse direction
            for(int i = phonemeList.size()-1; i >=0; i--)
            {
                QDomElement phoneme = phonemeList.item(i).toElement();
                // Skip silence
                if( phoneme.attribute("value").compare("x") == 0 ) continue;
                TimeLineComboBox* phonemeBox = new TimeLineComboBox(phoneme, sentenceLength, m_phonemeList, m_phonemes);
                connect(phonemeBox, SIGNAL(xmlNodeChanged()), this, SLOT(enableSaveButton()) );
                connect(phonemeBox, SIGNAL(xmlNodeChanged()), wordBox, SLOT(updateFromXml()));
                phonemeBox->setVisible(true);
            }
        }
        // Get phonemes which don't belong to words
        else if( wordNode.nodeName().compare("phn") == 0 )
        {
            QDomElement phoneme = wordNode.toElement();
            // Skip silence
            if( phoneme.attribute("value").compare("x") != 0 )
            {
                TimeLineComboBox* phonemeBox = new TimeLineComboBox(phoneme, sentenceLength, m_phonemeList, m_phonemes);
                connect(phonemeBox, SIGNAL(xmlNodeChanged()), this, SLOT(enableSaveButton()) );
                phonemeBox->setVisible(true);
            }
        }

        wordNode = wordNode.previousSibling();
    }
}
예제 #24
0
bool KXMLGUIClient::mergeXML( QDomElement &base, const QDomElement &additive, KActionCollection *actionCollection )
{
  static const QString &tagAction = KGlobal::staticQString( "Action" );
  static const QString &tagMerge = KGlobal::staticQString( "Merge" );
  static const QString &tagSeparator = KGlobal::staticQString( "Separator" );
  static const QString &attrName = KGlobal::staticQString( "name" );
  static const QString &attrAppend = KGlobal::staticQString( "append" );
  static const QString &attrWeakSeparator = KGlobal::staticQString( "weakSeparator" );
  static const QString &tagMergeLocal = KGlobal::staticQString( "MergeLocal" );
  static const QString &tagText = KGlobal::staticQString( "text" );
  static const QString &attrAlreadyVisited = KGlobal::staticQString( "alreadyVisited" );
  static const QString &attrNoMerge = KGlobal::staticQString( "noMerge" );
  static const QString &attrOne = KGlobal::staticQString( "1" );

  // there is a possibility that we don't want to merge in the
  // additive.. rather, we might want to *replace* the base with the
  // additive.  this can be for any container.. either at a file wide
  // level or a simple container level.  we look for the 'noMerge'
  // tag, in any event and just replace the old with the new
  if ( additive.attribute(attrNoMerge) == attrOne ) // ### use toInt() instead? (Simon)
  {
    base.parentNode().replaceChild(additive, base);
    return true;
  }

  QString tag;

  // iterate over all elements in the container (of the global DOM tree)
  QDomNode n = base.firstChild();
  while ( !n.isNull() )
  {
    QDomElement e = n.toElement();
    n = n.nextSibling(); // Advance now so that we can safely delete e
    if (e.isNull())
       continue;

    tag = e.tagName();

    // if there's an action tag in the global tree and the action is
    // not implemented, then we remove the element
    if ( tag == tagAction )
    {
      QCString name =  e.attribute( attrName ).utf8(); // WABA
      if ( !actionCollection->action( name ) ||
           (kapp && !kapp->authorizeKAction(name)))
      {
        // remove this child as we aren't using it
        base.removeChild( e );
        continue;
      }
    }

    // if there's a separator defined in the global tree, then add an
    // attribute, specifying that this is a "weak" separator
    else if ( tag == tagSeparator )
    {
      e.setAttribute( attrWeakSeparator, (uint)1 );

      // okay, hack time. if the last item was a weak separator OR
      // this is the first item in a container, then we nuke the
      // current one
      QDomElement prev = e.previousSibling().toElement();
      if ( prev.isNull() ||
	 ( prev.tagName() == tagSeparator && !prev.attribute( attrWeakSeparator ).isNull() ) ||
	 ( prev.tagName() == tagText ) )
      {
        // the previous element was a weak separator or didn't exist
        base.removeChild( e );
        continue;
      }
    }

    // the MergeLocal tag lets us specify where non-standard elements
    // of the local tree shall be merged in.  After inserting the
    // elements we delete this element
    else if ( tag == tagMergeLocal )
    {
      QDomNode it = additive.firstChild();
      while ( !it.isNull() )
      {
        QDomElement newChild = it.toElement();
        it = it.nextSibling();
        if (newChild.isNull() )
          continue;

        if ( newChild.tagName() == tagText )
          continue;

        if ( newChild.attribute( attrAlreadyVisited ) == attrOne )
          continue;

        QString itAppend( newChild.attribute( attrAppend ) );
        QString elemName( e.attribute( attrName ) );

        if ( ( itAppend.isNull() && elemName.isEmpty() ) ||
             ( itAppend == elemName ) )
        {
          // first, see if this new element matches a standard one in
          // the global file.  if it does, then we skip it as it will
          // be merged in, later
          QDomElement matchingElement = findMatchingElement( newChild, base );
          if ( matchingElement.isNull() || newChild.tagName() == tagSeparator )
            base.insertBefore( newChild, e );
        }
      }

      base.removeChild( e );
      continue;
    }

    // in this last case we check for a separator tag and, if not, we
    // can be sure that its a container --> proceed with child nodes
    // recursively and delete the just proceeded container item in
    // case its empty (if the recursive call returns true)
    else if ( tag != tagMerge )
    {
      // handle the text tag
      if ( tag == tagText )
        continue;

      QDomElement matchingElement = findMatchingElement( e, additive );

      if ( !matchingElement.isNull() )
      {
        matchingElement.setAttribute( attrAlreadyVisited, (uint)1 );

        if ( mergeXML( e, matchingElement, actionCollection ) )
        {
          base.removeChild( e );
          continue;
        }

        // Merge attributes
        const QDomNamedNodeMap attribs = matchingElement.attributes();
        const uint attribcount = attribs.count();

        for(uint i = 0; i < attribcount; ++i)
        {
          const QDomNode node = attribs.item(i);
          e.setAttribute(node.nodeName(), node.nodeValue());
        }

        continue;
      }
      else
      {
        // this is an important case here! We reach this point if the
        // "local" tree does not contain a container definition for
        // this container. However we have to call mergeXML recursively
        // and make it check if there are actions implemented for this
        // container. *If* none, then we can remove this container now
        if ( mergeXML( e, QDomElement(), actionCollection ) )
          base.removeChild( e );
        continue;
      }
    }
  }

  //here we append all child elements which were not inserted
  //previously via the LocalMerge tag
  n = additive.firstChild();
  while ( !n.isNull() )
  {
    QDomElement e = n.toElement();
    n = n.nextSibling(); // Advance now so that we can safely delete e
    if (e.isNull())
       continue;

    QDomElement matchingElement = findMatchingElement( e, base );

    if ( matchingElement.isNull() )
    {
      base.appendChild( e );
    }
  }

  // do one quick check to make sure that the last element was not
  // a weak separator
  QDomElement last = base.lastChild().toElement();
  if ( (last.tagName() == tagSeparator) && (!last.attribute( attrWeakSeparator ).isNull()) )
  {
    base.removeChild( last );
  }

  // now we check if we are empty (in which case we return "true", to
  // indicate the caller that it can delete "us" (the base element
  // argument of "this" call)
  bool deleteMe = true;

  n = base.firstChild();
  while ( !n.isNull() )
  {
    QDomElement e = n.toElement();
    n = n.nextSibling(); // Advance now so that we can safely delete e
    if (e.isNull())
       continue;

    tag = e.tagName();

    if ( tag == tagAction )
    {
      // if base contains an implemented action, then we must not get
      // deleted (note that the actionCollection contains both,
      // "global" and "local" actions
      if ( actionCollection->action( e.attribute( attrName ).utf8() ) )
      {
        deleteMe = false;
        break;
      }
    }
    else if ( tag == tagSeparator )
    {
      // if we have a separator which has *not* the weak attribute
      // set, then it must be owned by the "local" tree in which case
      // we must not get deleted either
      QString weakAttr = e.attribute( attrWeakSeparator );
      if ( weakAttr.isEmpty() || weakAttr.toInt() != 1 )
      {
        deleteMe = false;
        break;
      }
    }

    // in case of a merge tag we have unlimited lives, too ;-)
    else if ( tag == tagMerge )
    {
//      deleteMe = false;
//      break;
        continue;
    }

    // a text tag is NOT enough to spare this container
    else if ( tag == tagText )
    {
      continue;
    }

    // what's left are non-empty containers! *don't* delete us in this
    // case (at this position we can be *sure* that the container is
    // *not* empty, as the recursive call for it was in the first loop
    // which deleted the element in case the call returned "true"
    else
    {
      deleteMe = false;
      break;
    }
  }

  return deleteMe;
}