QWidget * ExtArgNumber::createEditor(QWidget * parent)
{
    textBox = (QLineEdit *)ExtArgText::createEditor(parent);
    textBox->disconnect(SIGNAL(textChanged(QString)));

    if ( _argument->arg_type == EXTCAP_ARG_INTEGER || _argument->arg_type == EXTCAP_ARG_UNSIGNED )
    {
        QIntValidator * textValidator = new QIntValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_int(_argument->range_start));

        if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED && textValidator->bottom() < 0 )
            textValidator->setBottom(0);

        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_int(_argument->range_end));
        textBox->setValidator(textValidator);
    }
    else if ( _argument->arg_type == EXTCAP_ARG_DOUBLE )
    {
        QDoubleValidator * textValidator = new QDoubleValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_double(_argument->range_start));
        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_double(_argument->range_end));

        textBox->setValidator(textValidator);
    }

    textBox->setText(defaultValue());

    connect(textBox, SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));

    return textBox;
}
Exemple #2
0
QWidget * ExtArgText::createEditor(QWidget * parent)
{
    QString storeValue;
    QString text = defaultValue();

    if ( _argument->storeval )
    {
        QString storeValue = _argument->storeval;

        if ( storeValue.length() > 0 && storeValue.compare(text) != 0 )
            text = storeValue.trimmed();
    }

    textBox = new QLineEdit(text, parent);

    if ( _argument->tooltip != NULL )
        textBox->setToolTip(QString().fromUtf8(_argument->tooltip));

    if (_argument->arg_type == EXTCAP_ARG_PASSWORD)
        textBox->setEchoMode(QLineEdit::Password);

    connect(textBox , SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));

    return textBox;
}
QWidget * ExtArgText::createEditor(QWidget * parent)
{
    textBox = new QLineEdit(_default->toString(), parent);

    textBox->setText(defaultValue());

    if ( _argument->tooltip != NULL )
        textBox->setToolTip(QString().fromUtf8(_argument->tooltip));

    connect(textBox , SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));

    return textBox;
}
Exemple #4
0
QWidget * ExtArgNumber::createEditor(QWidget * parent)
{
    QString storeValue;
    QString text = defaultValue();

    if ( _argument->storeval )
    {
        QString storeValue = _argument->storeval;

        if ( storeValue.length() > 0 && storeValue.compare(text) != 0 )
            text = storeValue;
    }

    textBox = (QLineEdit *)ExtArgText::createEditor(parent);
    textBox->disconnect(SIGNAL(textChanged(QString)));

    if ( _argument->arg_type == EXTCAP_ARG_INTEGER || _argument->arg_type == EXTCAP_ARG_UNSIGNED )
    {
        QIntValidator * textValidator = new QIntValidator(parent);
        if ( _argument->range_start != NULL )
        {
            int val = 0;
            if ( _argument->arg_type == EXTCAP_ARG_INTEGER )
                val = extcap_complex_get_int(_argument->range_start);
            else if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED )
            {
                guint tmp = extcap_complex_get_uint(_argument->range_start);
                if ( tmp > G_MAXINT )
                {
                    g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Defined value for range_start of %s exceeds valid integer range", _argument->call );
                    val = G_MAXINT;
                }
                else
                    val = (gint)tmp;
            }

            textValidator->setBottom(val);
        }
        if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED && textValidator->bottom() < 0 )
        {
            g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "%s sets negative bottom range for unsigned value, setting to 0", _argument->call );
            textValidator->setBottom(0);
        }

        if ( _argument->range_end != NULL )
        {
            int val = 0;
            if ( _argument->arg_type == EXTCAP_ARG_INTEGER )
                val = extcap_complex_get_int(_argument->range_end);
            else if ( _argument->arg_type == EXTCAP_ARG_UNSIGNED )
            {
                guint tmp = extcap_complex_get_uint(_argument->range_end);
                if ( tmp > G_MAXINT )
                {
                    g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Defined value for range_end of %s exceeds valid integer range", _argument->call );
                    val = G_MAXINT;
                }
                else
                    val = (gint)tmp;
            }

            textValidator->setTop(val);
        }
        textBox->setValidator(textValidator);
    }
    else if ( _argument->arg_type == EXTCAP_ARG_DOUBLE )
    {
        QDoubleValidator * textValidator = new QDoubleValidator(parent);
        if ( _argument->range_start != NULL )
            textValidator->setBottom(extcap_complex_get_double(_argument->range_start));
        if ( _argument->range_end != NULL )
            textValidator->setTop(extcap_complex_get_double(_argument->range_end));

        textBox->setValidator(textValidator);
    }

    textBox->setText(text.trimmed());

    connect(textBox, SIGNAL(textChanged(QString)), SLOT(onStringChanged(QString)));

    return textBox;
}