static bool hasMetaMethodStartingWith(QObject *object, const QString &checkedSignature)
{
    const QMetaObject *mo = object->metaObject();
    bool found = false;
    for (int methodIndex = 0; methodIndex < mo->methodCount(); ++methodIndex) {
        QMetaMethod mm = mo->method(methodIndex);
        QString signature = QString::fromLatin1(mm.methodSignature());

        if (signature.startsWith(checkedSignature)) {
            found = true;
            break;
        }
    }
    return found;
}
Example #2
0
void MethodViewer::_invokeMethodEvery() {
	QAction *sender = static_cast<QAction*>(this->sender());
	Item *item = sender->property("treeItem").value<MethodViewer::Item*>();
	QMetaMethod method = item->getMethod();

	bool bOk;
	int interval = QInputDialog::getInt(this, tr("Invoke method %1 every...").arg(method.signature()),
										tr("Interval in seconds"), 5, 1, 30, 1, &bOk);

	if (!bOk) return;

	m_invokedMethod = method;
	m_invokedObject = item->getObject();
	m_invokeTimer.start(interval*1000);
}
Example #3
0
void Timed::invoke_signal(const nanotime_t &back)
{
  log_debug("systime_back=%s, back=%s", systime_back.str().c_str(), back.str().c_str()) ;
  systime_back += back ;
  log_debug("new value: systime_back=%s", systime_back.str().c_str()) ;
  if(signal_invoked)
    return ;
  signal_invoked = true ;
  int methodIndex = this->metaObject()->indexOfMethod("send_time_settings()") ;
  QMetaMethod method = this->metaObject()->method(methodIndex);
  method.invoke(this, Qt::QueuedConnection);
  log_assert(q_pause==NULL) ;
  q_pause = new machine_t::pause_t(am) ;
  log_debug("new q_pause=%p", q_pause) ;
}
Example #4
0
static int publicMethodIndex(NPObject *npobj, NPIdentifier name)
{
    NPClass_Prolog;
    QByteArray qname = NPN_UTF8FromIdentifier(name);
    const QMetaObject *metaObject = qobject->metaObject();
    for (int slotIndex = metaOffset(metaObject, MetaMethod); slotIndex < metaObject->methodCount(); ++slotIndex) {
        const QMetaMethod slot = qobject->metaObject()->method(slotIndex);
        if (slot.access() != QMetaMethod::Public || slot.methodType() == QMetaMethod::Signal)
            continue;
        QByteArray signature = slot.signature();
        if (signature.left(signature.indexOf('(')) == qname)
            return slotIndex;
    }
    return -1;
}
QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObject *metaObject, 
                                                                  const QString &property)
{
    Q_ASSERT(metaObject);

    QDeclarativePropertyCache::Data rv;
    {
        const QMetaObject *cmo = metaObject;
        while (cmo) {
            int idx = metaObject->indexOfProperty(property.toUtf8());
            if (idx != -1) {
                QMetaProperty p = metaObject->property(idx);
                if (p.isScriptable()) {
                    rv.load(metaObject->property(idx));
                    if (!isDynamicMetaObject(cmo))
                        rv.flags |= Data::IsDirect;
                    return rv;
                } else {
                    while (cmo && cmo->propertyOffset() >= idx)
                        cmo = cmo->superClass();
                }
            } else {
                cmo = 0;
            }
        }
    }

    int methodCount = metaObject->methodCount();
    for (int ii = methodCount - 1; ii >= 3; --ii) { // >=3 to block the destroyed signal and deleteLater() slot
        QMetaMethod m = metaObject->method(ii);
        if (m.access() == QMetaMethod::Private)
            continue;
        QString methodName = QString::fromUtf8(m.signature());

        int parenIdx = methodName.indexOf(QLatin1Char('('));
        Q_ASSERT(parenIdx != -1);
        QStringRef methodNameRef = methodName.leftRef(parenIdx);

        if (methodNameRef == property) {
            rv.load(m);
            if (!isDynamicMetaObject(m.enclosingMetaObject()))
                rv.flags |= Data::IsDirect;
            return rv;
        }
    }

    return rv;
}
void listInterface(const QString &service, const QString &path, const QString &interface)
{
    QDBusInterfacePtr iface(*connection, service, path, interface);
    if (!iface->isValid()) {
        QDBusError err(iface->lastError());
        fprintf(stderr, "Interface '%s' not available in object %s at %s:\n%s (%s)\n",
                qPrintable(interface), qPrintable(path), qPrintable(service),
                qPrintable(err.name()), qPrintable(err.message()));
        exit(1);
    }
    const QMetaObject *mo = iface->metaObject();

    // properties
    for (int i = mo->propertyOffset(); i < mo->propertyCount(); ++i) {
        QMetaProperty mp = mo->property(i);
        printf("property ");

        if (mp.isReadable() && mp.isWritable())
            printf("readwrite");
        else if (mp.isReadable())
            printf("read");
        else
            printf("write");

        printf(" %s %s.%s\n", mp.typeName(), qPrintable(interface), mp.name());
    }

    // methods (signals and slots)
    for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
        QMetaMethod mm = mo->method(i);

        QByteArray signature = mm.signature();
        signature.truncate(signature.indexOf('('));
        printf("%s %s%s%s %s.%s(",
               mm.methodType() == QMetaMethod::Signal ? "signal" : "method",
               mm.tag(), *mm.tag() ? " " : "",
               *mm.typeName() ? mm.typeName() : "void",
               qPrintable(interface), signature.constData());

        QList<QByteArray> types = mm.parameterTypes();
        QList<QByteArray> names = mm.parameterNames();
        bool first = true;
        for (int i = 0; i < types.count(); ++i) {
            printf("%s%s",
                   first ? "" : ", ",
                   types.at(i).constData());
            if (!names.at(i).isEmpty())
                printf(" %s", names.at(i).constData());
            first = false;
        }
        printf(")\n");
    }
}
Example #7
0
	int DynamicQObject::findSignalId(const char *signal)
	{
#if 0
		const QMetaObject *meta = obj->metaObject();

		// Finding signal id
		for (int i = meta->methodOffset(); i < meta->methodCount(); ++i) {
			QMetaMethod method = meta->method(i);
			const char *methodName = method.name().data();

			if (strcmp(signal, methodName) == 0)
				return i;
		}
#endif
		return -1;
	}
static int publicMethodIndex(NPObject *npobj, const QByteArray &slotName, int argCount = -1)
{
    NPClass_Prolog;
    const QMetaObject *metaObject = qobject->metaObject();
    for (int slotIndex = metaOffset(metaObject, MetaMethod); slotIndex < metaObject->methodCount(); ++slotIndex) {
        const QMetaMethod slot = qobject->metaObject()->method(slotIndex);
        if (slot.access() != QMetaMethod::Public || slot.methodType() == QMetaMethod::Signal)
            continue;
        QByteArray signature = slot.signature();
        if (signature.left(signature.indexOf('(')) == slotName) {
            if (argCount == -1 || slot.parameterTypes().count() == argCount)
                return slotIndex;
        }
    }
    return -1;
}
Example #9
0
bool QObject::isSignalConnected(const QMetaMethod &signalMetaMethod) const
{
   bool retval = false;
   const BentoAbstract *signalMethod_Bento = signalMetaMethod.getBentoBox();

   std::unique_lock<std::mutex> senderLock{this->m_mutex_ToReceiver};

   for(auto index = this->m_connectList_ToReceiver.begin(); index != this->m_connectList_ToReceiver.end(); ++index) {
      const ConnectStruct &temp = *index;

      if (*(temp.signalMethod) != *(signalMethod_Bento))  {
         continue;
      }

      if (temp.sender == 0) {
         // connection is marked for deletion
         continue;
      }

      retval = true;
      break;
   }

   return retval;
}
static inline QByteArray getMethodName(const QMetaMethod& method) {
	QByteArray name(method.signature());
	int bracket = name.indexOf("(");
	if (bracket >= 0)
		name.remove(bracket, name.size() - bracket);
	return name;
}
Example #11
0
bool PacketReceiver::registerListener(PacketType type, QObject* listener, const char* slot,
                                             bool deliverPending) {
    Q_ASSERT_X(listener, "PacketReceiver::registerListener", "No object to register");
    Q_ASSERT_X(slot, "PacketReceiver::registerListener", "No slot to register");

    QMetaMethod matchingMethod = matchingMethodForListener(type, listener, slot);

    if (matchingMethod.isValid()) {
        qCDebug(networking) << "Registering a packet listener for packet list type" << type;
        registerVerifiedListener(type, listener, matchingMethod, deliverPending);
        return true;
    } else {
        qCWarning(networking) << "FAILED to Register a packet listener for packet list type" << type;
        return false;
    }
}
Example #12
0
static bool NPClass_Invoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32 argCount, NPVariant *result)
{
    NPClass_Prolog;
    int slotIndex = publicMethodIndex(npobj, name);
    if (slotIndex == -1) {
        QByteArray qname = NPN_UTF8FromIdentifier(name);
        NPN_SetException(npobj, QByteArray("No such method " + qname).constData());
        return false;
    }

    const QMetaMethod slot = qobject->metaObject()->method(slotIndex);
    QList<QByteArray> parameterTypes = slot.parameterTypes();
    if (parameterTypes.count() != static_cast<int>(argCount)) {
        QByteArray qname = NPN_UTF8FromIdentifier(name);
        NPN_SetException(npobj, QByteArray("Wrong parameter count for method " + qname).constData());
        return false;
    }

    QVariant returnVariant(QVariant::nameToType(slot.typeName()), (void *)0);
    QVector<QVariant> variants(parameterTypes.count()); // keep data alive
    QVector<const void *> metacallArgs(parameterTypes.count() + 1); // arguments for qt_metacall
    metacallArgs[0] = returnVariant.data(); // args[0] == return value

    for (int p = 0; p < parameterTypes.count(); ++p) {
        QVariant::Type type = QVariant::nameToType(parameterTypes.at(p));
        if (type == QVariant::Invalid) {
            QByteArray qname = NPN_UTF8FromIdentifier(name);
            NPN_SetException(npobj, QByteArray("Unsupported parameter in method " + qname).constData());
            return false;
        }
        QVariant qvar = args[p];
        if (!qvar.convert(type)) {
            QByteArray qname = NPN_UTF8FromIdentifier(name);
            NPN_SetException(npobj, QByteArray("Unsupported parameter value in method " + qname).constData());
            return false;
        }

        variants[p] = qvar;
        metacallArgs[p + 1] = variants.at(p).constData(); // must not detach!
    }

    qobject->qt_metacall(QMetaObject::InvokeMetaMethod, slotIndex, const_cast<void * *>(metacallArgs.data()));
    if (returnVariant.isValid() && result)
        *result = NPVariant::fromQVariant(This, returnVariant);

    return true;
}
Example #13
0
/* We catch all qt_metacall invocations */
extern "C" SEXP qt_qmetacall(SEXP x, SEXP s_call, SEXP s_id, SEXP s_args)
{
  SmokeObject *so = SmokeObject::fromSexp(x);
  QMetaObject::Call call =
    enum_from_sexp<QMetaObject::Call>(s_call, SmokeType());
  int id = from_sexp<int>(s_id);
  void **args = reinterpret_cast<void **>(from_sexp<void *>(s_args));
  
  // Assume the target slot is a C++ one
  Smoke::StackItem i[4];
  i[1].s_enum = call;
  i[2].s_int = id;
  i[3].s_voidp = args;
  so->invokeMethod("qt_metacall$$?", i);
  int ret = i[0].s_int;
  if (ret < 0) {
    return ScalarInteger(ret);
  }

  if (call != QMetaObject::InvokeMetaMethod)
    return ScalarInteger(id);

  QObject * qobj = reinterpret_cast<QObject *>(so->castPtr("QObject"));
  // get obj metaobject with a virtual call
  const QMetaObject *metaobject = qobj->metaObject();
  
  // get method count
  int count = metaobject->methodCount();
  
  QMetaMethod method = metaobject->method(id);
  if (method.methodType() == QMetaMethod::Signal) {
    // FIXME: this override of 'activate' is obsolete
    metaobject->activate(qobj, id, (void**) args);
    return ScalarInteger(id - count);
  }
  DynamicBinding binding(MocMethod(so->smoke(), metaobject, id));
  QVector<SmokeType> stackTypes = binding.types();
  MocStack mocStack = MocStack(args, stackTypes.size());
  SmokeStack smokeStack = mocStack.toSmoke(stackTypes);
  binding.invoke(so, smokeStack.items());
  mocStack.returnFromSmoke(smokeStack, stackTypes[0]);
  if (binding.lastError() == Method::NoError)
    warning("Slot invocation failed for %s::%s", so->klass()->name(),
            binding.name());
  
  return ScalarInteger(id - count);
}
/*!
    Places a call to the remote method specified by \a method on this interface, using \a args as
    arguments. This function returns the message that was received as a reply, which can be a normal
    QDBusMessage::ReplyMessage (indicating success) or QDBusMessage::ErrorMessage (if the call
    failed). The \a mode parameter specifies how this call should be placed.

    If the call succeeds, lastError() will be cleared; otherwise, it will contain the error this
    call produced.

    Normally, you should place calls using call().

    \warning If you use \c UseEventLoop, your code must be prepared to deal with any reentrancy:
             other method calls and signals may be delivered before this function returns, as well
             as other Qt queued signals and events.

    \threadsafe
*/
QDBusMessage QDBusAbstractInterface::callWithArgumentList(QDBus::CallMode mode,
                                                          const QString& method,
                                                          const QList<QVariant>& args)
{
    Q_D(QDBusAbstractInterface);

    QString m = method;
    // split out the signature from the method
    int pos = method.indexOf(QLatin1Char('.'));
    if (pos != -1)
        m.truncate(pos);

    if (mode == QDBus::AutoDetect) {
        // determine if this a sync or async call
        mode = QDBus::Block;
        const QMetaObject *mo = metaObject();
        QByteArray match = m.toLatin1() + '(';

        for (int i = staticMetaObject.methodCount(); i < mo->methodCount(); ++i) {
            QMetaMethod mm = mo->method(i);
            if (QByteArray(mm.signature()).startsWith(match)) {
                // found a method with the same name as what we're looking for
                // hopefully, nobody is overloading asynchronous and synchronous methods with
                // the same name

                QList<QByteArray> tags = QByteArray(mm.tag()).split(' ');
                if (tags.contains("Q_NOREPLY"))
                    mode = QDBus::NoBlock;

                break;
            }
        }
    }

//    qDebug() << "QDBusAbstractInterface" << "Service" << service() << "Path:" << path();
    QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), interface(), m);
    msg.setArguments(args);

    QDBusMessage reply = d->connection.call(msg, mode);
    d->lastError = reply;       // will clear if reply isn't an error

    // ensure that there is at least one element
    if (reply.arguments().isEmpty())
        reply << QVariant();

    return reply;
}
Example #15
0
static int lqtL_connect(lua_State *L) {
    static int methodId = 0;

    QObject* sender = static_cast<QObject*>(lqtL_toudata(L, 1, "QObject*"));
    if (sender == NULL)
        return luaL_argerror(L, 1, "sender not QObject*");

    const char *signal = luaL_checkstring(L, 2);
    const QMetaObject *senderMeta = sender->metaObject();
    int idxS = senderMeta->indexOfSignal(signal + 1);
    if (idxS == -1)
        return luaL_argerror(L, 2, qPrintable(QString("no such sender signal: '%1'").arg(signal + 1)));

    QObject* receiver;
    QString methodName;

    if (lua_type(L, 3) == LUA_TFUNCTION) {
        receiver = sender;

        // simulate sender:__addmethod('LQT_SLOT_X(signature)', function()...end)
        QMetaMethod m = senderMeta->method(idxS);
        methodName = QString(m.signature()).replace(QRegExp("^[^\\(]+"), QString("LQT_SLOT_%1").arg(methodId++));

        lua_getfield(L, 1, "__addmethod");
        lua_pushvalue(L, 1);
        lua_pushstring(L, qPrintable(methodName));
        lua_pushvalue(L, 3);
        lua_call(L, 3, 0);
        
        methodName.prepend("1");
    } else {
        receiver = static_cast<QObject*>(lqtL_toudata(L, 3, "QObject*"));
        if (receiver == NULL)
            return luaL_argerror(L, 3, "receiver not QObject*");
        const char *method = luaL_checkstring(L, 4);
        methodName = method;

        const QMetaObject *receiverMeta = receiver->metaObject();
        int idxR = receiverMeta->indexOfMethod(method + 1);
        if (idxR == -1)
            return luaL_argerror(L, 4, qPrintable(QString("no such receiver method: '%1'").arg(method + 1)));
    }

    bool ok = QObject::connect(sender, signal, receiver, qPrintable(methodName));
    lua_pushboolean(L, ok);
    return 1;
}
Example #16
0
QString QbPersistable::getObjectString() {
    QString prefix = QbProperties::getInstance()->getProperty("qubic.configuration.getters.prefix");
    QString objectString;
    for(int i = 0; i < this->metaObject()->methodCount(); i++)
    {
        QMetaMethod method = this->metaObject()->method(i);
        if(method.name().startsWith(prefix.toStdString().c_str()))
        {
            QString memberName = method.name().right(method.name().length() - prefix.length());
            memberName = memberName.toUpper();
            QString memberValue = QbMappingHelper::getStringValue(*this, method);
            objectString.append(memberName + " = " + memberValue + "; ");
        }
    }
    objectString = objectString.left(objectString.length() - 2);
    return objectString;
}
Example #17
0
JSValue QtInstance::stringValue(ExecState* exec) const
{
    QObject* obj = getObject();
    if (!obj)
        return jsNull();

    // Hmm.. see if there is a toString defined
    QByteArray buf;
    bool useDefault = true;
    getClass();
    if (m_class) {
        // Cheat and don't use the full name resolution
        int index = obj->metaObject()->indexOfMethod("toString()");
        if (index >= 0) {
            QMetaMethod m = obj->metaObject()->method(index);
            // Check to see how much we can call it
            if (m.access() != QMetaMethod::Private
                && m.methodType() != QMetaMethod::Signal
                && m.parameterTypes().isEmpty()) {
                const char* retsig = m.typeName();
                if (retsig && *retsig) {
                    QVariant ret(QMetaType::type(retsig), (void*)0);
                    void * qargs[1];
                    qargs[0] = ret.data();

                    if (QMetaObject::metacall(obj, QMetaObject::InvokeMetaMethod, index, qargs) < 0) {
                        if (ret.isValid() && ret.canConvert(QVariant::String)) {
                            buf = ret.toString().toLatin1().constData(); // ### Latin 1? Ascii?
                            useDefault = false;
                        }
                    }
                }
            }
        }
    }

    if (useDefault) {
        const QMetaObject* meta = obj ? obj->metaObject() : &QObject::staticMetaObject;
        QString name = obj ? obj->objectName() : QString::fromUtf8("unnamed");
        QString str = QString::fromUtf8("%0(name = \"%1\")")
                      .arg(QLatin1String(meta->className())).arg(name);

        buf = str.toLatin1();
    }
    return jsString(exec, buf.constData());
}
PythonQtMethodInfo::PythonQtMethodInfo(const QMetaMethod& meta, PythonQtClassInfo* classInfo)
{
#ifdef PYTHONQT_DEBUG
  QByteArray sig(meta.signature());
  sig = sig.mid(sig.indexOf('('));
  QByteArray fullSig = QByteArray(meta.typeName()) + " " + sig;
  std::cout << "caching " << fullSig.data() << std::endl;
#endif

  ParameterInfo type;
  fillParameterInfo(type, QByteArray(meta.typeName()), classInfo);
  _parameters.append(type);
  QList<QByteArray> names = meta.parameterTypes();
  foreach (const QByteArray& name, names) {
    fillParameterInfo(type, name, classInfo);
    _parameters.append(type);
  }
Example #19
0
inline int indexOfMethod( const QMetaObject * metaObject,
                          const QByteArray methodName, int methodType = -1 )
{
    while (metaObject->superClass() != 0)
    {
        for (int idx = metaObject->methodOffset(); idx < metaObject->methodCount(); ++idx)
        {
            QMetaMethod method = metaObject->method(idx);
            if (methodType != -1 && method.methodType() != methodType)
                continue;
            if (method.name() == methodName)
                return idx;
        }
        metaObject = metaObject->superClass();
    }
    return -1;
}
QByteArray MaiaXmlRpcServerConnection::getReturnType( const QMetaObject *obj,
                                                      const QByteArray &method,
                                                      const QList<QByteArray> &argTypes )
{
    for( int n = 0; n < obj->methodCount(); ++n ) {
        QMetaMethod m = obj->method(n);
#if QT_VERSION >= 0x050000
        if( m.name() == method && m.parameterTypes() == argTypes ) {
            return m.typeName();
        }
#else
        QByteArray sig = m.signature();

        int offset = sig.indexOf('(');
        if( offset == -1 ) {
            continue;
        }

        QByteArray name = sig.mid(0, offset);
        if( name == method && m.parameterTypes() == argTypes ) {
            return m.typeName();
        }
#endif
    }
    return QByteArray();

} // QByteArray getReturnType( const QMetaObject *obj, const QByteArray &method, const QList<QByteArray> &argTypes )
Example #21
0
bool JsonRpcServer::convertArgs(const QMetaMethod& meta_method,
                                const QVariantList& args,
                                QVariantList& converted_args)
{
    QList<QByteArray> param_types = meta_method.parameterTypes();
    if (args.size() != param_types.size()) {
        logError(QString("wrong number of arguments to method %1 -- "
                         "expected %2 arguments, but got %3")
                 .arg(QString(meta_method.methodSignature()))
                 .arg(meta_method.parameterCount())
                 .arg(args.size()));
        return false;
    }

    for (int i = 0; i < param_types.size(); i++) {
        const QVariant& arg = args.at(i);
        if (!arg.isValid()) {
            logError(QString("argument %1 of %2 to method %3 is invalid")
                     .arg(i + 1)
                     .arg(param_types.size())
                     .arg(QString(meta_method.methodSignature())));
            return false;
        }

        QByteArray arg_type_name = arg.typeName();
        QByteArray param_type_name = param_types.at(i);

        QVariant::Type param_type = QVariant::nameToType(param_type_name);

        QVariant copy = QVariant(arg);

        if (copy.type() != param_type) {
            if (copy.canConvert(param_type)) {
                if (!copy.convert(param_type)) {
                    // qDebug() << "cannot convert" << arg_type_name
                    //          << "to" << param_type_name;
                    return false;
                }
            }
        }

        converted_args << copy;
    }
    return true;
}
QString ExtendedBase::fromMethodToCallbackFlag(const QMetaMethod &method)
{
    QString buf;

    buf += method.name();
    buf += "(";
    for(auto index = 0; index < method.parameterCount(); index++)
    {
        if(index)
        {
            buf += ",";
        }
        buf += method.parameterTypes()[index];
    }
    buf += ")";

    return buf;
}
Example #23
0
QString QDeclarativePropertyCache::Data::name(const QMetaObject *metaObject)
{
    if (!metaObject || coreIndex == -1)
        return QString();

    if (flags & IsFunction) {
        QMetaMethod m = metaObject->method(coreIndex);

        QString name = QString::fromUtf8(m.signature());
        int parenIdx = name.indexOf(QLatin1Char('('));
        if (parenIdx != -1)
            name = name.left(parenIdx);
        return name;
    } else {
        QMetaProperty p = metaObject->property(coreIndex);
        return QString::fromUtf8(p.name());
    }
}
Example #24
0
void QDeclarativePropertyCache::Data::load(const QMetaMethod &m)
{
    coreIndex = m.methodIndex();
    relatedIndex = -1;
    flags |= Data::IsFunction;
    if (m.methodType() == QMetaMethod::Signal)
        flags |= Data::IsSignal;
    propType = QVariant::Invalid;

    const char *returnType = m.typeName();
    if (returnType) 
        propType = QMetaType::type(returnType);

    QList<QByteArray> params = m.parameterTypes();
    if (!params.isEmpty())
        flags |= Data::HasArguments;
    revision = m.revision();
}
void Nuria::ObjectWrapperResourcePrivate::addMethodToPropertyList (QMetaMethod method, Method &descriptor) {
	Nuria::Resource::Property::Type type = (method.methodType () == QMetaMethod::Signal)
	                                       ? Nuria::Resource::Property::Signal
	                                       : Nuria::Resource::Property::Slot;
	QString name = QString::fromLatin1 (method.name ());
	int resultType = method.returnType ();
	Nuria::Resource::ArgumentTypeMap args;
	
	// Convert descriptor to argument type map
	for (int i = 0; i < descriptor.names.length (); i++) {
		args.insert (descriptor.names.at (i), descriptor.types.at (i));
	}
	
	// Add to list
	descriptor.propertyIndex = this->propertyList.length ();
	this->propertyList.append (Nuria::Resource::Property (type, name, args, resultType));
	
}
Example #26
0
QStringList Component::getEffectList()
{
    QMetaObject metaObject = *this->metaObject();
    QMetaMethod method;
    QStringList effectList;

    for (int i = 0; i<metaObject.methodCount(); i++)
    {
        method = metaObject.method(i);
        QString signature = metaObject.normalizedSignature(method.signature());
        if (method.methodType() == QMetaMethod::Slot && signature.startsWith("effect"))
        {
            effectList << signature;
        }
    }

    return effectList;
}
Example #27
0
    /**
     * \brief Extract the arguments types of a meta method
     *
     * \param metaMethod Qt meta method
     *
     * \return Arguments types of the meta method
     */
    static std::vector<ponder::Type> argTypes(const QMetaMethod& metaMethod)
    {
        std::vector<ponder::Type> types;

        QList<QByteArray> args = metaMethod.parameterTypes();
        Q_FOREACH(QByteArray arg, args)
        {
            types.push_back(QtHelper::type(arg));
        }
static QByteArray QMetaMethod_name(const QMetaMethod &m)
{
    QByteArray sig = m.signature();
    int paren = sig.indexOf('(');
    if (paren == -1)
        return sig;
    else
        return sig.left(paren);
}
QByteArray MaiaXmlRpcServerConnection::getReturnType(const QMetaObject *obj,
			const QByteArray &method, const QList<QByteArray> argTypes) {
	for(int n = 0; n < obj->methodCount(); ++n) {
		QMetaMethod m = obj->method(n);
		QByteArray sig = m.signature();
		int offset = sig.indexOf('(');
		if(offset == -1)
			continue;
		QByteArray name = sig.mid(0, offset);
		if(name != method)
			continue;
		if(m.parameterTypes() != argTypes)
			continue;

		return m.typeName();
	}
	return QByteArray();
}
Example #30
-1
void DataWidgetMapper::addMapping(QWidget *widget, int section, const QByteArray &propertyName) {
    QMetaProperty property;
    for (int i=0; i<widget->metaObject()->propertyCount(); ++i) {
        if (QString(widget->metaObject()->property(i).name()) == propertyName) {
            property = widget->metaObject()->property(i);
            break;
        }
    }
    Q_ASSERT(property.isValid());
    QMetaMethod notifySignal = property.notifySignal();
    Q_ASSERT(notifySignal.isValid());
    connect(widget, notifySignal, this, QMetaMethod::fromSignal(&DataWidgetMapper::dataChanged));

    QDataWidgetMapper::addMapping(widget, section, propertyName);
}