fixed the terrible bug (QDomDocument&) node.toElement()

This commit is contained in:
granzuglia 2006-11-08 22:25:35 +00:00
parent fa68f489cc
commit deb5402d35
2 changed files with 49 additions and 23 deletions

View File

@ -172,8 +172,6 @@ namespace io {
m.face[ff].WT(0).u() = wt.at(indtx * 2).toFloat(); m.face[ff].WT(0).u() = wt.at(indtx * 2).toFloat();
m.face[ff].WT(0).v() = wt.at(indtx * 2 + 1).toFloat(); m.face[ff].WT(0).v() = wt.at(indtx * 2 + 1).toFloat();
m.face[ff].WT(0).n() = 1; m.face[ff].WT(0).n() = 1;
vcg::TCoord2<float> ttt = m.face[ff].WT(0);
int hh = 0;
} }
/*int indcl; /*int indcl;
@ -203,8 +201,6 @@ namespace io {
m.face[ff].WT(1).u() = wt.at(indtx * 2).toFloat(); m.face[ff].WT(1).u() = wt.at(indtx * 2).toFloat();
m.face[ff].WT(1).v() = wt.at(indtx * 2 + 1).toFloat(); m.face[ff].WT(1).v() = wt.at(indtx * 2 + 1).toFloat();
m.face[ff].WT(1).n() = 1; m.face[ff].WT(1).n() = 1;
vcg::TCoord2<float> ttt = m.face[ff].WT(1);
int hh = 0;
} }
/*if (!wcsrc.isNull()) /*if (!wcsrc.isNull())
@ -233,8 +229,6 @@ namespace io {
m.face[ff].WT(2).u() = wt.at(indtx * 2).toFloat(); m.face[ff].WT(2).u() = wt.at(indtx * 2).toFloat();
m.face[ff].WT(2).v() = wt.at(indtx * 2 + 1).toFloat(); m.face[ff].WT(2).v() = wt.at(indtx * 2 + 1).toFloat();
m.face[ff].WT(2).n() = 1; m.face[ff].WT(2).n() = 1;
vcg::TCoord2<float> ttt = m.face[ff].WT(2);
int hh = 0;
} }
/*if (!wcsrc.isNull()) /*if (!wcsrc.isNull())

View File

@ -102,15 +102,8 @@ namespace io {
assert(url_st.size() != 0); assert(url_st.size() != 0);
} }
inline static QDomNode findNodeBySpecificAttributeValue(const QDomNode& n,const QString& tag,const QString& attrname,const QString& attrvalue) inline static QDomNode findNodeBySpecificAttributeValue(const QDomNodeList& ndl,const QString& attrname,const QString& attrvalue)
{ {
QDomNode ndl = n.toElement();
return findNodeBySpecificAttributeValue((QDomDocument&) ndl,tag,attrname,attrvalue);
}
inline static QDomNode findNodeBySpecificAttributeValue(const QDomDocument& n,const QString& tag,const QString& attrname,const QString& attrvalue)
{
QDomNodeList ndl = n.elementsByTagName(tag);
int ndl_size = ndl.size(); int ndl_size = ndl.size();
assert(ndl_size != 0); assert(ndl_size != 0);
int ind = 0; int ind = 0;
@ -123,15 +116,29 @@ namespace io {
return QDomNode(); return QDomNode();
} }
inline static QDomNode findNodeBySpecificAttributeValue(const QDomNode& n,const QString& tag,const QString& attrname,const QString& attrvalue)
{
return findNodeBySpecificAttributeValue(n.toElement().elementsByTagName(tag),attrname,attrvalue);
}
inline static QDomNode findNodeBySpecificAttributeValue(const QDomDocument& n,const QString& tag,const QString& attrname,const QString& attrvalue)
{
return findNodeBySpecificAttributeValue(n.elementsByTagName(tag),attrname,attrvalue);
}
inline static bool isThereTag(const QDomNodeList& list)
{
return ((list.size() > 0) ? true : false);
}
inline static bool isThereTag(const QDomNode& n,const QString& tagname) inline static bool isThereTag(const QDomNode& n,const QString& tagname)
{ {
QDomNode ndl = n.toElement(); return isThereTag(n.toElement().elementsByTagName(tagname));
return isThereTag((QDomDocument&) n,tagname);
} }
inline static bool isThereTag(const QDomDocument& n,const QString& tagname) inline static bool isThereTag(const QDomDocument& n,const QString& tagname)
{ {
return ((n.toElement().elementsByTagName(tagname).size() > 0)? true : false); return isThereTag(n.elementsByTagName(tagname));
} }
@ -162,6 +169,8 @@ namespace io {
} }
/*inline static bool removeChildNode(QDomNodeList*/
inline static bool removeChildNodeList(QDomNodeList& nodelst,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") inline static bool removeChildNodeList(QDomNodeList& nodelst,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
{ {
for(int jj = 0;jj < nodelst.size();++jj) for(int jj = 0;jj < nodelst.size();++jj)
@ -171,13 +180,8 @@ namespace io {
return true; return true;
} }
inline static bool removeChildNode(QDomNode& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
{
return removeChildNode((QDomDocument&) node.toElement(),tag,attribname,attribvalue);
}
inline static bool removeChildNode(QDomDocument& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") inline static bool removeChildNode(QDomNode& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
//inline static bool removeChildNode(QDomNode node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
{ {
QDomNodeList clst = node.childNodes(); QDomNodeList clst = node.childNodes();
for(int ii = 0;ii < clst.size();++ii) for(int ii = 0;ii < clst.size();++ii)
@ -204,6 +208,34 @@ namespace io {
return true; return true;
} }
//inline static bool removeChildNode(QDomDocument& node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
////inline static bool removeChildNode(QDomNode node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
//{
// QDomNodeList clst = node.childNodes();
// for(int ii = 0;ii < clst.size();++ii)
// {
// QDomNode oldchild = node.childNodes().at(ii);
// if (tag != "")
// {
// if ((attribname != "") && (attribvalue != ""))
// {
// if (clst.at(ii).toElement().attribute(attribname) == attribvalue)
// node.removeChild(oldchild);
// }
// else
// {
// QString nm = clst.at(ii).nodeName();
// if (clst.at(ii).nodeName() == tag)
// {
// node.removeChild(oldchild);
// }
// }
// }
// else node.removeChild(oldchild);
// }
// return true;
//}
/*inline static bool removeChildNode(QDomDocument node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "") /*inline static bool removeChildNode(QDomDocument node,const QString& tag = "", const QString& attribname = "", const QString& attribvalue = "")
{ {
QDomNodeList clst = node.childNodes(); QDomNodeList clst = node.childNodes();