summaryrefslogtreecommitdiffstats
path: root/kig/objects/object_imp_factory.cc
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-11 04:44:41 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-11 04:44:41 +0000
commita374efce3a207b39514be3c52264091400ce297e (patch)
tree77bdf654b55826d4f59b53a5621310206bcaead1 /kig/objects/object_imp_factory.cc
parentf81a494f3957d5cf38c787973415597941934727 (diff)
downloadtdeedu-a374efce3a207b39514be3c52264091400ce297e.tar.gz
tdeedu-a374efce3a207b39514be3c52264091400ce297e.zip
TQt4 port kdeedu
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1236073 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kig/objects/object_imp_factory.cc')
-rw-r--r--kig/objects/object_imp_factory.cc138
1 files changed, 69 insertions, 69 deletions
diff --git a/kig/objects/object_imp_factory.cc b/kig/objects/object_imp_factory.cc
index 65cd9c94..116f0d0d 100644
--- a/kig/objects/object_imp_factory.cc
+++ b/kig/objects/object_imp_factory.cc
@@ -48,25 +48,25 @@ ObjectImpFactory::~ObjectImpFactory()
{
}
-static void addXYElements( const Coordinate& c, TQDomElement& parent, TQDomDocument& doc )
+static void addXYElements( const Coordinate& c, TQDomElement& tqparent, TQDomDocument& doc )
{
TQDomElement xe = doc.createElement( "x" );
xe.appendChild(
doc.createTextNode(
TQString::number( c.x ) ) );
- parent.appendChild( xe );
+ tqparent.appendChild( xe );
TQDomElement ye = doc.createElement( "y" );
ye.appendChild(
doc.createTextNode(
TQString::number( c.y ) ) );
- parent.appendChild( ye );
+ tqparent.appendChild( ye );
}
-static void addDoubleElement( const char* name, double d, TQDomElement& parent, TQDomDocument& doc )
+static void addDoubleElement( const char* name, double d, TQDomElement& tqparent, TQDomDocument& doc )
{
TQDomElement e = doc.createElement( name );
e.appendChild( doc.createTextNode( TQString::number( d ) ) );
- parent.appendChild( e );
+ tqparent.appendChild( e );
}
static void addCoordinateElement( const char* name, const Coordinate& d, TQDomElement& p, TQDomDocument& doc )
@@ -76,41 +76,41 @@ static void addCoordinateElement( const char* name, const Coordinate& d, TQDomEl
p.appendChild( e );
}
-TQString ObjectImpFactory::serialize( const ObjectImp& d, TQDomElement& parent,
+TQString ObjectImpFactory::serialize( const ObjectImp& d, TQDomElement& tqparent,
TQDomDocument& doc ) const
{
if( d.inherits( IntImp::stype() ) )
{
- parent.appendChild(
+ tqparent.appendChild(
doc.createTextNode(
TQString::number( static_cast<const IntImp&>( d ).data() ) ) );
- return TQString::fromLatin1( "int" );
+ return TQString::tqfromLatin1( "int" );
}
else if ( d.inherits( DoubleImp::stype() ) )
{
- parent.appendChild(
+ tqparent.appendChild(
doc.createTextNode(
TQString::number( static_cast<const DoubleImp&>( d ).data() ) ) );
- return TQString::fromLatin1( "double" );
+ return TQString::tqfromLatin1( "double" );
}
else if( d.inherits( StringImp::stype() ) )
{
- parent.appendChild(
+ tqparent.appendChild(
doc.createTextNode(
static_cast<const StringImp&>( d ).data() ) );
- return TQString::fromLatin1( "string" );
+ return TQString::tqfromLatin1( "string" );
}
else if ( d.inherits( TestResultImp::stype() ) )
{
- parent.appendChild(
+ tqparent.appendChild(
doc.createTextNode(
static_cast<const TestResultImp&>( d ).data() ) );
- return TQString::fromLatin1( "testresult" );
+ return TQString::tqfromLatin1( "testresult" );
}
else if( d.inherits( HierarchyImp::stype() ) )
{
- static_cast<const HierarchyImp&>( d ).data().serialize( parent, doc );
- return TQString::fromLatin1( "hierarchy" );
+ static_cast<const HierarchyImp&>( d ).data().serialize( tqparent, doc );
+ return TQString::tqfromLatin1( "hierarchy" );
}
else if ( d.inherits( TransformationImp::stype() ) )
{
@@ -128,58 +128,58 @@ TQString ObjectImpFactory::serialize( const ObjectImp& d, TQDomElement& parent,
matrixe.appendChild( elel );
};
}
- parent.appendChild( matrixe );
+ tqparent.appendChild( matrixe );
TQDomElement homothetye = doc.createElement( "homothetic" );
const char* ishomothety = trans.isHomothetic() ? "true" : "false";
homothetye.appendChild( doc.createTextNode( ishomothety ) );
- parent.appendChild( homothetye );
+ tqparent.appendChild( homothetye );
- return TQString::fromLatin1( "transformation" );
+ return TQString::tqfromLatin1( "transformation" );
}
else if( d.inherits( AbstractLineImp::stype() ) )
{
LineData l = static_cast<const AbstractLineImp&>( d ).data();
- addCoordinateElement( "a", l.a, parent, doc );
- addCoordinateElement( "b", l.b, parent, doc );
+ addCoordinateElement( "a", l.a, tqparent, doc );
+ addCoordinateElement( "b", l.b, tqparent, doc );
if( d.inherits( SegmentImp::stype() ) )
- return TQString::fromLatin1( "segment" );
+ return TQString::tqfromLatin1( "segment" );
else if( d.inherits( RayImp::stype() ) )
- return TQString::fromLatin1( "ray" );
- else return TQString::fromLatin1( "line" );
+ return TQString::tqfromLatin1( "ray" );
+ else return TQString::tqfromLatin1( "line" );
}
else if( d.inherits( PointImp::stype() ) )
{
addXYElements( static_cast<const PointImp&>( d ).coordinate(),
- parent, doc );
- return TQString::fromLatin1( "point" );
+ tqparent, doc );
+ return TQString::tqfromLatin1( "point" );
}
else if( d.inherits( TextImp::stype() ) )
{
TQString text = static_cast<const TextImp&>( d ).text();
- parent.appendChild(
+ tqparent.appendChild(
doc.createTextNode( text ) );
- return TQString::fromLatin1( "text" );
+ return TQString::tqfromLatin1( "text" );
}
else if( d.inherits( AngleImp::stype() ) )
{
- addDoubleElement( "size", static_cast<const AngleImp&>( d ).size(), parent, doc );
- return TQString::fromLatin1( "angle" );
+ addDoubleElement( "size", static_cast<const AngleImp&>( d ).size(), tqparent, doc );
+ return TQString::tqfromLatin1( "angle" );
}
else if ( d.inherits( ArcImp::stype() ) )
{
const ArcImp& a = static_cast<const ArcImp&>( d );
- addCoordinateElement( "center", a.center(), parent, doc );
- addDoubleElement( "radius", a.radius(), parent, doc );
- addDoubleElement( "startangle", a.startAngle(), parent, doc );
- addDoubleElement( "angle", a.angle(), parent, doc );
- return TQString::fromLatin1( "arc" );
+ addCoordinateElement( "center", a.center(), tqparent, doc );
+ addDoubleElement( "radius", a.radius(), tqparent, doc );
+ addDoubleElement( "startangle", a.startAngle(), tqparent, doc );
+ addDoubleElement( "angle", a.angle(), tqparent, doc );
+ return TQString::tqfromLatin1( "arc" );
}
else if( d.inherits( VectorImp::stype() ) )
{
Coordinate dir = static_cast<const VectorImp&>( d ).dir();
- addXYElements( dir, parent, doc );
- return TQString::fromLatin1( "vector" );
+ addXYElements( dir, tqparent, doc );
+ return TQString::tqfromLatin1( "vector" );
}
else if( d.inherits( LocusImp::stype() ) )
{
@@ -190,30 +190,30 @@ TQString ObjectImpFactory::serialize( const ObjectImp& d, TQDomElement& parent,
const CurveImp& curveimp = *locus.curve();
TQString type = serialize( curveimp, curve, doc );
curve.setAttribute( "type", type );
- parent.appendChild( curve );
+ tqparent.appendChild( curve );
// serialize the hierarchy..
TQDomElement hier = doc.createElement( "calculation" );
locus.hierarchy().serialize( hier, doc );
- parent.appendChild( hier );
+ tqparent.appendChild( hier );
- return TQString::fromLatin1( "locus" );
+ return TQString::tqfromLatin1( "locus" );
}
else if( d.inherits( CircleImp::stype() ) )
{
const CircleImp& c = static_cast<const CircleImp&>( d );
- addCoordinateElement( "center", c.center(), parent, doc );
- addDoubleElement( "radius", c.radius(), parent, doc );
- return TQString::fromLatin1( "circle" );
+ addCoordinateElement( "center", c.center(), tqparent, doc );
+ addDoubleElement( "radius", c.radius(), tqparent, doc );
+ return TQString::tqfromLatin1( "circle" );
}
else if( d.inherits( ConicImp::stype() ) )
{
const ConicPolarData data = static_cast<const ConicImp&>( d ).polarData();
- addCoordinateElement( "focus1", data.focus1, parent, doc );
- addDoubleElement( "pdimen", data.pdimen, parent, doc );
- addDoubleElement( "ecostheta0", data.ecostheta0, parent, doc );
- addDoubleElement( "esintheta0", data.esintheta0, parent, doc );
- return TQString::fromLatin1( "conic" );
+ addCoordinateElement( "focus1", data.focus1, tqparent, doc );
+ addDoubleElement( "pdimen", data.pdimen, tqparent, doc );
+ addDoubleElement( "ecostheta0", data.ecostheta0, tqparent, doc );
+ addDoubleElement( "esintheta0", data.esintheta0, tqparent, doc );
+ return TQString::tqfromLatin1( "conic" );
}
else if( d.inherits( CubicImp::stype() ) )
{
@@ -229,11 +229,11 @@ TQString ObjectImpFactory::serialize( const ObjectImp& d, TQDomElement& parent,
addDoubleElement( "a112", data.coeffs[7], coeffs, doc );
addDoubleElement( "a122", data.coeffs[8], coeffs, doc );
addDoubleElement( "a222", data.coeffs[9], coeffs, doc );
- parent.appendChild( coeffs );
- return TQString::fromLatin1( "cubic" );
+ tqparent.appendChild( coeffs );
+ return TQString::tqfromLatin1( "cubic" );
}
assert( false );
- return TQString::null;
+ return TQString();
}
static Coordinate readXYElements( const TQDomElement& e, bool& ok )
@@ -285,40 +285,40 @@ static double readDoubleElement( TQDomNode n, bool& ok,
}
ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
- const TQDomElement& parent,
+ const TQDomElement& tqparent,
TQString& error ) const
{
#define KIG_GENERIC_PARSE_ERROR \
{ \
error = i18n( "An error was encountered at line %1 in file %2." ) \
- .arg( __LINE__ ).arg( __FILE__ ); \
+ .tqarg( __LINE__ ).tqarg( __FILE__ ); \
return 0; \
}
bool ok = true;
if ( type == "int" )
{
- int ret = parent.text().toInt( &ok );
+ int ret = tqparent.text().toInt( &ok );
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
return new IntImp( ret );
}
else if ( type == "double" )
{
- double ret = parent.text().toDouble( &ok );
+ double ret = tqparent.text().toDouble( &ok );
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
return new DoubleImp( ret );
}
else if ( type == "string" )
{
- return new StringImp( parent.text() );
+ return new StringImp( tqparent.text() );
}
else if ( type == "testresult" )
{
- return new TestResultImp( parent.text() );
+ return new TestResultImp( tqparent.text() );
}
else if ( type == "hierarchy" )
{
- ObjectHierarchy* hier = ObjectHierarchy::buildSafeObjectHierarchy( parent, error );
+ ObjectHierarchy* hier = ObjectHierarchy::buildSafeObjectHierarchy( tqparent, error );
if ( ! hier ) return 0;
HierarchyImp* imp = new HierarchyImp( *hier );
delete hier;
@@ -328,7 +328,7 @@ ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
{
double data[3][3];
bool homothetic = false;
- for ( TQDomElement childe = parent.firstChild().toElement();
+ for ( TQDomElement childe = tqparent.firstChild().toElement();
! childe.isNull(); childe = childe.nextSibling().toElement() )
{
if ( childe.tagName() == "matrix" )
@@ -357,13 +357,13 @@ ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
}
else if ( type == "point" )
{
- Coordinate ret = readXYElements( parent, ok );
+ Coordinate ret = readXYElements( tqparent, ok );
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
return new PointImp( ret );
}
else if ( type == "line" || type == "segment" || type == "ray" )
{
- TQDomNode n = parent.firstChild();
+ TQDomNode n = tqparent.firstChild();
Coordinate a = readCoordinateElement( n, ok, "a" );
if ( !ok ) KIG_GENERIC_PARSE_ERROR;
n = n.nextSibling();
@@ -375,13 +375,13 @@ ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
}
else if( type == "angle" )
{
- double size = readDoubleElement( parent.firstChild(), ok, "size" );
+ double size = readDoubleElement( tqparent.firstChild(), ok, "size" );
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
return new AngleImp( Coordinate(), 0, size );
}
else if ( type == "arc" )
{
- TQDomNode n = parent.firstChild();
+ TQDomNode n = tqparent.firstChild();
Coordinate center = readCoordinateElement( n, ok, "center" );
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
n = n.nextSibling();
@@ -397,13 +397,13 @@ ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
}
else if( type == "vector" )
{
- Coordinate dir = readXYElements( parent, ok );
+ Coordinate dir = readXYElements( tqparent, ok );
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
return new VectorImp( Coordinate(), dir );
}
else if( type == "locus" )
{
- TQDomElement curvee = parent.firstChild().toElement();
+ TQDomElement curvee = tqparent.firstChild().toElement();
if ( curvee.isNull() || curvee.tagName() != "curve" ) KIG_GENERIC_PARSE_ERROR;
TQString type = curvee.attribute( "type" );
ObjectImp* oi = deserialize( type, curvee, error );
@@ -417,7 +417,7 @@ ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
}
else if( type == "circle" )
{
- TQDomNode n = parent.firstChild();
+ TQDomNode n = tqparent.firstChild();
Coordinate center = readCoordinateElement( n, ok, "center" );
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
@@ -429,7 +429,7 @@ ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
}
else if( type == "conic" )
{
- TQDomNode n = parent.firstChild();
+ TQDomNode n = tqparent.firstChild();
Coordinate focus1 = readCoordinateElement( n, ok, "focus1" );
if ( ! ok ) KIG_GENERIC_PARSE_ERROR;
@@ -450,7 +450,7 @@ ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
}
else if( type == "cubic" )
{
- TQDomElement coeffse = parent.firstChild().toElement();
+ TQDomElement coeffse = tqparent.firstChild().toElement();
if ( coeffse.isNull() || coeffse.tagName() != "coefficients" )
KIG_GENERIC_PARSE_ERROR;
@@ -504,7 +504,7 @@ ObjectImp* ObjectImpFactory::deserialize( const TQString& type,
"which this Kig version does not support."
"Perhaps you have compiled Kig without support "
"for this object type,"
- "or perhaps you are using an older Kig version." ).arg( type );
+ "or perhaps you are using an older Kig version." ).tqarg( type );
return 0;
}