mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improved integer slider editor
Use sliders for cell range filter
This commit is contained in:
@@ -46,14 +46,33 @@ void PdmUiSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
{
|
||||
assert(!m_lineEdit.isNull());
|
||||
|
||||
m_groupBox->setTitle(field()->uiName(uiConfigName));
|
||||
QIcon ic = field()->uiIcon(uiConfigName);
|
||||
if (!ic.isNull())
|
||||
{
|
||||
m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64))));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_label->setText(field()->uiName(uiConfigName));
|
||||
}
|
||||
|
||||
m_label->setVisible(!field()->isUiHidden(uiConfigName));
|
||||
m_label->setEnabled(!field()->isUiReadOnly(uiConfigName));
|
||||
|
||||
m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName));
|
||||
m_slider->setEnabled(!field()->isUiReadOnly(uiConfigName));
|
||||
|
||||
field()->ownerObject()->editorAttribute(field(), uiConfigName, &m_attributes);
|
||||
m_lineEdit->setValidator(new QIntValidator(m_attributes.m_minimum, m_attributes.m_maximum, this));
|
||||
|
||||
m_lineEdit->setText(field()->uiValue().toString());
|
||||
{
|
||||
m_slider->blockSignals(true);
|
||||
m_slider->setRange(m_attributes.m_minimum, m_attributes.m_maximum);
|
||||
m_slider->blockSignals(false);
|
||||
}
|
||||
|
||||
QString textValue = field()->uiValue().toString();
|
||||
m_lineEdit->setText(textValue);
|
||||
updateSliderPosition();
|
||||
}
|
||||
|
||||
@@ -62,25 +81,32 @@ void PdmUiSliderEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiSliderEditor::createEditorWidget(QWidget * parent)
|
||||
{
|
||||
m_groupBox = new QGroupBox(parent);
|
||||
QWidget* containerWidget = new QWidget(parent);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(parent);
|
||||
m_groupBox->setLayout(layout);
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setMargin(0);
|
||||
containerWidget->setLayout(layout);
|
||||
|
||||
m_lineEdit = new QLineEdit(m_groupBox);
|
||||
m_lineEdit->setValidator(new QIntValidator(m_attributes.m_minimum, m_attributes.m_maximum, m_groupBox));
|
||||
m_lineEdit = new QLineEdit(containerWidget);
|
||||
m_lineEdit->setMaximumWidth(30);
|
||||
connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
||||
|
||||
m_slider = new QSlider(Qt::Horizontal, m_groupBox);
|
||||
m_slider->setRange(m_attributes.m_minimum, m_attributes.m_maximum);
|
||||
|
||||
m_slider = new QSlider(Qt::Horizontal, containerWidget);
|
||||
layout->addWidget(m_lineEdit);
|
||||
layout->addWidget(m_slider);
|
||||
|
||||
|
||||
connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderValueChanged(int)));
|
||||
|
||||
return m_groupBox;
|
||||
return containerWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiSliderEditor::createLabelWidget(QWidget * parent)
|
||||
{
|
||||
m_label = new QLabel(parent);
|
||||
return m_label;
|
||||
}
|
||||
|
||||
|
||||
@@ -91,10 +117,7 @@ void PdmUiSliderEditor::slotEditingFinished()
|
||||
{
|
||||
updateSliderPosition();
|
||||
|
||||
QString textValue = m_lineEdit->text();
|
||||
QVariant v;
|
||||
v = textValue;
|
||||
this->setValueToField(v);
|
||||
writeValueToField();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -103,6 +126,8 @@ void PdmUiSliderEditor::slotEditingFinished()
|
||||
void PdmUiSliderEditor::slotSliderValueChanged(int position)
|
||||
{
|
||||
m_lineEdit->setText(QString::number(position));
|
||||
|
||||
writeValueToField();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -121,5 +146,16 @@ void PdmUiSliderEditor::updateSliderPosition()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiSliderEditor::writeValueToField()
|
||||
{
|
||||
QString textValue = m_lineEdit->text();
|
||||
QVariant v;
|
||||
v = textValue;
|
||||
this->setValueToField(v);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
Reference in New Issue
Block a user