コード例 #1
0
/*!
    Sets \a iface to point to the implementation of the
    QAccessibleInterface for \a object, and returns \c QS_OK if
    successfull, or sets \a iface to 0 and returns \c QE_NOCOMPONENT if
    no accessibility implementation for \a object exists.

    The function uses the \link QObject::className() classname
    \endlink of \a object to find a suitable implementation. If no
    implementation for the object's class is available the function
    tries to find an implementation for the object's parent class.

    This function is called to answer an accessibility client's
    request for object information. You should never need to call this
    function yourself.
*/
QRESULT QAccessible::queryAccessibleInterface( QObject *object, QAccessibleInterface **iface )
{
    *iface = 0;
    if ( !object )
	return QE_INVALIDARG;

    if ( qAccessibleInterface ) {
	*iface = qAccessibleInterface->find( object );
	if ( *iface ) {
	    (*iface)->addRef();
	    return QS_OK;
	}
    }

    if ( !qAccessibleManager ) {
	qAccessibleManager = new QPluginManager<QAccessibleFactoryInterface>( IID_QAccessibleFactory, QApplication::libraryPaths(), "/accessible" );
	if ( !cleanupAdded ) {
	    qAddPostRoutine( qAccessibleCleanup );
	    cleanupAdded = TRUE;
	}
    }

    QInterfacePtr<QAccessibleFactoryInterface> factory = 0;
    QMetaObject *mo = object->metaObject();
    while ( mo ) {
	qAccessibleManager->queryInterface( mo->className(), &factory );
	if ( factory )
	    break;
	mo = mo->superClass();
    }
    if ( factory )
	return factory->createAccessibleInterface( mo->className(), object, iface );

    return QE_NOCOMPONENT;
}
コード例 #2
0
void ImportQMetaObject::import(const QMetaObject& t)
{
    Analitza::BuiltinMethods* b=m_a->builtinMethods();
    QByteArray classname(t.className());
    classname.replace("::", "_");
    
    for(int p=0; p<t.propertyCount(); p++) {
        QMetaProperty prop=t.property(p);
        QByteArray name(prop.name());
        
        if(prop.isReadable()) {
            QObjectGet* getter=new QObjectGet(name);
            b->insertFunction(QString(classname+'_'+name), getter->type(classname, prop), getter);
        }
        
        if(prop.isWritable()) {
            QObjectSet* setter=new QObjectSet(name);
            b->insertFunction(QString(classname+"_set_"+name), setter->type(classname, prop), setter);
        }
    }
    
    if(t.superClass()) {
        QObjectCastToParent *cast = new QObjectCastToParent(t.className(), t.superClass()->className());
        b->insertFunction(classname+QStringLiteral("_toParent"), cast->type(), cast);
    }
}
コード例 #3
0
ファイル: qtmetautilities.cpp プロジェクト: lemmel/vessaq
void QtMetaUtilities::setValue(const QMetaObject &metaObject, QObject *object, const QString &propertyName, const QVariant &value)
{
    QString className = QLatin1String(metaObject.className());
    if (className == "QObject")
        return ;
    int idx = metaObject.indexOfProperty(propertyName.toUtf8().data());
    if (idx != -1)
        metaObject.property(idx).write(object, value);
}
コード例 #4
0
ファイル: qtmetautilities.cpp プロジェクト: lemmel/vessaq
QStringList QtMetaUtilities::getNames(const QMetaObject &metaObject)
{
    QStringList retour;
    QString className = QLatin1String(metaObject.className());
    if (className == "QObject")
        return retour;
    for (int idx = metaObject.propertyOffset(); idx < metaObject.propertyCount(); idx++)
        retour <<metaObject.property(idx).name();
    return retour;
}
コード例 #5
0
ファイル: qtmetautilities.cpp プロジェクト: lemmel/vessaq
QList<QVariant> QtMetaUtilities::getValues(const QMetaObject &metaObject, const QObject *object)
{
    QList<QVariant> retour;

    QString className = QLatin1String(metaObject.className());
    if (className == "QObject")
        return retour;
    for (int idx = metaObject.propertyOffset(); idx < metaObject.propertyCount(); idx++)
        retour << metaObject.property(idx).read(object);
    return retour;
}
コード例 #6
0
ファイル: qtmetautilities.cpp プロジェクト: lemmel/vessaq
QList<QPair<QString, QVariant::Type> >QtMetaUtilities::getNamesNTypes(const QMetaObject &metaObject)
{
    QList<QPair<QString, QVariant::Type> >retour;
    QString className = QLatin1String(metaObject.className());
    if (className == "QObject")
        return retour;
    for (int idx = metaObject.propertyOffset(); idx < metaObject.propertyCount(); idx++) {
        QMetaProperty prop = metaObject.property(idx);
        retour.append(QPair<QString, QVariant::Type>(prop.name(), prop.type()));
    }
    return retour;
}
コード例 #7
0
ファイル: qtmetautilities.cpp プロジェクト: lemmel/vessaq
QVariant QtMetaUtilities::getValue(const QMetaObject &metaObject, const QObject *object, const QString &propertyName)
{
    QVariant retour;
    QString className = QLatin1String(metaObject.className());
    if (className == "QObject")
        return retour;
    int idx = metaObject.indexOfProperty(propertyName.toUtf8().data());
    if (idx != -1)
        return metaObject.property(idx).read(object);

    return retour;
}
コード例 #8
0
bool QuickInterpreter::queryDispatchObjects( QObject *obj,
					     QPtrVector<QObject> &result )
{
    Q_ASSERT( obj );
    QMetaObject *meta = obj->metaObject();
    result.resize( 1 );
    result.insert( 0, obj );
    while ( meta ) {
	factory->constructInterface( meta->className(), (void*)obj, result );
	meta = meta->superClass();
    }
    return TRUE;
}
コード例 #9
0
ファイル: qtmetautilities.cpp プロジェクト: lemmel/vessaq
QString QtMetaUtilities::toString(const QMetaObject &metaObject, const QObject *object)
{
    QString retour;

    QString className = QLatin1String(metaObject.className());
    if (className == "QObject")
        return retour;
    for (int idx = metaObject.propertyOffset(); idx < metaObject.propertyCount(); idx++)
    {
        retour += QString("[ %1 = %2 ]")
                .arg(metaObject.property(idx).name())
                .arg(metaObject.property(idx).read(object).toString());
    }

    return retour;
}
コード例 #10
0
ファイル: utils.cpp プロジェクト: Noughmad/Toutatis
QJsonArray Utils::serializeType(const QMetaObject& meta, qlonglong timestamp)
{
    QString className = meta.className();
    QStringList properties;
    properties << "_id" << "modified" << "deleted";
    properties << propertyNames(meta);
    
    QSqlQuery query;
    query.prepare(QString("SELECT %1 FROM %2 WHERE modified>:timestamp OR deleted>:timestamp").arg(properties.join(",")).arg(className));
    query.bindValue(":timestamp", timestamp);
    query.exec();
    
    QJsonArray array;
    while (query.next())
    {
        array.append(serializeObject(properties, query));
    }
    
    return array;
}
コード例 #11
0
ファイル: metaobject.cpp プロジェクト: Kampfgnom/QPersistence
/******************************************************************************
 * QpMetaObject
 */
QpMetaObject QpMetaObject::registerMetaObject(const QMetaObject &metaObject)
{
    QString className(metaObject.className());
    auto it = MetaObjectsForName()->find(className);

    if (it != MetaObjectsForName()->end()) {
        return it.value();
    }

    QpMetaObject result = QpMetaObject(metaObject);
    MetaObjects()->append(result);

    const QMetaObject *objectInClassHierarchy = &metaObject;
    do {
        QpMetaObject qpmo = QpMetaObject(*objectInClassHierarchy);
        MetaObjectsForName()->insert(qpmo.classNameWithoutNamespace(), result);
        MetaObjectsForName()->insert(qpmo.className(), result);

        objectInClassHierarchy = objectInClassHierarchy->superClass();
    } while (objectInClassHierarchy->className() != QObject::staticMetaObject.className());

    return result;
}
コード例 #12
0
/*!\internal
 */
void QMetaObject::resolveProperty( QMetaProperty* prop )
{
    QMetaObject* super = superclass;
    while ( super ) {
	const QMetaProperty* p = super->property( prop->n );
	if( p ) {
	    if ( qstrcmp( prop->type(), p->type() ) != 0 ) {
#if defined(CHECK_STATE)
		qWarning( "QMetaObject::resolveProperty: Attempt to override property type: %s %s::%s clashes with %s %s::%s", p->type(), super->className(), p->name(), prop->type(), className(), prop->name() );
#endif
	    }
	    if ( prop->get == 0 ) {
		if ( p->get != 0 ) {
		    prop->get = p->get;
		    prop->gspec = p->gspec;
		}
	    }
	    if ( prop->set == 0 ) {
		if ( p->set != 0 ) {
		    prop->set = p->set;
		    prop->sspec = p->sspec;
		}
	    }

	    if ( prop->testFlags( QMetaProperty::UnresolvedStored ) )
	    {
		if ( !p->testFlags( QMetaProperty::UnresolvedStored ) )
		{
		    prop->clearFlags( QMetaProperty::UnresolvedStored );
		    if ( p->testFlags( QMetaProperty::NotStored ) )
			prop->setFlags( QMetaProperty::NotStored );
		    prop->store = p->store;
		}
	    }
	    if ( prop->testFlags( QMetaProperty::UnresolvedDesignable ) )
	    {
		if ( !p->testFlags( QMetaProperty::UnresolvedDesignable ) )
		{
		    prop->clearFlags( QMetaProperty::UnresolvedDesignable );
		    if ( p->testFlags( QMetaProperty::NotDesignable ) )
			prop->setFlags( QMetaProperty::NotDesignable );
		}
	    }
	}
	if ( prop->testFlags( QMetaProperty::UnresolvedEnum | QMetaProperty::UnresolvedSet | QMetaProperty::UnresolvedEnumOrSet ) ) {
	    QMetaEnum* e = super->enumerator( prop->t);
	    if ( e && e->set ) {
		if ( !prop->testFlags( QMetaProperty::UnresolvedSet | QMetaProperty::UnresolvedEnumOrSet ) ) {
#if defined(CHECK_STATE)
		    qWarning("QMetaObject::resolveProperty: The property %s %s::%s assumed that '%s' was listed in Q_ENUMS, but it was listed in Q_SETS", prop->type(), className(), prop->name(), prop->type() );
#endif
		}
		prop->enumData = e;
		prop->clearFlags( QMetaProperty::UnresolvedEnum );
	    }
	    else if ( e && !e->set ) {
		if ( !prop->testFlags( QMetaProperty::UnresolvedEnum | QMetaProperty::UnresolvedEnumOrSet ) ) {
#if defined(CHECK_STATE)
		    qWarning("QMetaObject::resolveProperty: The property %s %s::%s assumed that '%s' was listed in Q_SETS, but it was listed in Q_ENUMS", prop->type(), className(), prop->name(), prop->type() );
#endif
		}
		prop->enumData = e;
		prop->clearFlags( QMetaProperty::UnresolvedEnum );
	    }
	}
	super = super->superclass;
    }

    if ( !prop->isValid() ) {
#if defined(CHECK_STATE)
	qWarning("QMetaObject::resolveProperty: Could not resolve property %s::%s. Property not available.", className(), prop->name() );
#endif
    }
}
コード例 #13
0
ファイル: metaobject.cpp プロジェクト: Kampfgnom/QPersistence
QpMetaObject QpMetaObject::forMetaObject(const QMetaObject &metaObject)
{
    return QpMetaObject::forClassName(metaObject.className());
}
コード例 #14
0
QString AsemanQtTools::exportItem(const QString &module, int major, int minor, const QString &component, bool store)
{
    QString result;
    aseman_qt_tools_indexCache << component;

    QMetaObject meta = T::staticMetaObject;
    QString inherits = fixType(meta.superClass()? meta.superClass()->className() : "");
    bool isModel = component.toLower().contains("model");

    result += QString("# %1\n\n").arg(component);

    QString headers;
    headers += QString(" * [Component details](#component-details)\n");

    QString details = QString("\n### Component details:\n\n");
    details += QString("|Detail|Value|\n"
                       "|------|-----|\n");
    details += QString("|%1|%2 %3.%4|\n").arg("Import").arg(module).arg(major).arg(minor);
    details += QString("|%1|<font color='#074885'>%2</font>|\n").arg("Component").arg(component);
    details += QString("|%1|<font color='#074885'>%2</font>|\n").arg("C++ class").arg(meta.className());
    details += QString("|%1|<font color='#074885'>%2</font>|\n").arg("Inherits").arg(inherits);
    details += QString("|%1|<font color='#074885'>%2</font>|\n").arg("Model").arg(isModel?"Yes":"No");

    QString resultProperties;
    QStringList propertiesSignals;
    for(int i=0; i<meta.propertyCount(); i++)
    {
        QMetaProperty property = meta.property(i);
        const QString &propertyName = property.name();
        const QString &propertyType = fixType(property.typeName());
        propertiesSignals << property.notifySignal().name();

        QString text = QString("* <font color='#074885'><b>%1</b></font>: %2").arg(propertyName).arg(propertyType);
        if(!property.isWritable())
            text += " (readOnly)";

        text += "\n";
        if(meta.propertyOffset()<=i)
            resultProperties += text;
    }

    QString enumResults;
    for(int i=meta.enumeratorOffset(); i<meta.enumeratorCount(); i++)
    {
        QMetaEnum enumerator = meta.enumerator(i);
        const QString &enumName = enumerator.name();

        enumResults += QString("\n##### %1\n\n").arg(enumName);
        enumResults += QString("|Key|Value|\n"
                               "|---|-----|\n");

        for(int j=0; j<enumerator.keyCount(); j++)
            enumResults += QString("|%1|%2|\n").arg(enumerator.key(j)).arg(enumerator.value(j));
    }

    QString resultSlots;
    QString resultSignals;
    for(int i=meta.methodOffset(); i<meta.methodCount(); i++)
    {
        QMetaMethod method = meta.method(i);
        if(method.access() != QMetaMethod::Public)
            continue;

        const QString &methodName = method.name();
        if(propertiesSignals.contains(methodName))
            continue;

        const QString &methodType = fixType(method.typeName());

        QString args;
        const QList<QByteArray> &paramNames = method.parameterNames();
        const QList<QByteArray> &paramTypes = method.parameterTypes();
        for(int j=0; j<paramNames.count(); j++)
        {
            if(j != 0)
                args += ", ";

            args += fixType(paramTypes[j]) + " " + paramNames[j];
        }

        QString text = QString(" * %1 <font color='#074885'><b>%2</b></font>(%3)\n").arg(methodType).arg(methodName).arg(args);
        switch(static_cast<int>(method.methodType()))
        {
        case QMetaMethod::Slot:
            resultSlots += text;
            break;
        case QMetaMethod::Signal:
            resultSignals += text;
            break;
        }
    }

    if(!resultProperties.isEmpty())
    {
        headers += QString(" * [Normal Properties](#normal-properties)\n");
        resultProperties = QString("\n### Normal Properties\n\n") + resultProperties;
    }
    if(!enumResults.isEmpty())
    {
        headers += QString(" * [Enumerator](#enumerator)\n");
        enumResults = QString("\n### Enumerator\n\n") + enumResults;
    }
    if(!resultSlots.isEmpty())
    {
        headers += QString(" * [Methods](#methods)\n");
        resultSlots = QString("\n### Methods\n\n") + resultSlots;
    }
    if(!resultSignals.isEmpty())
    {
        headers += QString(" * [Signals](#signals)\n");
        resultSignals = QString("\n### Signals\n\n") + resultSignals;
    }
    if(isModel)
        headers += QString(" * [Roles](#roles)\n");

    result += headers + "\n";
    result += details + "\n";
    result += resultProperties + "\n";
    result += resultSlots + "\n";
    result += resultSignals + "\n";
    result += enumResults + "\n";

    if(!store)
        return result;

    QString path = aseman_qt_tools_destination + "/" + component.toLower() + ".md";
    QFile file(path);
    if(!file.open(QFile::WriteOnly))
        return result;

    file.write(result.toUtf8());
    file.close();
    return result;
}
コード例 #15
0
ファイル: embeddedpyqt.cpp プロジェクト: Fealum/WebScriptRS
void EmbeddedPyQt::registerMetaObject(const QMetaObject &mo) {
    classes[mo.className()] = &mo;
}
コード例 #16
0
bool operator < (const QMetaObject & o1, const QMetaObject & o2)
{
    return o1.className() < o2.className();
}