mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3076 Stop key press event in time step interval causing filtered dialog to close.
This commit is contained in:
parent
a888ab0160
commit
9e7dd7d4ea
@ -26,6 +26,7 @@
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
|
||||
@ -67,6 +68,7 @@ RimTimeStepFilter::RimTimeStepFilter()
|
||||
CAF_PDM_InitField(&m_lastTimeStep, "LastTimeStep", 0, "Last Time Step", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_interval, "Interval", 1, "Interval", "", "", "");
|
||||
m_interval.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&m_timeStepNamesFromFile, "TimeStepsFromFile", std::vector<QString>(), "TimeSteps From File", "", "", "");
|
||||
CAF_PDM_InitField(&m_dateFormat, "DateFormat", QString("yyyy-MM-dd"), "Date Format", "", "", "");
|
||||
@ -259,6 +261,14 @@ void RimTimeStepFilter::defineEditorAttribute(const caf::PdmFieldHandle* field,
|
||||
attrib->m_buttonText = "Reload Case";
|
||||
}
|
||||
}
|
||||
else if (field == &m_interval)
|
||||
{
|
||||
caf::PdmUiLineEditorAttribute* attrib = dynamic_cast<caf::PdmUiLineEditorAttribute*>(attribute);
|
||||
if (attrib)
|
||||
{
|
||||
attrib->avoidSendingEnterEventToParentWidget = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -46,9 +46,9 @@
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QKeyEvent>
|
||||
#include <QIntValidator>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QPalette>
|
||||
@ -195,6 +195,8 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
{
|
||||
m_lineEdit->setValidator(new QIntValidator(leab.minValue, leab.maxValue, this));
|
||||
}
|
||||
|
||||
m_lineEdit->setAvoidSendingEnterEventToParentWidget(leab.avoidSendingEnterEventToParentWidget);
|
||||
}
|
||||
|
||||
{
|
||||
@ -259,7 +261,7 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiLineEditor::createEditorWidget(QWidget * parent)
|
||||
{
|
||||
m_lineEdit = new QLineEdit(parent);
|
||||
m_lineEdit = new PdmUiLineEdit(parent);
|
||||
|
||||
connect(m_lineEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
|
||||
|
||||
@ -319,4 +321,37 @@ bool PdmUiLineEditor::isMultipleFieldsWithSameKeywordSelected(PdmFieldHandle* ed
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiLineEdit::PdmUiLineEdit(QWidget* parent)
|
||||
: QLineEdit(parent), m_avoidSendingEnterEvent(false)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiLineEdit::setAvoidSendingEnterEventToParentWidget(bool avoidSendingEnterEvent)
|
||||
{
|
||||
m_avoidSendingEnterEvent = avoidSendingEnterEvent;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiLineEdit::keyPressEvent(QKeyEvent * event)
|
||||
{
|
||||
QLineEdit::keyPressEvent(event);
|
||||
if (m_avoidSendingEnterEvent)
|
||||
{
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
|
||||
{
|
||||
// accept enter/return events so they won't
|
||||
// be ever propagated to the parent dialog..
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -58,12 +58,14 @@ class PdmUiLineEditorAttribute : public PdmUiEditorAttribute
|
||||
public:
|
||||
PdmUiLineEditorAttribute()
|
||||
{
|
||||
avoidSendingEnterEventToParentWidget = false;
|
||||
useRangeValidator = false;
|
||||
minValue = 0;
|
||||
maxValue = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
bool avoidSendingEnterEventToParentWidget;
|
||||
bool useRangeValidator;
|
||||
int minValue;
|
||||
int maxValue;
|
||||
@ -97,6 +99,17 @@ public:
|
||||
QString m_displayString;
|
||||
};
|
||||
|
||||
class PdmUiLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PdmUiLineEdit(QWidget* parent);
|
||||
void setAvoidSendingEnterEventToParentWidget(bool avoidSendingEnter);
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
private:
|
||||
bool m_avoidSendingEnterEvent;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -122,8 +135,8 @@ private:
|
||||
bool isMultipleFieldsWithSameKeywordSelected(PdmFieldHandle* editorField) const;
|
||||
|
||||
private:
|
||||
QPointer<QLineEdit> m_lineEdit;
|
||||
QPointer<QLabel> m_label;
|
||||
QPointer<PdmUiLineEdit> m_lineEdit;
|
||||
QPointer<QLabel> m_label;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user