void QgsDefaultSearchWidgetWrapper::setExpression( QString exp )
{
  QVariant::Type fldType = layer()->fields()[mFieldIdx].type();
  bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double || fldType == QVariant::LongLong );

  QSettings settings;
  QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
  QString fieldName = layer()->fields()[mFieldIdx].name();
  QString str;
  if ( exp == nullValue )
  {
    str = QString( "%1 IS NULL" ).arg( QgsExpression::quotedColumnRef( fieldName ) );
  }
  else
  {
    str = QString( "%1 %2 '%3'" )
          .arg( QgsExpression::quotedColumnRef( fieldName ) )
          .arg( numeric ? "=" : mCaseString )
          .arg( numeric
                ? exp.replace( "'", "''" )
                :
                "%" + exp.replace( "'", "''" ) + "%" ); // escape quotes
  }
  mExpression = str;
  emit expressionChanged( mExpression );
}
示例#2
0
/*!
  \reimp
*/
void QThemeLevelItem::loadAttributes(QXmlStreamReader &reader)
{
    QThemeImageItem::loadAttributes(reader);
    if (!reader.attributes().value("count").isEmpty())
        d->count = reader.attributes().value("count").toString().toInt();
    if (!reader.attributes().value("min").isEmpty())
        d->min = reader.attributes().value("min").toString().toInt();
    if (!reader.attributes().value("max").isEmpty())
        d->max = reader.attributes().value("max").toString().toInt();
    if (!reader.attributes().value("loop").isEmpty())
        d->loop = reader.attributes().value("loop").toString().toInt();
    if (!reader.attributes().value("looprev").isEmpty())
        d->looprev = reader.attributes().value("looprev").toString().toInt();

    if (d->animInfo)
        delete d->animInfo;
    d->animInfo = new QThemeAnimationFrameInfo(this, reader.attributes().value("delay").toString().toInt());

    if (!reader.attributes().value("play").isEmpty()) {
        QString play = reader.attributes().value("play").toString();
        if (isExpression(play)) {
            d->playExpression = createExpression(strippedExpression(play));
            if (d->playExpression)
                expressionChanged(d->playExpression);
        } else if (play != "no") {
            /*            if (!attribute("playing"))*/
            start();
        }
    }
}
void PropertyEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
                                             const PropertyName &name,
                                             const QVariant &value,
                                             PropertyEditorView *propertyEditor)
{
    PropertyName propertyName(name);
    propertyName.replace('.', '_');
    PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(backendValuesPropertyMap().value(propertyName)));
    if (!valueObject) {
        valueObject = new PropertyEditorValue(&backendValuesPropertyMap());
        QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &backendValuesPropertyMap(), SIGNAL(valueChanged(QString,QVariant)));
        QObject::connect(valueObject, SIGNAL(expressionChanged(QString)), propertyEditor, SLOT(changeExpression(QString)));
        backendValuesPropertyMap().insert(QString::fromUtf8(propertyName), QVariant::fromValue(valueObject));
    }
    valueObject->setName(name);
    valueObject->setModelNode(qmlObjectNode);

    if (qmlObjectNode.propertyAffectedByCurrentState(name) && !(qmlObjectNode.modelNode().property(name).isBindingProperty()))
        valueObject->setValue(qmlObjectNode.modelValue(name));

    else
        valueObject->setValue(value);

    if (propertyName != "id" &&
        qmlObjectNode.currentState().isBaseState() &&
        qmlObjectNode.modelNode().property(propertyName).isBindingProperty()) {
        valueObject->setExpression(qmlObjectNode.modelNode().bindingProperty(propertyName).expression());
    } else {
        valueObject->setExpression(qmlObjectNode.instanceValue(name).toString());
    }
}
示例#4
0
void PropertyEditorValue::setExpressionWithEmit(const QString &expression)
{
    if ( m_expression != expression) {
        setExpression(expression);
        emit expressionChanged(name());
    }
}
示例#5
0
void createPropertyEditorValue(const QmlObjectNode &fxObjectNode, const QString &name, const QVariant &value, QDeclarativePropertyMap *propertyMap, PropertyEditor *propertyEditor)
{
    QString propertyName(name);
    propertyName.replace(QLatin1Char('.'), QLatin1Char('_'));
    PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(propertyMap->value(propertyName)));
    if (!valueObject) {
        valueObject = new PropertyEditorValue(propertyMap);
        QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), propertyMap, SIGNAL(valueChanged(QString,QVariant)));
        QObject::connect(valueObject, SIGNAL(expressionChanged(QString)), propertyEditor, SLOT(changeExpression(QString)));
        propertyMap->insert(propertyName, QVariant::fromValue(valueObject));
    }
    valueObject->setName(name);
    valueObject->setModelNode(fxObjectNode);

    if (fxObjectNode.propertyAffectedByCurrentState(name) && !(fxObjectNode.modelNode().property(name).isBindingProperty())) {
        valueObject->setValue(fxObjectNode.modelValue(name));

    } else {
        valueObject->setValue(value);
    }

    if (propertyName != QLatin1String("id") &&
        fxObjectNode.currentState().isBaseState() &&
        fxObjectNode.modelNode().property(propertyName).isBindingProperty()) {
        valueObject->setExpression(fxObjectNode.modelNode().bindingProperty(propertyName).expression());
    } else {
        valueObject->setExpression(fxObjectNode.instanceValue(name).toString());
    }
}
示例#6
0
void PropertyEditorValue::setExpression(const QString &expression)
{
    if ( m_expression != expression) {
        m_expression = expression;
        emit expressionChanged(QString());
    }
}
MatrixFunctionDialog::MatrixFunctionDialog(Matrix* m, QWidget* parent, Qt::WFlags fl) : KDialog(parent, fl), m_matrix(m) {
	Q_ASSERT(m_matrix);
	setWindowTitle(i18n("Function values"));

	QFrame* mainWidget = new QFrame(this);
	ui.setupUi(mainWidget);
	setMainWidget( mainWidget );

	ui.tbConstants->setIcon( KIcon("labplot-format-text-symbol") );
	ui.tbFunctions->setIcon( KIcon("preferences-desktop-font") );

	QStringList vars;
	vars<<"x"<<"y";
	ui.teEquation->setVariables(vars);
	ui.teEquation->setFocus();

	QString info = "[" + QString::number(m_matrix->xStart()) + ", " + QString::number(m_matrix->xEnd()) + "], " + QString::number(m_matrix->columnCount()) + " " + i18n("values");
	ui.lXInfo->setText(info);
	info = "[" + QString::number(m_matrix->yStart()) + ", " + QString::number(m_matrix->yEnd()) + "], " + QString::number(m_matrix->rowCount()) + " " + i18n("values");
	ui.lYInfo->setText(info);

	ui.teEquation->setPlainText(m_matrix->formula());

	setButtons( KDialog::Ok | KDialog::Cancel );
	setButtonText(KDialog::Ok, i18n("&Generate"));
	setButtonToolTip(KDialog::Ok, i18n("Generate function values"));

	connect( ui.teEquation, SIGNAL(expressionChanged()), this, SLOT(checkValues()) );
	connect( ui.tbConstants, SIGNAL(clicked()), this, SLOT(showConstants()) );
	connect( ui.tbFunctions, SIGNAL(clicked()), this, SLOT(showFunctions()) );
	connect(this, SIGNAL(okClicked()), this, SLOT(generate()));

	resize( QSize(300,0).expandedTo(minimumSize()) );
}
void RemoteWantedEdit::setWantedExpr(WantedExpr *wantedExpr)
{
    this->wantedExpr = wantedExpr;
    dialog->setWantedExpr(wantedExpr);
    connect(wantedExpr, SIGNAL(expressionChanged(QString)), this, SLOT(refresh()));
    refresh();
}
示例#9
0
void
KnobGui::onExprChanged(int dimension)
{
    if (_imp->guiRemoved) {
        return;
    }
    KnobPtr knob = getKnob();
    std::string exp = knob->getExpression(dimension);
    reflectExpressionState(dimension,!exp.empty());
    if (exp.empty()) {
        reflectAnimationLevel(dimension, knob->getAnimationLevel(dimension));
    } else {
        
        NodeSettingsPanel* isNodeSettings = dynamic_cast<NodeSettingsPanel*>(_imp->container);
        if (isNodeSettings) {
            NodeGuiPtr node = isNodeSettings->getNode();
            if (node) {
                node->onKnobExpressionChanged(this);
            }
        }
        
        if (_imp->warningIndicator) {
            bool invalid = false;
            QString fullErrTooltip;
            int dims = knob->getDimension();
            for (int i = 0; i < dims; ++i) {
                std::string err;
                if (!knob->isExpressionValid(i, &err)) {
                    invalid = true;
                }
                if (dims > 1 && invalid) {
                    fullErrTooltip += QString::fromUtf8("<p><b>");
                    fullErrTooltip += QString::fromUtf8(knob->getDimensionName(i).c_str());
                    fullErrTooltip += QString::fromUtf8("</b></p>");
                }
                if (!err.empty()) {
                    fullErrTooltip += QString::fromUtf8(err.c_str());
                }
            }
            if (invalid) {
                QString toPrepend;
                toPrepend += QString::fromUtf8("<p>");
                toPrepend += QObject::tr("Invalid expression(s), value returned is the underlying curve:");
                toPrepend += QString::fromUtf8("</p>");
                fullErrTooltip.prepend(toPrepend);
                
                setWarningValue(eKnobWarningExpressionInvalid, fullErrTooltip);
            } else {
                setWarningValue(eKnobWarningExpressionInvalid, QString());
            }
        }
        onHelpChanged();
        Q_EMIT expressionChanged();
        
    }
    updateGUI(dimension);
    
}
示例#10
0
/*!
 * 	// Tab "General"
 */
void XYFitCurveDock::setupGeneral() {
    QWidget* generalTab = new QWidget(ui.tabGeneral);
    uiGeneralTab.setupUi(generalTab);
    QGridLayout* gridLayout = dynamic_cast<QGridLayout*>(generalTab->layout());
    if (gridLayout) {
        gridLayout->setContentsMargins(2,2,2,2);
        gridLayout->setHorizontalSpacing(2);
        gridLayout->setVerticalSpacing(2);
    }

    cbXDataColumn = new TreeViewComboBox(generalTab);
    gridLayout->addWidget(cbXDataColumn, 4, 4, 1, 2);

    cbYDataColumn = new TreeViewComboBox(generalTab);
    gridLayout->addWidget(cbYDataColumn, 5, 4, 1, 2);

    cbWeightsColumn = new TreeViewComboBox(generalTab);
    gridLayout->addWidget(cbWeightsColumn, 6, 4, 1, 2);

    uiGeneralTab.cbModel->addItem(i18n("Polynomial"));
    uiGeneralTab.cbModel->addItem(i18n("Power"));
    uiGeneralTab.cbModel->addItem(i18n("Exponential"));
    uiGeneralTab.cbModel->addItem(i18n("Inverse Exponential"));
    uiGeneralTab.cbModel->addItem(i18n("Fourier"));
    uiGeneralTab.cbModel->addItem(i18n("Gaussian"));
    uiGeneralTab.cbModel->addItem(i18n("Lorentz (Cauchy)"));
    uiGeneralTab.cbModel->addItem(i18n("Maxwell-Boltzmann"));
    uiGeneralTab.cbModel->addItem(i18n("Sigmoid"));
    uiGeneralTab.cbModel->addItem(i18n("Custom"));

    uiGeneralTab.teEquation->setMaximumHeight(uiGeneralTab.leName->sizeHint().height()*2);

    uiGeneralTab.tbConstants->setIcon( KIcon("labplot-format-text-symbol") );
    uiGeneralTab.tbFunctions->setIcon( KIcon("preferences-desktop-font") );
    uiGeneralTab.pbRecalculate->setIcon(KIcon("run-build"));

    QHBoxLayout* layout = new QHBoxLayout(ui.tabGeneral);
    layout->setMargin(0);
    layout->addWidget(generalTab);

    //Slots
    connect( uiGeneralTab.leName, SIGNAL(returnPressed()), this, SLOT(nameChanged()) );
    connect( uiGeneralTab.leComment, SIGNAL(returnPressed()), this, SLOT(commentChanged()) );
    connect( uiGeneralTab.chkVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) );

    connect( uiGeneralTab.cbModel, SIGNAL(currentIndexChanged(int)), this, SLOT(modelChanged(int)) );
    connect( uiGeneralTab.sbDegree, SIGNAL(valueChanged(int)), this, SLOT(updateModelEquation()) );
    connect( uiGeneralTab.teEquation, SIGNAL(expressionChanged()), this, SLOT(enableRecalculate()) );
    connect( uiGeneralTab.tbConstants, SIGNAL(clicked()), this, SLOT(showConstants()) );
    connect( uiGeneralTab.tbFunctions, SIGNAL(clicked()), this, SLOT(showFunctions()) );
    connect( uiGeneralTab.pbParameters, SIGNAL(clicked()), this, SLOT(showParameters()) );
    connect( uiGeneralTab.pbOptions, SIGNAL(clicked()), this, SLOT(showOptions()) );
    connect( uiGeneralTab.pbRecalculate, SIGNAL(clicked()), this, SLOT(recalculateClicked()) );
}
void QgsCheckboxSearchWidgetWrapper::stateChanged( int )
{
  if ( mCheckBox )
  {
    mCheckBox->setTristate( false );
    QString exp = value().toString();
    setExpression( exp );
    emit valueChanged();
    emit expressionChanged( mExpression );
  }
}
示例#12
0
void FunctionCurve::setFunction(AbstractFunction *f)
{
    if(f != mFunction) {
        mFunction = f;
        setTitle(f->getName());
        qDebug() << "FunctionCurve::setFunction for function "<<f->getName();
        connect(mFunction, SIGNAL(needsRecompute()), this, SLOT(slotUpdateData()));
        connect(mFunction, SIGNAL(nameUpdated(const QString &)), this, SLOT(updateName(const QString &)));
        connect(mFunction, SIGNAL(expressionChanged()), this, SLOT(slotDeferedUpdate()));
        mNeedsUpdate = true;
        update();
    }
void QgsDateTimeSearchWidgetWrapper::dateTimeChanged( const QDateTime& dt )
{
  if ( mDateTimeEdit )
  {
    QString exp = value().toString();
    setExpression( exp );
    if ( dt.isValid() && !dt.isNull() )
      emit valueChanged();
    else
      emit valueCleared();
    emit expressionChanged( mExpression );
  }
}
void QgsValueRelationSearchWidgetWrapper::valueChanged()
{
  QVariant vl = value();
  if ( !vl.isValid() )
  {
    clearExpression();
  }
  else
  {
    QSettings settings;
    setExpression( vl.isNull() ? settings.value( "qgis/nullValue", "NULL" ).toString() : vl.toString() );
  }
  emit expressionChanged( mExpression );
}
示例#15
0
/*!
  \reimp
*/
void QThemeLevelItem::constructionComplete()
{
    if (!d->text.isEmpty()) {
        if (isExpression(d->text)) {
            d->frameExpression = createExpression(strippedExpression(d->text));
            if (d->frameExpression != 0)
                expressionChanged(d->frameExpression);
        } else {
            setFrame(d->text.toInt());
        }
        d->text = QString();
    }
    QThemeImageItem::constructionComplete();
}
void QgsValueMapSearchWidgetWrapper::comboBoxIndexChanged( int idx )
{
  if ( mComboBox )
  {
    if ( idx == 0 )
    {
      clearExpression();
    }
    else
    {
      setExpression( mComboBox->itemData( idx ).toString() );
    }
    emit expressionChanged( mExpression );
  }
}
void QgsRelationReferenceSearchWidgetWrapper::onValueChanged( const QVariant& value )
{
  if ( !value.isValid() )
  {
    clearExpression();
    emit valueCleared();
  }
  else
  {
    QSettings settings;
    setExpression( value.isNull() ? settings.value( QStringLiteral( "qgis/nullValue" ), "NULL" ).toString() : value.toString() );
    emit valueChanged();
  }
  emit expressionChanged( mExpression );
}
void QgsValueRelationSearchWidgetWrapper::onValueChanged()
{
  QVariant vl = value();
  if ( !vl.isValid() )
  {
    clearExpression();
    emit valueCleared();
  }
  else
  {
    setExpression( vl.isNull() ? QgsApplication::nullRepresentation() : vl.toString() );
    emit valueChanged();
  }
  emit expressionChanged( mExpression );
}
void QgsRelationReferenceSearchWidgetWrapper::onValueChanged( const QVariant &value )
{
  if ( !value.isValid() )
  {
    clearExpression();
    emit valueCleared();
  }
  else
  {
    QgsSettings settings;
    setExpression( value.isNull() ? QgsApplication::nullRepresentation() : value.toString() );
    emit valueChanged();
  }
  emit expressionChanged( mExpression );
}
示例#20
0
void QgsDefaultSearchWidgetWrapper::setCaseString( int caseSensitiveCheckState )
{
  if ( caseSensitiveCheckState == Qt::Checked )
  {
    mCaseString = QStringLiteral( "LIKE" );
  }
  else
  {
    mCaseString = QStringLiteral( "ILIKE" );
  }
  // need to update also the line edit
  setExpression( mLineEdit->text() );

  if ( applyDirectly() )
    emit expressionChanged( mExpression );
}
示例#21
0
 ExpressionMenu(Fun f, QWidget* parent)
     : menu{new QMenu{parent}}
     , deleteAction{menu->addAction(QObject::tr("Disable"))}
     , editAction{menu->addAction(QObject::tr("Edit"))}
 {
   connect(editAction, &QAction::triggered, this, [=] {
     bool ok = false;
     auto str = QInputDialog::getText(
         nullptr,
         tr("Edit expression"),
         tr("Edit expression"),
         QLineEdit::Normal,
         f().toString(),
         &ok);
     if (ok)
       expressionChanged(std::move(str));
   });
 }
示例#22
0
void setupPropertyEditorValue(const QString &name, QDeclarativePropertyMap *propertyMap, PropertyEditor *propertyEditor, const QString &type)
{
    QString propertyName(name);
    propertyName.replace(QLatin1Char('.'), QLatin1Char('_'));
    PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(QDeclarativeMetaType::toQObject(propertyMap->value(propertyName)));
    if (!valueObject) {
        valueObject = new PropertyEditorValue(propertyMap);
        QObject::connect(valueObject, SIGNAL(valueChanged(QString, const QVariant&)), propertyMap, SIGNAL(valueChanged(QString, const QVariant&)));
        QObject::connect(valueObject, SIGNAL(expressionChanged(QString)), propertyEditor, SLOT(changeExpression(QString)));
        propertyMap->insert(propertyName, QVariant::fromValue(valueObject));
    }
    valueObject->setName(propertyName);
    if (type == "QColor")
        valueObject->setValue(QVariant("#000000"));
    else
        valueObject->setValue(QVariant(1));

}
void PropertyEditorQmlBackend::setupPropertyEditorValue(const PropertyName &name, PropertyEditorView *propertyEditor, const QString &type)
{
    QmlDesigner::PropertyName propertyName(name);
    propertyName.replace('.', '_');
    PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(backendValuesPropertyMap().value(propertyName)));
    if (!valueObject) {
        valueObject = new PropertyEditorValue(&backendValuesPropertyMap());
        QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &backendValuesPropertyMap(), SIGNAL(valueChanged(QString,QVariant)));
        QObject::connect(valueObject, SIGNAL(expressionChanged(QString)), propertyEditor, SLOT(changeExpression(QString)));
        backendValuesPropertyMap().insert(QString::fromUtf8(propertyName), QVariant::fromValue(valueObject));
    }
    valueObject->setName(propertyName);
    if (type == "QColor")
        valueObject->setValue(QVariant("#000000"));
    else
        valueObject->setValue(QVariant(1));

}
示例#24
0
void setupPropertyEditorValue(const PropertyName &name, QDeclarativePropertyMap *propertyMap, PropertyEditor *propertyEditor, const QString &type)
{
    QmlDesigner::PropertyName propertyName(name);
    propertyName.replace('.', '_');
    PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(propertyMap->value(propertyName)));
    if (!valueObject) {
        valueObject = new PropertyEditorValue(propertyMap);
        QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), propertyMap, SIGNAL(valueChanged(QString,QVariant)));
        QObject::connect(valueObject, SIGNAL(expressionChanged(QString)), propertyEditor, SLOT(changeExpression(QString)));
        propertyMap->insert(QString::fromUtf8(propertyName), QVariant::fromValue(valueObject));
    }
    valueObject->setName(propertyName);
    if (type == "QColor")
        valueObject->setValue(QVariant("#000000"));
    else
        valueObject->setValue(QVariant(1));

}
示例#25
0
void ValidateExpressionThread::run()
{
    while(!mStopThread)
    {
        mExpressionMutex.lock();
        QString expression = mExpressionText;
        bool changed = mExpressionChanged;
        mExpressionChanged = false;
        mExpressionMutex.unlock();
        if(changed)
        {
            duint value;
            bool validExpression = DbgFunctions()->ValFromString(expression.toUtf8().constData(), &value);
            bool validPointer = validExpression && DbgMemIsValidReadPtr(value);
            emit expressionChanged(validExpression, validPointer, value);
        }
        Sleep(50);
    }
    mStopThread = false;
}
QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx )
    : QDialog()
    , mLayer( vl )
    , mFieldIdx( fieldIdx )
{
  setupUi( this );
  setWindowTitle( tr( "Edit Widget Properties - %1 (%2)" ).arg( vl->fields().at( fieldIdx ).name(), vl->name() ) );

  QMapIterator<QString, QgsEditorWidgetFactory*> it( QgsEditorWidgetRegistry::instance()->factories() );
  while ( it.hasNext() )
  {
    it.next();
    QListWidgetItem* item = new QListWidgetItem( selectionListWidget );
    item->setText( it.value()->name() );
    item->setData( Qt::UserRole, it.key() );
    if ( !it.value()->supportsField( vl, fieldIdx ) )
      item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
    selectionListWidget->addItem( item );
  }

  // Set required list width based on content + twice the border width
  selectionListWidget->setMinimumWidth( selectionListWidget->sizeHintForColumn( 0 )
                                        + 2 );
  selectionListWidget->setMaximumWidth( selectionListWidget->sizeHintForColumn( 0 )
                                        + 2 );

  if ( vl->fields().fieldOrigin( fieldIdx ) == QgsFields::OriginJoin ||
       vl->fields().fieldOrigin( fieldIdx ) == QgsFields::OriginExpression )
  {
    isFieldEditableCheckBox->setEnabled( false );
  }

  connect( mExpressionWidget, SIGNAL( expressionChanged( QString ) ), this, SLOT( defaultExpressionChanged() ) );

  QSettings settings;
  restoreGeometry( settings.value( "/Windows/QgsAttributeTypeDialog/geometry" ).toByteArray() );

  constraintExpressionWidget->setLayer( vl );
}
示例#27
0
void QSearchBar::expressionChangedHandler(const QString & text)
{
	emit expressionChanged(text);
}
示例#28
0
void QgsExpressionLineEdit::expressionEdited( const QString& expression )
{
  updateLineEditStyle( expression );
  emit expressionChanged( expression );
}
// =============================== PRIVATE ====================================
void FunctionVariablesWidget::useFunction(const FunctionPtr &f)
{
    mFunction = f;
    connect(f.data(), SIGNAL(expressionChanged()), this, SLOT(updateVariables()));
    updateVariables();
}
示例#30
0
void QDuseQualityMetricObject::setExpression(QObject *expression)
{
    qmodelingelementproperty_cast<QDuseQualityMetric *>(this)->setExpression(qmodelingelementproperty_cast<QUmlOpaqueExpression *>(expression));
    emit expressionChanged(this->expression());
}