#3877 Add RegExp-validator to "Well name for export" field for COMPDAT export

* Max 8 characters, minimum 1
* Only alpha-numeric characters and hyphen and underscore are acceptable. (no space)
This commit is contained in:
Gaute Lindkvist 2018-12-18 10:58:07 +01:00
parent 9851a2d938
commit 7296c11bc2
2 changed files with 21 additions and 0 deletions

View File

@ -32,8 +32,10 @@
#include "cvfAssert.h"
#include "cafPdmUiLineEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include <QRegExpValidator>
#include <cmath>
//--------------------------------------------------------------------------------------------------
@ -79,6 +81,7 @@ RimWellPathCompletions::RimWellPathCompletions()
m_fractureCollection.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_wellNameForExport, "WellNameForExport", QString(), "Well Name for Completion Export", "", "", "");
m_wellNameForExport.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_wellGroupName, "WellGroupNameForExport", QString(), "Well Group Name for Completion Export", "", "", "");
@ -282,6 +285,23 @@ void RimWellPathCompletions::fieldChangedByUi(const caf::PdmFieldHandle* changed
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCompletions::defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute)
{
caf::PdmUiLineEditorAttribute* lineEditorAttr = dynamic_cast<caf::PdmUiLineEditorAttribute*>(attribute);
if (field == &m_wellNameForExport && lineEditorAttr)
{
QRegExp rx("[\\w\\-\\_]{1,8}");
QRegExpValidator* validator = new QRegExpValidator(nullptr);
validator->setRegExp(rx);
lineEditorAttr->validator = validator;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -61,6 +61,7 @@ public:
protected:
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override;
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
private:
QString formatStringForExport(const QString& text, const QString& defaultText = "") const;