mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
QT6: QTextStream::setCodec use QTextStream::setEncoding
This commit is contained in:
@@ -164,9 +164,9 @@ bool QET::lineContainsPoint(const QLineF &line, const QPointF &point) {
|
|||||||
@return true si le projete orthogonal du point sur la droite appartient au
|
@return true si le projete orthogonal du point sur la droite appartient au
|
||||||
segment de droite.
|
segment de droite.
|
||||||
*/
|
*/
|
||||||
bool QET::orthogonalProjection(const QPointF &point,
|
bool QET::orthogonalProjection(
|
||||||
const QLineF &line,
|
const QPointF &point,const QLineF &line,QPointF *intersection)
|
||||||
QPointF *intersection) {
|
{
|
||||||
// recupere le vecteur normal de `line'
|
// recupere le vecteur normal de `line'
|
||||||
QLineF line_normal_vector(line.normalVector());
|
QLineF line_normal_vector(line.normalVector());
|
||||||
QPointF normal_vector(line_normal_vector.dx(), line_normal_vector.dy());
|
QPointF normal_vector(line_normal_vector.dx(), line_normal_vector.dy());
|
||||||
@@ -210,9 +210,9 @@ bool QET::orthogonalProjection(const QPointF &point,
|
|||||||
@param entier Pointeur facultatif vers un entier
|
@param entier Pointeur facultatif vers un entier
|
||||||
@return true si l'attribut est bien un entier, false sinon
|
@return true si l'attribut est bien un entier, false sinon
|
||||||
*/
|
*/
|
||||||
bool QET::attributeIsAnInteger(const QDomElement &e,
|
bool QET::attributeIsAnInteger(
|
||||||
const QString& nom_attribut,
|
const QDomElement &e,const QString& nom_attribut,int *entier)
|
||||||
int *entier) {
|
{
|
||||||
// verifie la presence de l'attribut
|
// verifie la presence de l'attribut
|
||||||
if (!e.hasAttribute(nom_attribut)) return(false);
|
if (!e.hasAttribute(nom_attribut)) return(false);
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
@@ -231,9 +231,9 @@ bool QET::attributeIsAnInteger(const QDomElement &e,
|
|||||||
@param reel Pointeur facultatif vers un double
|
@param reel Pointeur facultatif vers un double
|
||||||
@return true si l'attribut est bien un reel, false sinon
|
@return true si l'attribut est bien un reel, false sinon
|
||||||
*/
|
*/
|
||||||
bool QET::attributeIsAReal(const QDomElement &e,
|
bool QET::attributeIsAReal(
|
||||||
const QString& nom_attribut,
|
const QDomElement &e,const QString& nom_attribut,qreal *reel)
|
||||||
qreal *reel) {
|
{
|
||||||
// verifie la presence de l'attribut
|
// verifie la presence de l'attribut
|
||||||
if (!e.hasAttribute(nom_attribut)) return(false);
|
if (!e.hasAttribute(nom_attribut)) return(false);
|
||||||
// verifie la validite de l'attribut
|
// verifie la validite de l'attribut
|
||||||
@@ -258,13 +258,14 @@ bool QET::attributeIsAReal(const QDomElement &e,
|
|||||||
@return la proposition decrivant le nombre d'elements, de conducteurs et de
|
@return la proposition decrivant le nombre d'elements, de conducteurs et de
|
||||||
textes
|
textes
|
||||||
*/
|
*/
|
||||||
QString QET::ElementsAndConductorsSentence(int elements_count,
|
QString QET::ElementsAndConductorsSentence(
|
||||||
int conductors_count,
|
int elements_count,
|
||||||
int texts_count,
|
int conductors_count,
|
||||||
int images_count,
|
int texts_count,
|
||||||
int shapes_count,
|
int images_count,
|
||||||
int element_text_count,
|
int shapes_count,
|
||||||
int tables_count)
|
int element_text_count,
|
||||||
|
int tables_count)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
if (elements_count) {
|
if (elements_count) {
|
||||||
@@ -333,9 +334,14 @@ QString QET::ElementsAndConductorsSentence(int elements_count,
|
|||||||
/**
|
/**
|
||||||
@return the list of \a tag_name elements directly under the \a e XML element.
|
@return the list of \a tag_name elements directly under the \a e XML element.
|
||||||
*/
|
*/
|
||||||
QList<QDomElement> QET::findInDomElement(const QDomElement &e, const QString &tag_name) {
|
QList<QDomElement> QET::findInDomElement(
|
||||||
|
const QDomElement &e, const QString &tag_name)
|
||||||
|
{
|
||||||
QList<QDomElement> return_list;
|
QList<QDomElement> return_list;
|
||||||
for (QDomNode node = e.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
for (QDomNode node = e.firstChild() ;
|
||||||
|
!node.isNull() ;
|
||||||
|
node = node.nextSibling())
|
||||||
|
{
|
||||||
if (!node.isElement()) continue;
|
if (!node.isElement()) continue;
|
||||||
QDomElement element = node.toElement();
|
QDomElement element = node.toElement();
|
||||||
if (element.isNull() || element.tagName() != tag_name) continue;
|
if (element.isNull() || element.tagName() != tag_name) continue;
|
||||||
@@ -352,18 +358,24 @@ QList<QDomElement> QET::findInDomElement(const QDomElement &e, const QString &ta
|
|||||||
@param children tag XML a rechercher
|
@param children tag XML a rechercher
|
||||||
@return La liste des elements XML children
|
@return La liste des elements XML children
|
||||||
*/
|
*/
|
||||||
QList<QDomElement> QET::findInDomElement(const QDomElement &e,
|
QList<QDomElement> QET::findInDomElement(
|
||||||
const QString &parent,
|
const QDomElement &e,const QString &parent,const QString &children)
|
||||||
const QString &children) {
|
{
|
||||||
QList<QDomElement> return_list;
|
QList<QDomElement> return_list;
|
||||||
|
|
||||||
// parcours des elements parents
|
// parcours des elements parents
|
||||||
for (QDomNode enfant = e.firstChild() ; !enfant.isNull() ; enfant = enfant.nextSibling()) {
|
for (QDomNode enfant = e.firstChild() ;
|
||||||
|
!enfant.isNull() ;
|
||||||
|
enfant = enfant.nextSibling())
|
||||||
|
{
|
||||||
// on s'interesse a l'element XML "parent"
|
// on s'interesse a l'element XML "parent"
|
||||||
QDomElement parents = enfant.toElement();
|
QDomElement parents = enfant.toElement();
|
||||||
if (parents.isNull() || parents.tagName() != parent) continue;
|
if (parents.isNull() || parents.tagName() != parent) continue;
|
||||||
// parcours des enfants de l'element XML "parent"
|
// parcours des enfants de l'element XML "parent"
|
||||||
for (QDomNode node_children = parents.firstChild() ; !node_children.isNull() ; node_children = node_children.nextSibling()) {
|
for (QDomNode node_children = parents.firstChild() ;
|
||||||
|
!node_children.isNull() ;
|
||||||
|
node_children = node_children.nextSibling())
|
||||||
|
{
|
||||||
// on s'interesse a l'element XML "children"
|
// on s'interesse a l'element XML "children"
|
||||||
QDomElement n_children = node_children.toElement();
|
QDomElement n_children = node_children.toElement();
|
||||||
if (!n_children.isNull() && n_children.tagName() == children) return_list.append(n_children);
|
if (!n_children.isNull() && n_children.tagName() == children) return_list.append(n_children);
|
||||||
@@ -404,8 +416,8 @@ QString QET::license()
|
|||||||
*/
|
*/
|
||||||
QList<QChar> QET::forbiddenCharacters()
|
QList<QChar> QET::forbiddenCharacters()
|
||||||
{
|
{
|
||||||
return(QList<QChar>() << '\\' << '/' << ':' << '*' << '?' << '"'
|
return(QList<QChar>()
|
||||||
<< '<' << '>' << '|');
|
<< '\\' << '/' << ':' << '*' << '?' << '"'<< '<' << '>' << '|');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -614,7 +626,14 @@ bool QET::writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString *
|
|||||||
}
|
}
|
||||||
|
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
out.setCodec("UTF-8");
|
out.setCodec("UTF-8");
|
||||||
|
#else
|
||||||
|
#if TODO_LIST
|
||||||
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
|
#endif
|
||||||
|
out.setEncoding(QStringConverter::Utf8);
|
||||||
|
#endif
|
||||||
out.setGenerateByteOrderMark(false);
|
out.setGenerateByteOrderMark(false);
|
||||||
out << xml_doc.toString(4);
|
out << xml_doc.toString(4);
|
||||||
if (!file.commit())
|
if (!file.commit())
|
||||||
@@ -741,7 +760,14 @@ bool QET::writeToFile(QDomDocument &xml_doc, QFile *file, QString *error_message
|
|||||||
|
|
||||||
QTextStream out(file);
|
QTextStream out(file);
|
||||||
out.seek(0);
|
out.seek(0);
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
out.setCodec("UTF-8");
|
out.setCodec("UTF-8");
|
||||||
|
#else
|
||||||
|
#if TODO_LIST
|
||||||
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
|
#endif
|
||||||
|
out.setEncoding(QStringConverter::Utf8);
|
||||||
|
#endif
|
||||||
out.setGenerateByteOrderMark(false);
|
out.setGenerateByteOrderMark(false);
|
||||||
out << xml_doc.toString(4);
|
out << xml_doc.toString(4);
|
||||||
if (opened_here) {
|
if (opened_here) {
|
||||||
|
|||||||
@@ -274,7 +274,14 @@ bool QETXML::writeXmlFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
out.setCodec("UTF-8");
|
out.setCodec("UTF-8");
|
||||||
|
#else
|
||||||
|
#if TODO_LIST
|
||||||
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
|
#endif
|
||||||
|
out.setEncoding(QStringConverter::Utf8);
|
||||||
|
#endif
|
||||||
out.setGenerateByteOrderMark(false);
|
out.setGenerateByteOrderMark(false);
|
||||||
out << xml_document.toString(4);
|
out << xml_document.toString(4);
|
||||||
file.close();
|
file.close();
|
||||||
@@ -314,9 +321,9 @@ QVector<QDomElement> QETXML::directChild(
|
|||||||
{
|
{
|
||||||
QVector<QDomElement> return_list;
|
QVector<QDomElement> return_list;
|
||||||
for (
|
for (
|
||||||
QDomNode node = element.firstChild() ;
|
QDomNode node = element.firstChild() ;
|
||||||
!node.isNull() ;
|
!node.isNull() ;
|
||||||
node = node.nextSibling())
|
node = node.nextSibling())
|
||||||
{
|
{
|
||||||
if (!node.isElement()) continue;
|
if (!node.isElement()) continue;
|
||||||
QDomElement element = node.toElement();
|
QDomElement element = node.toElement();
|
||||||
@@ -345,18 +352,18 @@ QVector<QDomElement> QETXML::subChild(
|
|||||||
QVector<QDomElement> return_list;
|
QVector<QDomElement> return_list;
|
||||||
|
|
||||||
for (
|
for (
|
||||||
QDomNode child = element.firstChild() ;
|
QDomNode child = element.firstChild() ;
|
||||||
!child.isNull() ;
|
!child.isNull() ;
|
||||||
child = child.nextSibling())
|
child = child.nextSibling())
|
||||||
{
|
{
|
||||||
QDomElement parents = child.toElement();
|
QDomElement parents = child.toElement();
|
||||||
if (parents.isNull() || parents.tagName() != parent_tag_name)
|
if (parents.isNull() || parents.tagName() != parent_tag_name)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (
|
for (
|
||||||
QDomNode node_children = parents.firstChild() ;
|
QDomNode node_children = parents.firstChild() ;
|
||||||
!node_children.isNull() ;
|
!node_children.isNull() ;
|
||||||
node_children = node_children.nextSibling())
|
node_children = node_children.nextSibling())
|
||||||
{
|
{
|
||||||
QDomElement n_children = node_children.toElement();
|
QDomElement n_children = node_children.toElement();
|
||||||
if (!n_children.isNull() && n_children.tagName() == children_tag_name)
|
if (!n_children.isNull() && n_children.tagName() == children_tag_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user