// HQDeleter.cpp - implementation of the
HOOPS/Qt class HQDeleter
// More
about this class
// HOOPS/Qt includes
#include "HQDeleter.h"
// HOOPS/MVO includes
#include "HTools.h"
HQDeleter::HQDeleter(
QObject * parent, const char * name )
: QObject( parent, name )
{
objects = new QIntDict<QObject>(31);
}
HQDeleter::~HQDeleter()
{
delete objects;
}
void HQDeleter::processDeletes()
{
QIntDictIterator<QObject> it( *objects );
QObject * o;
while( (o=(QObject *)it.current()) != 0 ) {
++it;
delete o;
}
}
void
HQDeleter::detectOtherDelete()
{
objects->take((long) sender() );
}
bool
HQDeleter::event( QEvent * e )
{
if ( e && e->type() == 12345 ) {
processDeletes();
return true;
}else{
return false;
}
}
void
HQDeleter::deleteLater( QObject * o )
{
if ( objects->count() == 0 ) {
QEvent * e = new QEvent( 12345 );
QApplication::postEvent( this, e );
}
if ( !objects->find( (long)o ) ) {
objects->insert( (long)o, (const QObject*) o);
connect( o, SIGNAL(destroyed()), this, SLOT(detectOtherDelete())
);
}
}
|