void QuickInterpreter::setTopLevelObjects( QObjectList *l )
{
    QSEngine::init();
    if( toplevel )
	for( QObject *o = toplevel->first(); o; o = toplevel->next() )
	    disconnect( o, SIGNAL( destroyed( QObject* ) ),
			this, SLOT( topLevelDestroyed( QObject* ) ) );
    delete toplevel;
    toplevel = new QObjectList;

    kids.clear();
    if ( !l ) {
	toplevel->clear();
	return;
    }
    QSObject global( env()->globalObject() );
    QObject *o = l->first();
    while ( o ) {
	if ( hasTopLevelParent( o ) ) {
	    o = l->next();
	    continue;
	}
	kids.append( QString::fromLatin1(o->name()) );
	connect( o, SIGNAL( destroyed( QObject * ) ),
		 this, SLOT( topLevelDestroyed( QObject * ) ) );
	global.put( QString::fromLatin1(o->name()), wrap( o ) );
	staticGlobals << QString::fromLatin1(o->name());
	toplevel->append( o );
	o = l->next();
    }
    delete l;
}
Exemple #2
0
QPoint QDesignerToolBar::calcIndicatorPos( const QPoint &pos )
{
    if ( orientation() == Horizontal ) {
	QPoint pnt( width() - 2, 0 );
	insertAnchor = 0;
	afterAnchor = TRUE;
	if ( !children() )
	    return pnt;
	pnt = QPoint( 13, 0 );
	QObjectListIt it( *children() );
	QObject * obj;
	while( (obj=it.current()) != 0 ) {
	    ++it;
	    if ( obj->isWidgetType() &&
		 qstrcmp( "qt_dockwidget_internal", obj->name() ) != 0 ) {
		QWidget *w = (QWidget*)obj;
		if ( w->x() < pos.x() ) {
		    pnt.setX( w->x() + w->width() + 1 );
		    insertAnchor = w;
		    afterAnchor = TRUE;
		}
	    }
	}
	return pnt;
    } else {
	QPoint pnt( 0, height() - 2 );
	insertAnchor = 0;
	afterAnchor = TRUE;
	if ( !children() )
	    return pnt;
	pnt = QPoint( 0, 13 );
	QObjectListIt it( *children() );
	QObject * obj;
	while( (obj=it.current()) != 0 ) {
	    ++it;
	    if ( obj->isWidgetType() &&
		 qstrcmp( "qt_dockwidget_internal", obj->name() ) != 0 ) {
		QWidget *w = (QWidget*)obj;
		if ( w->y() < pos.y() ) {
		    pnt.setY( w->y() + w->height() + 1 );
		    insertAnchor = w;
		    afterAnchor = TRUE;
		}
	    }
	}
	return pnt;
    }
}
Exemple #3
0
static inline void objectChildrenXml(AQSObject *o, QDomNode *doc,
                                     bool includeComplexTypes)
{
    const QObjectList *children = static_cast<QObject *>(o->o())->children();
    if (!children)
        return;
    QObjectListIt it(*children);
    QObject *obj;
    AQSObject *ito;
    QDomNode *itd;

    while ((obj = it.current())) {
        ++it;

        ito = ::qt_cast<AQSObject *>(AQSWrapperFactory::staticCreate(obj->className(), obj));
        if (!ito)
            continue;

        ito->setObjectName(obj->name());
        itd = ito->toXml(includeComplexTypes);
        objectChildrenXml(ito, itd, includeComplexTypes);
        doc->firstChild().appendChild(itd->firstChild());
        delete ito;
    }
}
Exemple #4
0
void Tools::printChildren(QObject* parent)
{
	const QObjectList objs = parent->children();
    QObject * obj;
    for(int i = 0 ; i < objs.size() ; i++) {
        obj = objs.at(i);
        kDebug() << k_funcinfo << obj->className() << ": " << obj->name() << endl;
    }

}
QString Project::qualifiedName( QObject *o )
{
    QString name = o->name();
    QObject *p = o->parent();
    while ( p ) {
	name.prepend( QString( p->name() ) + "." );
	if ( objs.findRef( p ) != -1 )
	    break;
	p = p->parent();
    }
    return name;
}
void QuickInterpreter::addTopLevelObject( QObject *o )
{
    QSEngine::init();
    if ( !toplevel )
	toplevel = new QObjectList;
    if ( toplevel->findRef( o ) != -1 )
	return;
    if ( hasTopLevelParent( o ) )
	return;

    for( QObject *cur = toplevel->first(); cur; cur = toplevel->next() ) {
	if( cur == o ) {
	    return;
	} else if ( cur && o && QString::fromLatin1( cur->name() ) == QString::fromLatin1( o->name() ) ) {
	    return;
	}
    }


    toplevel->append( o );

    kids.clear();
    if ( !toplevel )
	return;
    QObject *obj = toplevel->first();
    while ( obj ) {
	kids.append( QString::fromLatin1(obj->name()) );
	obj = toplevel->next();
    }
    connect( o, SIGNAL( destroyed( QObject * ) ), this, SLOT( topLevelDestroyed( QObject * ) ) );

    QSObject global = env()->globalObject();
    const_cast<QSClass *>(global.objectType())->deleteMember(o->name());
    env()->globalObject().put( QString::fromLatin1(o->name()), wrap( o ) );
    staticGlobals << QString::fromLatin1(o->name());
}
Exemple #7
0
QStringList KoDocumentInfo::pages() const
{
    QStringList ret;

    const QObjectList *list = children();
    if ( list )
    {
        QObjectListIt it( *list );
        QObject *obj;
        while ( ( obj = it.current() ) )
        {
            ret.prepend( obj->name() );
            ++it;
        }
    }

    return ret;
}