summaryrefslogtreecommitdiffstats
path: root/kig/misc/object_hierarchy.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/misc/object_hierarchy.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/misc/object_hierarchy.cc')
-rw-r--r--kig/misc/object_hierarchy.cc146
1 files changed, 73 insertions, 73 deletions
diff --git a/kig/misc/object_hierarchy.cc b/kig/misc/object_hierarchy.cc
index c2365aaa..7a977e63 100644
--- a/kig/misc/object_hierarchy.cc
+++ b/kig/misc/object_hierarchy.cc
@@ -47,14 +47,14 @@ public:
// on the given objects. The dependsstack contains a set of
// booleans telling which parts of the hierarchy certainly depend on
// the given objects. In this function, the node should check
- // whether any of its parents have true set, and if so, set its own
+ // whether any of its tqparents have true set, and if so, set its own
// value to true.
virtual void checkDependsOnGiven( std::vector<bool>& dependsstack, int loc ) const = 0;
// this function is used to check whether the given objects are all
- // used by one or more of the final objects. The usedstack contains
+ // used by one or more of the final objects. The usedstack tqcontains
// a set of booleans telling which parts of the hierarchy are
// certainly ancestors of the final objects. In this function, the
- // node should set all of its parents' booleans to true.
+ // node should set all of its tqparents' booleans to true.
virtual void checkArgumentsUsed( std::vector<bool>& usedstack ) const = 0;
};
@@ -118,15 +118,15 @@ class ApplyTypeNode
: public ObjectHierarchy::Node
{
const ObjectType* mtype;
- std::vector<int> mparents;
+ std::vector<int> mtqparents;
public:
- ApplyTypeNode( const ObjectType* type, const std::vector<int>& parents )
- : mtype( type ), mparents( parents ) {}
+ ApplyTypeNode( const ObjectType* type, const std::vector<int>& tqparents )
+ : mtype( type ), mtqparents( tqparents ) {}
~ApplyTypeNode();
Node* copy() const;
const ObjectType* type() const { return mtype; }
- const std::vector<int>& parents() const { return mparents; }
+ const std::vector<int>& tqparents() const { return mtqparents; }
int id() const;
void apply( std::vector<const ObjectImp*>& stack,
@@ -141,17 +141,17 @@ int ApplyTypeNode::id() const { return ID_ApplyType; }
void ApplyTypeNode::checkArgumentsUsed( std::vector<bool>& usedstack ) const
{
- for ( uint i = 0; i < mparents.size(); ++i )
+ for ( uint i = 0; i < mtqparents.size(); ++i )
{
- usedstack[mparents[i]] = true;
+ usedstack[mtqparents[i]] = true;
}
}
void ApplyTypeNode::checkDependsOnGiven( std::vector<bool>& dependsstack, int loc ) const
{
bool result = false;
- for ( uint i = 0; i < mparents.size(); ++i )
- if ( dependsstack[mparents[i]] == true ) result = true;
+ for ( uint i = 0; i < mtqparents.size(); ++i )
+ if ( dependsstack[mtqparents[i]] == true ) result = true;
dependsstack[loc] = result;
}
@@ -161,23 +161,23 @@ ApplyTypeNode::~ApplyTypeNode()
ObjectHierarchy::Node* ApplyTypeNode::copy() const
{
- return new ApplyTypeNode( mtype, mparents );
+ return new ApplyTypeNode( mtype, mtqparents );
}
void ApplyTypeNode::apply( std::vector<ObjectCalcer*>& stack, int loc ) const
{
- std::vector<ObjectCalcer*> parents;
- for ( uint i = 0; i < mparents.size(); ++i )
- parents.push_back( stack[ mparents[i] ] );
- stack[loc] = new ObjectTypeCalcer( mtype, parents );
+ std::vector<ObjectCalcer*> tqparents;
+ for ( uint i = 0; i < mtqparents.size(); ++i )
+ tqparents.push_back( stack[ mtqparents[i] ] );
+ stack[loc] = new ObjectTypeCalcer( mtype, tqparents );
}
void ApplyTypeNode::apply( std::vector<const ObjectImp*>& stack,
int loc, const KigDocument& doc ) const
{
Args args;
- for ( uint i = 0; i < mparents.size(); ++i )
- args.push_back( stack[mparents[i]] );
+ for ( uint i = 0; i < mtqparents.size(); ++i )
+ args.push_back( stack[mtqparents[i]] );
args = mtype->sortArgs( args );
stack[loc] = mtype->calc( args, doc );
}
@@ -186,21 +186,21 @@ class FetchPropertyNode
: public ObjectHierarchy::Node
{
mutable int mpropid;
- int mparent;
+ int mtqparent;
const TQCString mname;
public:
- // propid is a cache of the location of name in the parent's
+ // propid is a cache of the location of name in the tqparent's
// propertiesInternalNames(), just as it is in PropertyObject. We
// don't want to ever save this value, since we cannot guarantee it
// remains consistent if we add properties some place..
- FetchPropertyNode( const int parent, const TQCString& name, const int propid = -1 )
- : mpropid( propid ), mparent( parent ), mname( name ) {}
+ FetchPropertyNode( const int tqparent, const TQCString& name, const int propid = -1 )
+ : mpropid( propid ), mtqparent( tqparent ), mname( name ) {}
~FetchPropertyNode();
Node* copy() const;
void checkDependsOnGiven( std::vector<bool>& dependsstack, int loc ) const;
void checkArgumentsUsed( std::vector<bool>& usedstack ) const;
- int parent() const { return mparent; }
+ int tqparent() const { return mtqparent; }
const TQCString& propinternalname() const { return mname; }
int id() const;
@@ -215,17 +215,17 @@ FetchPropertyNode::~FetchPropertyNode()
void FetchPropertyNode::checkArgumentsUsed( std::vector<bool>& usedstack ) const
{
- usedstack[mparent] = true;
+ usedstack[mtqparent] = true;
}
void FetchPropertyNode::checkDependsOnGiven( std::vector<bool>& dependsstack, int loc ) const
{
- dependsstack[loc] = dependsstack[mparent];
+ dependsstack[loc] = dependsstack[mtqparent];
}
ObjectHierarchy::Node* FetchPropertyNode::copy() const
{
- return new FetchPropertyNode( mparent, mname, mpropid );
+ return new FetchPropertyNode( mtqparent, mname, mpropid );
}
int FetchPropertyNode::id() const
@@ -236,10 +236,10 @@ int FetchPropertyNode::id() const
void FetchPropertyNode::apply( std::vector<const ObjectImp*>& stack,
int loc, const KigDocument& d ) const
{
- assert( stack[mparent] );
- if ( mpropid == -1 ) mpropid = stack[mparent]->propertiesInternalNames().findIndex( mname );
+ assert( stack[mtqparent] );
+ if ( mpropid == -1 ) mpropid = stack[mtqparent]->propertiesInternalNames().tqfindIndex( mname );
if ( mpropid != -1 )
- stack[loc] = stack[mparent]->property( mpropid, d );
+ stack[loc] = stack[mtqparent]->property( mpropid, d );
else
stack[loc] = new InvalidImp();
}
@@ -247,9 +247,9 @@ void FetchPropertyNode::apply( std::vector<const ObjectImp*>& stack,
void FetchPropertyNode::apply( std::vector<ObjectCalcer*>& stack, int loc ) const
{
if ( mpropid == -1 )
- mpropid = stack[mparent]->imp()->propertiesInternalNames().findIndex( mname );
+ mpropid = stack[mtqparent]->imp()->propertiesInternalNames().tqfindIndex( mname );
assert( mpropid != -1 );
- stack[loc] = new ObjectPropertyCalcer( stack[mparent], mpropid );
+ stack[loc] = new ObjectPropertyCalcer( stack[mtqparent], mpropid );
}
std::vector<ObjectImp*> ObjectHierarchy::calc( const Args& a, const KigDocument& doc ) const
@@ -297,23 +297,23 @@ int ObjectHierarchy::visit( const ObjectCalcer* o, std::map<const ObjectCalcer*,
// because that's where we expect it.. We therefore copy it
// there using CopyObjectType..
int ret = mnumberofargs + mnodes.size();
- std::vector<int> parents;
- parents.push_back( smi->second );
- mnodes.push_back( new ApplyTypeNode( CopyObjectType::instance(), parents ) );
+ std::vector<int> tqparents;
+ tqparents.push_back( smi->second );
+ mnodes.push_back( new ApplyTypeNode( CopyObjectType::instance(), tqparents ) );
return ret;
}
else return smi->second;
}
- std::vector<ObjectCalcer*> p( o->parents() );
+ std::vector<ObjectCalcer*> p( o->tqparents() );
// we check if o descends from the given objects..
bool descendsfromgiven = false;
- std::vector<int> parents;
- parents.resize( p.size(), -1 );
+ std::vector<int> tqparents;
+ tqparents.resize( p.size(), -1 );
for ( uint i = 0; i < p.size(); ++i )
{
int v = visit( p[i], seenmap, false );
- parents[i] = v;
+ tqparents[i] = v;
descendsfromgiven |= (v != -1);
};
@@ -335,7 +335,7 @@ int ObjectHierarchy::visit( const ObjectCalcer* o, std::map<const ObjectCalcer*,
return -1;
};
- return storeObject( o, p, parents, seenmap );
+ return storeObject( o, p, tqparents, seenmap );
}
ObjectHierarchy::~ObjectHierarchy()
@@ -385,9 +385,9 @@ void ObjectHierarchy::init( const std::vector<ObjectCalcer*>& from, const std::v
seenmap[from[i]] = i;
for ( std::vector<ObjectCalcer*>::const_iterator i = to.begin(); i != to.end(); ++i )
{
- std::vector<ObjectCalcer*> parents = (*i)->parents();
- for ( std::vector<ObjectCalcer*>::const_iterator j = parents.begin();
- j != parents.end(); ++j )
+ std::vector<ObjectCalcer*> tqparents = (*i)->tqparents();
+ for ( std::vector<ObjectCalcer*>::const_iterator j = tqparents.begin();
+ j != tqparents.end(); ++j )
visit( *j, seenmap, true );
}
for ( std::vector<ObjectCalcer*>::const_iterator i = to.begin(); i != to.end(); ++i )
@@ -408,7 +408,7 @@ ObjectHierarchy::ObjectHierarchy( const std::vector<ObjectCalcer*>& from, const
init( from, to );
}
-void ObjectHierarchy::serialize( TQDomElement& parent, TQDomDocument& doc ) const
+void ObjectHierarchy::serialize( TQDomElement& tqparent, TQDomDocument& doc ) const
{
int id = 1;
for ( uint i = 0; i < mnumberofargs; ++i )
@@ -419,12 +419,12 @@ void ObjectHierarchy::serialize( TQDomElement& parent, TQDomDocument& doc ) cons
// we don't save these atm, since the user can't define them.
// we only load them from builtin macro's.
// TQDomElement ut = doc.createElement( "UseText" );
-// ut.appendChild( doc.createTextNode( TQString::fromLatin1(musetexts[i].c_str() ) ) );
+// ut.appendChild( doc.createTextNode( TQString::tqfromLatin1(musetexts[i].c_str() ) ) );
// e.appendChild( ut );
// TQDomElement ss = doc.createElement( "SelectStatement" );
-// ss.appendChild( doc.createTextNode( TQString::fromLatin1(mselectstatements[i].c_str() ) ) );
+// ss.appendChild( doc.createTextNode( TQString::tqfromLatin1(mselectstatements[i].c_str() ) ) );
// e.appendChild( ss );
- parent.appendChild( e );
+ tqparent.appendChild( e );
}
for ( uint i = 0; i < mnodes.size(); ++i )
@@ -437,12 +437,12 @@ void ObjectHierarchy::serialize( TQDomElement& parent, TQDomDocument& doc ) cons
{
const ApplyTypeNode* node = static_cast<const ApplyTypeNode*>( mnodes[i] );
e.setAttribute( "action", "calc" );
- e.setAttribute( "type", TQString::fromLatin1( node->type()->fullName() ) );
- for ( uint i = 0; i < node->parents().size(); ++i )
+ e.setAttribute( "type", TQString::tqfromLatin1( node->type()->fullName() ) );
+ for ( uint i = 0; i < node->tqparents().size(); ++i )
{
- int parent = node->parents()[i] + 1;
+ int tqparent = node->tqparents()[i] + 1;
TQDomElement arge = doc.createElement( "arg" );
- arge.appendChild( doc.createTextNode( TQString::number( parent ) ) );
+ arge.appendChild( doc.createTextNode( TQString::number( tqparent ) ) );
e.appendChild( arge );
};
}
@@ -450,9 +450,9 @@ void ObjectHierarchy::serialize( TQDomElement& parent, TQDomDocument& doc ) cons
{
const FetchPropertyNode* node = static_cast<const FetchPropertyNode*>( mnodes[i] );
e.setAttribute( "action", "fetch-property" );
- e.setAttribute( "property", node->propinternalname() );
+ e.setAttribute( TQString("property"), TQString(node->propinternalname()) );
TQDomElement arge = doc.createElement( "arg" );
- arge.appendChild( doc.createTextNode( TQString::number( node->parent() + 1 ) ) );
+ arge.appendChild( doc.createTextNode( TQString::number( node->tqparent() + 1 ) ) );
e.appendChild( arge );
}
else
@@ -464,7 +464,7 @@ void ObjectHierarchy::serialize( TQDomElement& parent, TQDomDocument& doc ) cons
e.setAttribute( "type", type );
};
- parent.appendChild( e );
+ tqparent.appendChild( e );
};
}
@@ -473,12 +473,12 @@ ObjectHierarchy::ObjectHierarchy()
{
}
-ObjectHierarchy* ObjectHierarchy::buildSafeObjectHierarchy( const TQDomElement& parent, TQString& error )
+ObjectHierarchy* ObjectHierarchy::buildSafeObjectHierarchy( const TQDomElement& tqparent, TQString& error )
{
#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; \
}
@@ -486,7 +486,7 @@ ObjectHierarchy* ObjectHierarchy::buildSafeObjectHierarchy( const TQDomElement&
bool ok = true;
TQString tmp;
- TQDomElement e = parent.firstChild().toElement();
+ TQDomElement e = tqparent.firstChild().toElement();
for (; !e.isNull(); e = e.nextSibling().toElement() )
{
if ( e.tagName() != "input" ) break;
@@ -537,18 +537,18 @@ ObjectHierarchy* ObjectHierarchy::buildSafeObjectHierarchy( const TQDomElement&
{
// ApplyTypeNode
TQCString typen = e.attribute( "type" ).latin1();
- const ObjectType* type = ObjectTypeFactory::instance()->find( typen );
+ const ObjectType* type = ObjectTypeFactory::instance()->tqfind( typen );
if ( ! type )
{
error = i18n( "This Kig file uses an object of type \"%1\", "
"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( typen );
+ "or perhaps you are using an older Kig version." ).tqarg( TQString(typen) );
return 0;
}
- std::vector<int> parents;
+ std::vector<int> tqparents;
for ( TQDomNode p = e.firstChild(); !p.isNull(); p = p.nextSibling() )
{
TQDomElement q = p.toElement();
@@ -556,18 +556,18 @@ ObjectHierarchy* ObjectHierarchy::buildSafeObjectHierarchy( const TQDomElement&
if ( q.tagName() != "arg" ) KIG_GENERIC_PARSE_ERROR;
int pid = q.text().toInt(&ok );
if ( !ok ) KIG_GENERIC_PARSE_ERROR;
- parents.push_back( pid - 1 );
+ tqparents.push_back( pid - 1 );
};
- newnode = new ApplyTypeNode( type, parents );
+ newnode = new ApplyTypeNode( type, tqparents );
}
else if ( tmp == "fetch-property" )
{
// FetchPropertyNode
TQCString propname = e.attribute( "property" ).latin1();
TQDomElement arge = e.firstChild().toElement();
- int parent = arge.text().toInt( &ok );
+ int tqparent = arge.text().toInt( &ok );
if ( !ok ) KIG_GENERIC_PARSE_ERROR;
- newnode = new FetchPropertyNode( parent - 1, propname );
+ newnode = new FetchPropertyNode( tqparent - 1, propname );
}
else
{
@@ -640,11 +640,11 @@ ObjectHierarchy ObjectHierarchy::transformFinalObject( const Transformation& t )
ObjectHierarchy ret( *this );
ret.mnodes.push_back( new PushStackNode( new TransformationImp( t ) ) );
- std::vector<int> parents;
- parents.push_back( ret.mnodes.size() - 1);
- parents.push_back( ret.mnodes.size() );
+ std::vector<int> tqparents;
+ tqparents.push_back( ret.mnodes.size() - 1);
+ tqparents.push_back( ret.mnodes.size() );
const ObjectType* type = ApplyTransformationObjectType::instance();
- ret.mnodes.push_back( new ApplyTypeNode( type, parents ) );
+ ret.mnodes.push_back( new ApplyTypeNode( type, tqparents ) );
return ret;
}
@@ -696,7 +696,7 @@ const ObjectImpType* lowermost( const ObjectImpType* a, const ObjectImpType* b )
// this function is part of the visit procedure really. It is
// factored out, because it recurses for cache ObjectImp's. What this
// does is, it makes sure that object o is calcable, by putting
-// appropriate Node's in mnodes.. po is o->parents() and pl contains
+// appropriate Node's in mnodes.. po is o->tqparents() and pl tqcontains
// the location of objects that are already in mnodes and -1
// otherwise.. -1 means we have to store their ObjectImp, unless
// they're cache ObjectImp's etc.
@@ -723,12 +723,12 @@ int ObjectHierarchy::storeObject( const ObjectCalcer* o, const std::vector<Objec
}
else if ( (uint) pl[i] < mnumberofargs )
{
- ObjectCalcer* parent = o->parents()[i];
- std::vector<ObjectCalcer*> opl = o->parents();
+ ObjectCalcer* tqparent = o->tqparents()[i];
+ std::vector<ObjectCalcer*> opl = o->tqparents();
margrequirements[pl[i]] =
lowermost( margrequirements[pl[i]],
- o->impRequirement( parent, opl ) );
+ o->impRequirement( tqparent, opl ) );
musetexts[pl[i]] = margrequirements[pl[i]]->selectStatement();
};
};
@@ -737,12 +737,12 @@ int ObjectHierarchy::storeObject( const ObjectCalcer* o, const std::vector<Objec
else if ( dynamic_cast<const ObjectPropertyCalcer*>( o ) )
{
assert( pl.size() == 1 );
- int parent = pl.front();
+ int tqparent = pl.front();
ObjectCalcer* op = po.front();
assert( op );
uint propid = static_cast<const ObjectPropertyCalcer*>( o )->propId();
assert( propid < op->imp()->propertiesInternalNames().size() );
- mnodes.push_back( new FetchPropertyNode( parent, op->imp()->propertiesInternalNames()[propid], propid ) );
+ mnodes.push_back( new FetchPropertyNode( tqparent, op->imp()->propertiesInternalNames()[propid], propid ) );
}
else
assert( false );