Exemplo n.º 1
0
void    Properties::propertyChanged( )
{
    if ( getTarget() == nullptr )
        return;
    // Note 20151029: Here is the magic, get the sender signal name an extract the 'property name'
    int senderSignalId = senderSignalIndex( );
    if ( ( sender( ) == this || sender() == getTarget() ) &&
         senderSignalId != -1 ) {
        QMetaMethod senderSignal{};
        if ( sender() == this )
            senderSignal = metaObject( )->method( senderSignalId );
        if ( getTarget() != nullptr && sender() == getTarget() )
            senderSignal = getTarget()->metaObject( )->method( senderSignalId );

        if ( senderSignal.isValid( ) ) {
            QString senderSignalName( senderSignal.name( ) );
            // FIXME 20151029 Document that behaviour: QuickProperties only works with xxxChanged() NOTIFY signals (this is the standard Qt "coding style").
            QStringList propertyNames = senderSignalName.split( QRegExp( "Changed" ) );
            if ( propertyNames.size( ) > 0 ) {
                QString propertyName = propertyNames.at( 0 );
                int propertyIndex = getPropertyIndex( propertyName );
                QModelIndex propertyModelIndex = index( propertyIndex );
                if ( propertyModelIndex.isValid( ) ) {
                    emit dataChanged( propertyModelIndex, propertyModelIndex );
                    emit propertiesModified( propertyName );
                }
            }
        }
    }
}
Exemplo n.º 2
0
void QDBusAdaptorConnector::relaySlot(void **argv)
{
    QObject *sndr = sender();
    if (Q_LIKELY(sndr)) {
        relay(sndr, senderSignalIndex(), argv);
    } else {
        qWarning("QtDBus: cannot relay signals from parent %s(%p \"%s\") unless they are emitted in the object's thread %s(%p \"%s\"). "
                 "Current thread is %s(%p \"%s\").",
                 parent()->metaObject()->className(), parent(), qPrintable(parent()->objectName()),
                 parent()->thread()->metaObject()->className(), parent()->thread(), qPrintable(parent()->thread()->objectName()),
                 QThread::currentThread()->metaObject()->className(), QThread::currentThread(), qPrintable(QThread::currentThread()->objectName()));
    }
}