9978 Improve UI for long drop-down lists, use tree selection more

* Improve tree selection editor
- always call defineEditorAttributes
- use heightHint in editor attributes 
- use tree selection editor as default editor for std::vector

* Use tree selection editor instead of list selection editor
List selection editor must be used when editing std::vector<cvf::vec3d> and similar. Replace other use of list selection editor with tree selection editor.

* Set checked state based on text string for integer only models
For models with only integer values, use text string to define the items to be selected. The full list will always be visible, and the checked state will be updated when editing the filter text.

Example: "1, 5-7" will set items 1, 5, 6, 7 checked and all other items unchecked

* Minor fixes
- Set placeholder text after content is added (to ensure correct data type)
- Fix check of integers. `canConvert<int>()`returns true for both QString and int. Thus convert to string and then check for int conversion.

* Activate filtering when unchecking all items in list with only integers
- Reactivate filtering when uncheck of all items for a list with only integer values (to keep consistency between filter and list)
- Update function name for clarity

---------

Co-authored-by: Jørgen Herje <jorgen.herje@ceetronsolutions.com>
This commit is contained in:
Magne Sjaastad
2023-05-22 15:44:37 +02:00
committed by GitHub
parent 2247dced58
commit 40080a99de
39 changed files with 281 additions and 157 deletions

View File

@@ -19,9 +19,11 @@
#include "RiaMemoryCleanup.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseResultInfo.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemResultAddress.h"
#include "RigGeoMechCaseData.h"
#include "Rim3dView.h"
#include "RimEclipseCase.h"
#include "RimEclipseResultDefinition.h"
@@ -29,8 +31,6 @@
#include "RimGeoMechResultDefinition.h"
#include "RimProject.h"
#include "RigEclipseResultInfo.h"
#include "cafPdmUiListEditor.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cafPdmUiTreeSelectionEditor.h"
@@ -46,17 +46,15 @@ CAF_PDM_SOURCE_INIT( RiaMemoryCleanup, "RiaMemoryCleanup" );
//--------------------------------------------------------------------------------------------------
RiaMemoryCleanup::RiaMemoryCleanup()
{
// clang-format off
CAF_PDM_InitFieldNoDefault(&m_case, "DataCase", "Case");
CAF_PDM_InitFieldNoDefault( &m_case, "DataCase", "Case" );
m_case = nullptr;
CAF_PDM_InitFieldNoDefault(&m_resultsToDelete, "ResultsToDelete", "Results In Memory");
m_resultsToDelete.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
m_resultsToDelete.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault( &m_resultsToDelete, "ResultsToDelete", "Results In Memory" );
m_resultsToDelete.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
m_resultsToDelete.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault(&m_performDelete, "ClearSelectedData", "");
caf::PdmUiPushButtonEditor::configureEditorForField(&m_performDelete);
// clang-format on
CAF_PDM_InitFieldNoDefault( &m_performDelete, "ClearSelectedData", "" );
caf::PdmUiPushButtonEditor::configureEditorForField( &m_performDelete );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -432,7 +432,7 @@ void RiaPreferencesSummary::defineEditorAttribute( const caf::PdmFieldHandle* fi
auto attrib = dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute );
if ( attrib )
{
attrib->m_heightHint = 30;
attrib->heightHint = 30;
}
}
}