示例#1
0
void tst_QColumnView::grips()
{
    QColumnView view;
    QDirModel model;
    view.setModel(&model);
    QCOMPARE(view.resizeGripsVisible(), true);

    view.setResizeGripsVisible(true);
    QCOMPARE(view.resizeGripsVisible(), true);

    {
        const QObjectList list = view.viewport()->children();
        for (int i = 0 ; i < list.count(); ++i) {
            if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i)))
                QVERIFY(view->cornerWidget() != 0);
        }
    }
    view.setResizeGripsVisible(false);
    QCOMPARE(view.resizeGripsVisible(), false);

    {
        const QObjectList list = view.viewport()->children();
        for (int i = 0 ; i < list.count(); ++i) {
            if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i))) {
                if (view->isVisible())
                    QVERIFY(view->cornerWidget() == 0);
            }
        }
    }

    view.setResizeGripsVisible(true);
    QCOMPARE(view.resizeGripsVisible(), true);
}
示例#2
0
void QMainWindow::setUpLayout()
{
    d->timer->stop();
    delete d->tll;
    d->tll = new QBoxLayout( this, QBoxLayout::Down );
    if ( !d->mb ) {
	// slightly evil hack here.  reconsider this after 1.40.
	QObjectList * l
	    = ((QObject*)this)->queryList( "QMenuBar", 0, FALSE, FALSE );
	if ( l && l->count() )
	    d->mb = menuBar();
	delete l;
    }
    if ( d->mb && !d->mb->testWFlags( WState_DoHide ) )
	d->tll->setMenuBar( d->mb );
    if ( style() == WindowsStyle )
	d->tll->addSpacing( 1 );
    addToolBarToLayout( d->top, d->tll,
			QBoxLayout::LeftToRight, QBoxLayout::Down, FALSE,
			d->justify, style() );
    QBoxLayout * mwl = new QBoxLayout( QBoxLayout::LeftToRight );
    d->tll->addLayout( mwl, 1 );
    addToolBarToLayout( d->left, mwl,
			QBoxLayout::Down, QBoxLayout::LeftToRight, FALSE,
			d->justify, style() );
    if ( centralWidget() && !centralWidget()->testWFlags( WState_DoHide ) )
	mwl->addWidget( centralWidget(), 1 );
    else
	mwl->addStretch( 1 );
    addToolBarToLayout( d->right, mwl,
			QBoxLayout::Down, QBoxLayout::LeftToRight, FALSE,
			d->justify, style() );
    addToolBarToLayout( d->bottom, d->tll,
			QBoxLayout::LeftToRight, QBoxLayout::Up, TRUE,
			d->justify, style() );
    if ( !d->sb ) {
	// as above.
	QObjectList * l
	    = ((QObject*)this)->queryList( "QStatusBar", 0, FALSE, FALSE );
	if ( l && l->count() )
	    d->sb = statusBar();
	delete l;
    }
    if ( d->sb && !d->sb->testWFlags( WState_DoHide ) )
	d->tll->addWidget( d->sb, 0 );
    //debug( "act %d, %d", x(), y() );
    d->tll->activate();
}
示例#3
0
void
E6Irc::fixCaps (QObject * root)
{
  if (root) {
    objectCount++;
    QVariant suppressVar = root->property ("noInitialCaps");
    if (suppressVar.isValid()) {
      qDebug () << "found property on " << root ;
      qDebug () << suppressVar;
      if (suppressVar.type() == QVariant::Bool) {
        bool suppress = suppressVar.toBool();
        if (suppress) {
          QDeclarativeItem * item = qobject_cast<QDeclarativeItem*> (root);
          if (item) {
            item->setInputMethodHints (Qt::ImhNoAutoUppercase);
          }
        }
      }
    }
    QObjectList children = root->children();
    for (int i=0; i<children.count(); i++) {
      fixCaps (children.at(i));
    }
  }
}
示例#4
0
文件: Map.cpp 项目: jnicholl/AIMaze
void Map::parentHeightChanged(float parentHeight)
{
	const float padding = 10; // Padding of at least 10 on all sides.
	parentHeight = parentHeight - padding*2;
	const float cellWidth = m_mapWidth / m_cols;
	const float cellHeight = parentHeight / m_rows;
	float oldCellSize = m_cellSize;
	m_cellSize = std::min(cellWidth, cellHeight);
	m_mapArea->setPreferredSize(m_cellSize * m_cols, m_cellSize * m_rows);

	QObjectList list = m_mapArea->children();
	if (m_rows * m_cols + 1 != list.count()) { qDebug("Uhoh: List size not correct!"); }

	int i=0;
	for (int y=0; y<m_rows; y++) {
		for (int x=0; x<m_cols; x++) {
			ImageView *cell = qobject_cast<ImageView*>(list[i]);
			if (cell) {
				cell->setPreferredSize(m_cellSize, m_cellSize);
				AbsoluteLayoutProperties *properties = static_cast<AbsoluteLayoutProperties*>(cell->layoutProperties());
				properties->setPositionX(x * m_cellSize);
				properties->setPositionY(y * m_cellSize);
			}
			i++;
		}
	}

	Container *robot = qobject_cast<Container*>(list[i]);
	if (robot) {
		robot->setPreferredSize(m_cellSize, m_cellSize);
		AbsoluteLayoutProperties *properties = static_cast<AbsoluteLayoutProperties*>(robot->layoutProperties());
		properties->setPositionX(properties->positionX() * m_cellSize / oldCellSize);
		properties->setPositionY(properties->positionY() * m_cellSize / oldCellSize);
	}
}
void QGeoSatelliteInfoSourcePrivate::loadStaticPlugins(QHash<QString, QGeoPositionInfoSourceFactory *> &plugins)
{
#if !defined QT_NO_DEBUG
    const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
#endif

    QObjectList staticPlugins = QPluginLoader::staticInstances();
    for (int i = 0; i < staticPlugins.count(); ++i) {
        QGeoPositionInfoSourceFactory *f =
                qobject_cast<QGeoPositionInfoSourceFactory*>(staticPlugins.at(i));

        if (f) {
            QString name = f->sourceName();

#if !defined QT_NO_DEBUG
            if (showDebug)
                qDebug("Static: found a service provider plugin with name %s", qPrintable(name));
#endif
            if (!name.isEmpty()) {
                plugins.insertMulti(name, f);
            }
        }

    }
}
示例#6
0
void tst_QColumnView::moveGrip()
{
    QFETCH(bool, reverse);
    if (reverse)
        qApp->setLayoutDirection(Qt::RightToLeft);
    ColumnView view;
    TreeModel model;
    view.setModel(&model);
    QModelIndex home = model.thirdLevel();
    view.setCurrentIndex(home);
    view.resize(640, 200);
    view.show();
    QTest::qWait(ANIMATION_DELAY);

    int columnNum = view.createdColumns.count() - 2;
    QVERIFY(columnNum >= 0);
    QObjectList list = view.createdColumns[columnNum]->children();
    QColumnViewGrip *grip = 0;
    for (int i = 0; i < list.count(); ++i) {
        if ((grip = qobject_cast<QColumnViewGrip *>(list[i]))) {
            break;
        }
    }
    if (!grip)
        return;

    QAbstractItemView *column = qobject_cast<QAbstractItemView *>(grip->parent());
    int oldX = column->width();
    QCOMPARE(view.columnWidths()[columnNum], oldX);
    grip->moveGrip(10);
    QCOMPARE(view.columnWidths()[columnNum], (oldX + (reverse ? -10 : 10)));
}
void tst_Q3ActionGroup::dropDownDeleted()
{
    Q3MainWindow mw;
    Q3ToolBar *tb = new Q3ToolBar(&mw);
    Q3ActionGroup *actGroup = new Q3ActionGroup(&mw);
    actGroup->setUsesDropDown(TRUE);
    Q3Action *actOne = new Q3Action(actGroup);
    actOne->setText("test one");
    Q3Action *actTwo = new Q3Action(actGroup);
    actTwo->setText("test two");
    Q3Action *actThree= new Q3Action(actGroup);
    actThree->setText("test three");
    actGroup->addTo(tb);
    QObjectList comboList = tb->queryList("QComboBox");
    QCOMPARE(comboList.count(), 1);
    QCOMPARE((int)((QComboBox*)comboList[0])->count(), 3);

    delete actOne;
    QCOMPARE((int)((QComboBox*)comboList[0])->count(), 2);
    delete actTwo;
    QCOMPARE((int)((QComboBox*)comboList[0])->count(), 1);
    delete actThree;
    QCOMPARE((int)((QComboBox*)comboList[0])->count(), 0);

    delete actGroup;
}
示例#8
0
QObject *Item3dPrivate::resources_at(QDeclarativeListProperty<QObject> *prop, int index)
{
    QObjectList children = prop->object->children();
    if (index < children.count())
        return children.at(index);
    else
        return 0;
}
示例#9
0
Item3d *Item3dPrivate::children_at(QDeclarativeListProperty<Item3d> *prop, int index)
{
    QObjectList thechildren = static_cast<Item3d*>(prop->object)->children();

    if (index < thechildren.count())
        return qobject_cast<Item3d *>(thechildren.at(index));
    else
        return 0;
}
示例#10
0
void QMetaUtilities::connectSlotsByName(QObject * source, QObject * target)
{
    if (!source || !target) return;

    const QMetaObject * source_mo = source->metaObject();
    const QMetaObject * target_mo = target->metaObject();
    Q_ASSERT(source_mo);
    Q_ASSERT(target_mo);

    // find source's children
    // and add source itself to the list, so we can autoconnect its signals too
    const QObjectList list = source->findChildren<QObject *>(QString()) << source;


    for (int i = 0; i < target_mo->methodCount(); ++i) {
        const char *slot = target_mo->method(i).signature();
        Q_ASSERT(slot);
        if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_')
            continue;
        bool foundIt = false;
        for(int j = 0; j < list.count(); ++j) {
            const QObject *co = list.at(j);
            const QMetaObject *smo = co->metaObject();
            QByteArray objName = co->objectName().toAscii();
            int len = objName.length();
            if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
                continue;
            int sigIndex = smo->indexOfSignal(slot + len + 4);
            if (sigIndex < 0) { // search for compatible signals
                int slotlen = qstrlen(slot + len + 4) - 1;
                for (int k = 0; k < co->metaObject()->methodCount(); ++k) {
                    QMetaMethod method = smo->method(k);
                    if (method.methodType() != QMetaMethod::Signal)
                        continue;

                    if (!qstrncmp(method.signature(), slot + len + 4, slotlen)) {
                        sigIndex = k;
                        break;
                    }
                }
            }
            if (sigIndex < 0)
                continue;
            if (QMetaObject::connect(co, sigIndex, target, i)) {
                foundIt = true;
                break;
            }
        }
        if (foundIt) {
            // we found our slot, now skip all overloads
            while (target_mo->method(i + 1).attributes() & QMetaMethod::Cloned)
                  ++i;
        } else if (!(target_mo->method(i).attributes() & QMetaMethod::Cloned)) {
            qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
        }
    }
}
示例#11
0
EventLoop::~EventLoop() {
    QMainWindow * wnd = StaticUtils::findMainWindow();
    if (wnd != NULL) {
        wnd->removeEventFilter(this);
        QObjectList childs = wnd->children();
        for (int i=0;i<childs.count();i++) {
            if (childs.at(i)->inherits("QWidget")) childs.at(i)->removeEventFilter(this);
        }
    }
}
示例#12
0
void mafObjectBase::connectObjectSlotsByName(QObject *signal_object) {
    const QMetaObject *mo = this->metaObject();
    Q_ASSERT(mo);
    const QObjectList list = qFindChildren<QObject *>(signal_object, QString());
    for (int i = 0; i < mo->methodCount(); ++i) {
        QMetaMethod method_slot = mo->method(i);
        if (method_slot.methodType() != QMetaMethod::Slot)
            continue;
        const char *slot = mo->method(i).signature();
        if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_')
            continue;
        bool foundIt = false;
        for(int j = 0; j < list.count(); ++j) {
            const QObject *co = list.at(j);
            QByteArray objName = co->objectName().toAscii();
            int len = objName.length();
            if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
                continue;
            int sigIndex = -1; //co->metaObject()->signalIndex(slot + len + 4);
            const QMetaObject *smo = co->metaObject();
            if (sigIndex < 0) { // search for compatible signals
                int slotlen = qstrlen(slot + len + 4) - 1;
                for (int k = 0; k < co->metaObject()->methodCount(); ++k) {
                    QMetaMethod method = smo->method(k);
                    if (method.methodType() != QMetaMethod::Signal)
                        continue;

                    if (!qstrncmp(method.signature(), slot + len + 4, slotlen)) {
                        const char *signal = method.signature();
                        QString event_sig = SIGNAL_SIGNATURE;
                        event_sig.append(signal);

                        QString observer_sig = CALLBACK_SIGNATURE;
                        observer_sig.append(slot);

                        if(connect(co, event_sig.toAscii(), this, observer_sig.toAscii())) {
                            qDebug() << mafTr("CONNECTED slot %1 with signal %2").arg(slot, signal);
                            foundIt = true;
                            break;
                        } else {
                            qWarning() << mafTr("Cannot connect slot %1 with signal %2").arg(slot, signal);
                        }
                    }
                }
            }
        }
        if (foundIt) {
            // we found our slot, now skip all overloads
            while (mo->method(i + 1).attributes() & QMetaMethod::Cloned)
                  ++i;
        } else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) {
            qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
        }
    }
}
示例#13
0
void QQmlQtQuick2DebugStatesDelegate::buildStatesList(QObject *obj)
{
    if (QQuickState *state = qobject_cast<QQuickState *>(obj)) {
        m_allStates.append(state);
    }

    QObjectList children = obj->children();
    for (int ii = 0; ii < children.count(); ++ii) {
        buildStatesList(children.at(ii));
    }
}
示例#14
0
void QDeclarativeWebViewPrivate::updateWindowObjects()
{
    if (!q->isComponentCompletePublic() || !q->page())
        return;

    for (int i = 0; i < windowObjects.count(); ++i) {
        QObject* object = windowObjects.at(i);
        QDeclarativeWebViewAttached* attached = static_cast<QDeclarativeWebViewAttached *>(qmlAttachedPropertiesObject<QDeclarativeWebView>(object));
        if (attached && !attached->windowObjectName().isEmpty())
            q->page()->mainFrame()->addToJavaScriptWindowObject(attached->windowObjectName(), object);
    }
}
示例#15
0
void AutoHideWidget::installFiliter(QObject *o){
    QObjectList children = o->children();
    for(int n=0;n < children.count();n++){
        if(children[n]->isWidgetType()){
            qDebug()<<"AutoHideWidget::installFilter:child name:"<<children[n]->objectName();
            QWidget *w = static_cast<QWidget*>(children[n]);
            w->setMouseTracking(true);
            w->installEventFilter(this);
            installFiliter(children[n]);
        }
    }
}
示例#16
0
/*! \reimp */
QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >
QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRelations*/) const
{
    QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels;
    if (match & QAccessible::Label) {
        const QAccessible::Relation rel = QAccessible::Label;
        if (QWidget *parent = widget()->parentWidget()) {
#ifndef QT_NO_SHORTCUT
            // first check for all siblings that are labels to us
            // ideally we would go through all objects and check, but that
            // will be too expensive
            const QList<QWidget*> kids = childWidgets(parent);
            for (int i = 0; i < kids.count(); ++i) {
                if (QLabel *labelSibling = qobject_cast<QLabel*>(kids.at(i))) {
                    if (labelSibling->buddy() == widget()) {
                        QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(labelSibling);
                        rels.append(qMakePair(iface, rel));
                    }
                }
            }
#endif
#ifndef QT_NO_GROUPBOX
            QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent);
            if (groupbox && !groupbox->title().isEmpty()) {
                QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupbox);
                rels.append(qMakePair(iface, rel));
            }
#endif
        }
    }

    if (match & QAccessible::Controlled) {
        QObjectList allReceivers;
        QACConnectionObject *connectionObject = (QACConnectionObject*)object();
        for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
            const QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toLatin1());
            allReceivers += receivers;
        }

        allReceivers.removeAll(object());  //### The object might connect to itself internally

        for (int i = 0; i < allReceivers.count(); ++i) {
            const QAccessible::Relation rel = QAccessible::Controlled;
            QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(allReceivers.at(i));
            if (iface)
                rels.append(qMakePair(iface, rel));
        }
    }

    return rels;
}
示例#17
0
void PopupMenuEditor::dropInPlace( QActionGroup * g, int y )
{
    if (!g->children())
	return;
    QObjectList l = *g->children();
    for ( int i = 0; i < (int)l.count(); ++i ) {
	QAction *a = ::qt_cast<QAction*>(l.at(i));
	QActionGroup *g = ::qt_cast<QActionGroup*>(l.at(i));
	if ( g )
	    dropInPlace( g, y );
	else if ( a )
	    dropInPlace( new PopupMenuEditorItem( a, this ), y );
    }
}
示例#18
0
void DkTransferToolBar::enableToolBar(bool enable) {

    QObjectList list = this->children();

    for (int i = 0; i < list.count(); i++) {
        if (QWidget *action = qobject_cast<QWidget*>(list.at(i)))
            action->setEnabled(enable);
    }

    if (enable)
        effect->setOpacity(1);
    else
        effect->setOpacity(.5);

}
示例#19
0
QStatusBar * QMainWindow::statusBar() const
{
    if ( d->sb )
	return d->sb;

    QObjectList * l
	= ((QObject*)this)->queryList( "QStatusBar", 0, FALSE, FALSE );
    QStatusBar * s;
    if ( l && l->count() )
	s = (QStatusBar *)l->first();
    else
	s = new QStatusBar( (QMainWindow *)this, "automatic status bar" );
    delete l;
    ((QMainWindow *)this)->setStatusBar( s );
    return s;
}
示例#20
0
QMenuBar * QMainWindow::menuBar() const
{
    if ( d->mb )
	return d->mb;

    QObjectList * l
	= ((QObject*)this)->queryList( "QMenuBar", 0, FALSE, FALSE );
    QMenuBar * b;
    if ( l && l->count() )
	b = (QMenuBar *)l->first();
    else
	b = new QMenuBar( (QMainWindow *)this, "automatic menu bar" );
    delete l;
    ((QMainWindowPrivate*)d)->mb = b;
    d->mb->installEventFilter( this );
    ((QMainWindow *)this)->triggerLayout();
    return b;
}
示例#21
0
void BasketStatusBar::setupStatusBar()
{
    QWidget* parent = statusBar();
    QObjectList lst = parent->findChildren<QObject*>("KRSqueezedTextLabel");

    //Tools::printChildren(parent);
    if (lst.count() == 0) {
        m_basketStatus = new QLabel(parent);
        QSizePolicy policy(QSizePolicy::Ignored, QSizePolicy::Ignored);
        policy.setHorizontalStretch(0);
        policy.setVerticalStretch(0);
        policy.setHeightForWidth(false);
        m_basketStatus->setSizePolicy(policy);
        addWidget(m_basketStatus, 1, false);  // Fit all extra space and is hiddable
    } else
        m_basketStatus = static_cast<QLabel*>(lst.at(0));
    lst.clear();

    m_selectionStatus = new QLabel(i18n("Loading..."), parent);
    addWidget(m_selectionStatus, 0, true);

    m_lockStatus = new QLabel(0/*this*/);
    m_lockStatus->setMinimumSize(18, 18);
    m_lockStatus->setAlignment(Qt::AlignCenter);
//  addWidget( m_lockStatus, 0, true );
    m_lockStatus->installEventFilter(this);

    m_savedStatusPixmap = SmallIcon("document-save");
    m_savedStatus = new QLabel(parent);
    m_savedStatus->setPixmap(m_savedStatusPixmap);
    m_savedStatus->setFixedSize(m_savedStatus->sizeHint());
    m_savedStatus->clear();
    //m_savedStatus->setPixmap(m_savedStatusIconSet.pixmap(QIconSet::Small, QIconSet::Disabled));
    //m_savedStatus->setEnabled(false);
    addWidget(m_savedStatus, 0, true);
    m_savedStatus->setToolTip("<p>" + i18n("Shows if there are changes that have not yet been saved."));


}
示例#22
0
void QtCalculator::updateGeometry()
{
    QObjectList *l;
    QSize s;
    int margin;

    //
    // Uppermost bar
    //
    calc_display->setMinimumWidth(calc_display->fontMetrics().maxWidth() * 15);

    //
    // Button groups (base and angle)
    //
    //QButtonGroup *g;
    //g = (QButtonGroup*)(anglebutton[0]->parentWidget());
    //g = (QButtonGroup*)(basebutton[0]->parentWidget());

    //
    // Calculator buttons
    //
    s.setWidth(mSmallPage->fontMetrics().width("MMM"));
    s.setHeight(mSmallPage->fontMetrics().lineSpacing());

    l = (QObjectList*)mSmallPage->children(); // silence please

    for(uint i=0; i < l->count(); i++)
    {
        QObject *o = l->at(i);
        if( o->isWidgetType() )
        {
            margin = QApplication::style().
                pixelMetric(QStyle::PM_ButtonMargin, ((QWidget *)o))*2;
            ((QWidget*)o)->setMinimumSize(s.width()+margin, s.height()+margin);
            ((QWidget*)o)->installEventFilter( this );
            ((QWidget*)o)->setAcceptDrops(true);
        }
    }

    l = (QObjectList*)mLargePage->children(); // silence please

    int h1 = pbF->minimumSize().height();
    int h2 = (int)((((float)h1 + 4.0) / 5.0));
    s.setWidth(mLargePage->fontMetrics().width("MMM") +
               QApplication::style().
               pixelMetric(QStyle::PM_ButtonMargin, pbF)*2);
    s.setHeight(h1 + h2);

    for(uint i = 0; i < l->count(); i++)
    {
        QObject *o = l->at(i);
        if(o->isWidgetType())
        {
            ((QWidget*)o)->setFixedSize(s);
            ((QWidget*)o)->installEventFilter(this);
            ((QWidget*)o)->setAcceptDrops(true);
        }
    }

    //
    // The status bar
    //
    s.setWidth( statusINVLabel->fontMetrics().width("NORM") +
                statusINVLabel->frameWidth() * 2 + 10);
    statusINVLabel->setMinimumWidth(s.width());
    statusHYPLabel->setMinimumWidth(s.width());

    //setFixedSize(minimumSize());
}
/*!
  Sets internal pointers to frequently used QML items, thus reducing the overhead
  of repeated searching for them at runtime.
  */
void CcfQmlBaseScenario::init()
{
    if (mScenarioFile != "") {
        QStringList unitSideList;
        QObject *unitsLoader = child("unitsLoader");
        QObject *unitItem = unitsLoader->property("unitsItem").value<QObject *>();
        QObject *map = child("map");

        if (unitItem->objectName() != "Campaign") {
            // This is a single scenario
            map->set("source", unitItem->getString("mapFile"));
            QObjectList tempList = unitItem->children();

            for (int i = 0; i < tempList.count(); ++i) {
                CcfQmlBaseUnit *unit = ccfUnit(tempList.at(i));
                if ((unit != 0) && (unit->property("unitIndex").isValid())) {
                    unit->setUnitIndex(i);
                    connect(this, &CcfQmlBaseScenario::togglePause,
                            unit, &CcfQmlBaseUnit::togglePause);
                    connect(unit, &CcfQmlBaseUnit::actionFinished,
                            this, &CcfQmlBaseScenario::actionFinished);
                    connect(unit, &CcfQmlBaseUnit::movementStateChange,
                            this, &CcfQmlBaseScenario::handleUnitMovement);
                    unitSideList.append(unit->getUnitSide());
                    mUnits.append(unit);
                }
            }

            mMapItem = map->property("mapItem").value<CcfQmlBaseMap *>();

            if(mMapItem != 0)
                mMapItem->setUnits(mUnits);
            else
                mlogger->error("MapItem object was not properly initialised",
                               "Robin Hood is a jerk");
        } else {
            // This is a campaign
            // TODO: add some clever code here ;)
        }

        mScenarioState->setAvailableSides(unitSideList);

        mAimLine = item("aimLine");
        mGameArea = item("gameArea");
        mZoomArea = item("zoomArea");
        mContextMenu = item("contextMenu");
        mEffectsTimer = child("effectsTimer");
        mRotationTimer = child("rotationTimer");
        mFollowingTimer = child("followingTimer");
        mMouseAreaMain = child("mouseAreaMain");

        mRoster = findChild<CcfQmlBaseRosterMenu *>("roster");
        mRoster->populateUnits(mUnits);

        connect(mContextMenu, SIGNAL(menuEntryClicked(QString)), this, SLOT(scheduleContextAction(QString)));
        connect(mRotationTimer, SIGNAL(triggered()), this, SLOT(updateAimLine()));
        connect(mEffectsTimer, SIGNAL(triggered()), this, SLOT(updateEffects()));
        connect(mFollowingTimer, SIGNAL(triggered()), this, SLOT(updateFollowingUnit()));
        connect(child("sceneUpdateTimer"), SIGNAL(triggered()), this, SLOT(updateUnitVisibility()));
        connect(child("rubberBandTimer"), SIGNAL(triggered()), this, SLOT(updateRubberBand()));

        hideNonPlayerUnits();
        setSideMarks();
    }
}
QTreeWidgetItem* GCF::Components::ScriptableObjectExplorerData::loadObjectInfo(QTreeWidget* treeWidget, QTreeWidgetItem* item, QObject* object, QString name, bool showChildren)
{
    if(!object)
        return 0;

    if(!treeWidget && !item)
        return 0;

    static QColor eventColor = Qt::black;
    static QColor propertyColor = Qt::black;
    static QColor methodColor = Qt::black;

    if(name.isEmpty())
        name = object->objectName();
    if(name.isEmpty())
        return 0;

    // add the object item
    QTreeWidgetItem* objectItem = 0;
    if(item)
        objectItem = new QTreeWidgetItem(item, OBJECT_ITEM);
    else
        objectItem = new QTreeWidgetItem(treeWidget, OBJECT_ITEM);
    objectItem->setText(0, name);
    objectItem->setData(0, Qt::UserRole, qVariantFromValue<QObject*>(object));
    objectItem->setText(1, name);
    objectItem->setIcon(0, objectPm);
    objectItems.append(objectItem);

    QTreeWidgetItem* eventItem = new QTreeWidgetItem(objectItem, QStringList() << "Events");
    QTreeWidgetItem* methodItem = new QTreeWidgetItem(objectItem, QStringList() << "Methods");
    QTreeWidgetItem* propertyItem = new QTreeWidgetItem(objectItem, QStringList() << "Properties");
    QTreeWidgetItem* childrenItem = new QTreeWidgetItem(objectItem, QStringList() << "Children");

    eventItem->setIcon(0, eventPmDir);
    methodItem->setIcon(0, methodPmDir);
    propertyItem->setIcon(0, propertyPmDir);
    childrenItem->setIcon(0, propertyPmDir);

    // add items.
    const QMetaObject* mo = object->metaObject();
    for(int j=QObject::staticMetaObject.methodCount(); j<mo->methodCount(); j++)
    {
        QMetaMethod m = mo->method(j);
        QTreeWidgetItem* item =  0;

        switch(m.methodType())
        {
        case QMetaMethod::Signal: {
            item = new QTreeWidgetItem(eventItem, EVENT_ITEM);
            item->setIcon(0, eventPm);
            QString event = formattedName(m.signature());
            item->setText(0, event);
            item->setData(0, Qt::ForegroundRole, eventColor);
            } break;
        case QMetaMethod::Method:
        case QMetaMethod::Slot:
        default: {
            if(m.access() != QMetaMethod::Public)
                break;
            item = new QTreeWidgetItem(methodItem, METHOD_ITEM);
            item->setIcon(0, methodPm);
            QString methodName = QString(m.signature()).section('(', 0, 0);
            item->setText(0, methodName);
            item->setData(0, Qt::ForegroundRole, methodColor);
            } break;
        }

        if(item)
            item->setData(0, Qt::UserRole, qVariantFromValue<QMetaMethod>(m));
    }

    for(int j=QObject::staticMetaObject.propertyCount(); j<mo->propertyCount(); j++)
    {
        QMetaProperty prop = mo->property(j);
        QTreeWidgetItem* item = new QTreeWidgetItem(propertyItem, PROPERTY_ITEM);
        item->setIcon(0, propertyPm);
        item->setData(0, Qt::UserRole, qVariantFromValue<QMetaProperty>(prop));
        item->setData(0, Qt::ForegroundRole, propertyColor);
        item->setText(0, prop.name());
    }

    if(showChildren)
    {
        QObjectList children = object->children();
        for(int i=0; i<children.count(); i++)
        {
            QObject* childObject = children[i];
            QString childName = QString("%1.%2").arg(name).arg(childObject->objectName());
            loadObjectInfo(treeWidget, childrenItem, childObject, childName, showChildren);
        }
    }

    objectItem->setExpanded(false);

    if(eventItem->childCount())
        eventItem->setExpanded(false);
    else
        delete eventItem;

    if(methodItem->childCount())
        methodItem->setExpanded(false);
    else
        delete methodItem;

    if(propertyItem->childCount())
        propertyItem->setExpanded(false);
    else
        delete propertyItem;

    if(childrenItem->childCount())
        childrenItem->setExpanded(false);
    else
        delete childrenItem;

    return objectItem;
}