mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4775 Summary : Use combo box with history to edit text based curve creation
This commit is contained in:
parent
7a470587ac
commit
0af6a1d95d
@ -50,6 +50,7 @@
|
||||
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
||||
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
|
||||
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiLabelEditor.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiToolBarEditor.h"
|
||||
@ -90,6 +91,7 @@ RimSummaryPlotFilterTextCurveSetEditor::RimSummaryPlotFilterTextCurveSetEditor()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_curveFilterText, "CurveFilterText", "Curve Filter Text", "", toolTipPropertyEditor, "" );
|
||||
m_curveFilterText.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
m_curveFilterText.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
|
||||
|
||||
// Special tool tip for toolbar
|
||||
m_curveFilterText.uiCapability()->setUiToolTip( toolTipToolbar, caf::PdmUiToolBarEditor::uiEditorConfigName() );
|
||||
@ -381,6 +383,17 @@ void RimSummaryPlotFilterTextCurveSetEditor::fieldChangedByUi( const caf::PdmFie
|
||||
{
|
||||
m_curveFilterText = curveFilterTextWithoutOutdatedLabel();
|
||||
|
||||
{
|
||||
if ( m_historyItems.indexOf( m_curveFilterText ) == -1 )
|
||||
{
|
||||
m_historyItems.push_front( m_curveFilterText );
|
||||
while ( m_historyItems.size() > 10 )
|
||||
{
|
||||
m_historyItems.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_curveFilterText.uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
@ -430,17 +443,29 @@ void RimSummaryPlotFilterTextCurveSetEditor::defineEditorAttribute( const caf::P
|
||||
{
|
||||
if ( field == &m_curveFilterText )
|
||||
{
|
||||
auto attr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
|
||||
if ( attr )
|
||||
{
|
||||
if ( uiConfigName == caf::PdmUiToolBarEditor::uiEditorConfigName() )
|
||||
auto attr = dynamic_cast<caf::PdmUiLineEditorAttribute*>( attribute );
|
||||
if ( attr )
|
||||
{
|
||||
// Special config for toolbar
|
||||
attr->maximumWidth = 150;
|
||||
}
|
||||
if ( uiConfigName == caf::PdmUiToolBarEditor::uiEditorConfigName() )
|
||||
{
|
||||
// Special config for toolbar
|
||||
attr->maximumWidth = 150;
|
||||
}
|
||||
|
||||
attr->selectAllOnFocusEvent = true;
|
||||
attr->placeholderText = "Click to define filter";
|
||||
attr->selectAllOnFocusEvent = true;
|
||||
attr->placeholderText = "Click to define filter";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto attr = dynamic_cast<caf::PdmUiComboBoxEditorAttribute*>( attribute );
|
||||
if ( attr )
|
||||
{
|
||||
attr->enableEditableContent = true;
|
||||
attr->adjustWidthToContents = true;
|
||||
attr->minimumWidth = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -458,6 +483,14 @@ QList<caf::PdmOptionItemInfo>
|
||||
appendOptionItemsForSources( options, false, false );
|
||||
}
|
||||
|
||||
if ( fieldNeedingOptions == &m_curveFilterText )
|
||||
{
|
||||
for ( const auto& s : m_historyItems )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( s, s ) );
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ private:
|
||||
|
||||
caf::PdmField<QString> m_curveFilterLabelText;
|
||||
caf::PdmField<QString> m_curveFilterText;
|
||||
QStringList m_historyItems;
|
||||
|
||||
bool m_isFieldRecentlyChangedFromGui;
|
||||
};
|
||||
|
@ -204,6 +204,32 @@ void PdmUiToolBarEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiToolBarEditor::focusWidget(PdmUiFieldEditorHandle* uiFieldEditorHandle)
|
||||
{
|
||||
// Some editors have a placeholder widget as parent of the main editor widget
|
||||
// This is the case for combo box widget to allow up/down arrow buttons associated with the combo box
|
||||
|
||||
QWidget* editorWidget = nullptr;
|
||||
auto comboEditor = dynamic_cast<caf::PdmUiComboBoxEditor*>(uiFieldEditorHandle);
|
||||
if (comboEditor)
|
||||
{
|
||||
auto topWidget = comboEditor->editorWidget();
|
||||
QComboBox* comboBox = topWidget->findChild<QComboBox*>();
|
||||
|
||||
editorWidget = comboBox;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
editorWidget = uiFieldEditorHandle->editorWidget();
|
||||
}
|
||||
|
||||
return editorWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -244,10 +270,11 @@ void PdmUiToolBarEditor::setFocusWidgetFromKeyword(const QString& fieldKeyword)
|
||||
auto fieldView = m_fieldViews.find(fieldKeyword);
|
||||
if (fieldView != m_fieldViews.end() && fieldView->second)
|
||||
{
|
||||
auto editorWidget = fieldView->second->editorWidget();
|
||||
if (editorWidget)
|
||||
QWidget* widget = focusWidget(fieldView->second);
|
||||
|
||||
if (widget)
|
||||
{
|
||||
editorWidget->setFocus(Qt::ActiveWindowFocusReason);
|
||||
widget->setFocus(Qt::ActiveWindowFocusReason);
|
||||
|
||||
PdmUiLineEditorAttribute attributes;
|
||||
|
||||
@ -265,7 +292,7 @@ void PdmUiToolBarEditor::setFocusWidgetFromKeyword(const QString& fieldKeyword)
|
||||
|
||||
if (attributes.selectAllOnFocusEvent)
|
||||
{
|
||||
auto lineEdit = dynamic_cast<QLineEdit*>(editorWidget);
|
||||
auto lineEdit = dynamic_cast<QLineEdit*>(widget);
|
||||
if (lineEdit )
|
||||
{
|
||||
lineEdit->selectAll();
|
||||
@ -316,11 +343,11 @@ QString PdmUiToolBarEditor::keywordForFocusWidget()
|
||||
{
|
||||
for (auto fieldViewPair : m_fieldViews)
|
||||
{
|
||||
auto fieldView = fieldViewPair.second;
|
||||
if (fieldView)
|
||||
auto uiFieldEditorHandle = fieldViewPair.second;
|
||||
if (uiFieldEditorHandle)
|
||||
{
|
||||
auto editorWidget = fieldView->editorWidget();
|
||||
if (editorWidget && editorWidget->hasFocus())
|
||||
auto widget = focusWidget(uiFieldEditorHandle);
|
||||
if (widget && widget->hasFocus())
|
||||
{
|
||||
keyword = fieldViewPair.first;
|
||||
}
|
||||
|
@ -75,6 +75,8 @@ public:
|
||||
|
||||
private:
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
|
||||
static QWidget* focusWidget(PdmUiFieldEditorHandle* uiFieldEditorHandle);
|
||||
|
||||
private:
|
||||
QPointer<QToolBar> m_toolbar;
|
||||
|
Loading…
Reference in New Issue
Block a user