mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
Add flag to control display of check boxes
This commit is contained in:
parent
ef8b0836bf
commit
d751ce4ce0
@ -216,6 +216,8 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi( const QString& uiConfigName
|
||||
uiObject->editorAttribute( uiField()->fieldHandle(), uiConfigName, &m_attributes );
|
||||
}
|
||||
|
||||
m_model->showCheckBoxes( m_attributes.showCheckBoxes );
|
||||
|
||||
if ( PdmUiTreeSelectionQModel::isMultipleValueField( fieldValue ) )
|
||||
{
|
||||
m_useSingleSelectionMode = m_attributes.singleSelectionMode;
|
||||
@ -419,6 +421,8 @@ bool PdmUiTreeSelectionEditor::isMultiRowEditor() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeSelectionEditor::customMenuRequested( const QPoint& pos )
|
||||
{
|
||||
if ( !m_attributes.showContextMenu ) return;
|
||||
|
||||
QMenu menu;
|
||||
|
||||
QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
|
||||
|
@ -64,6 +64,8 @@ public:
|
||||
bool showToggleAllCheckbox;
|
||||
bool singleSelectionMode;
|
||||
bool setCurrentIndexWhenItemIsChecked;
|
||||
bool showCheckBoxes;
|
||||
bool showContextMenu;
|
||||
int heightHint;
|
||||
|
||||
/// currentIndexFieldHandle is used to communicate the value of current item in the tree view
|
||||
@ -79,6 +81,8 @@ public:
|
||||
showToggleAllCheckbox = true;
|
||||
singleSelectionMode = false;
|
||||
setCurrentIndexWhenItemIsChecked = false;
|
||||
showCheckBoxes = true;
|
||||
showContextMenu = true;
|
||||
heightHint = -1;
|
||||
|
||||
currentIndexFieldHandle = nullptr;
|
||||
|
@ -56,6 +56,7 @@ caf::PdmUiTreeSelectionQModel::PdmUiTreeSelectionQModel( QObject* parent /*= 0*/
|
||||
, m_uiValueCache( nullptr )
|
||||
, m_tree( nullptr )
|
||||
, m_singleSelectionMode( false )
|
||||
, m_showCheckBoxes( true )
|
||||
, m_indexForLastUncheckedItem( QModelIndex() )
|
||||
{
|
||||
}
|
||||
@ -191,6 +192,14 @@ void caf::PdmUiTreeSelectionQModel::enableSingleSelectionMode( bool enable )
|
||||
m_singleSelectionMode = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::PdmUiTreeSelectionQModel::showCheckBoxes( bool enable )
|
||||
{
|
||||
m_showCheckBoxes = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -403,6 +412,8 @@ QVariant caf::PdmUiTreeSelectionQModel::data( const QModelIndex& index, int role
|
||||
}
|
||||
else if ( role == Qt::CheckStateRole && !optionItemInfo->isHeading() )
|
||||
{
|
||||
if ( !m_showCheckBoxes ) return QVariant();
|
||||
|
||||
if ( m_uiFieldHandle && m_uiFieldHandle->uiField() )
|
||||
{
|
||||
// Avoid calling the seriously heavy uiValue method if we have a temporary valid cache.
|
||||
|
@ -66,6 +66,7 @@ public:
|
||||
void unselectAllItems();
|
||||
|
||||
void enableSingleSelectionMode( bool enable );
|
||||
void showCheckBoxes( bool enable );
|
||||
|
||||
int optionItemCount() const;
|
||||
void setOptions( caf::PdmUiFieldEditorHandle* field, const QList<caf::PdmOptionItemInfo>& options );
|
||||
@ -111,6 +112,7 @@ private:
|
||||
|
||||
bool m_singleSelectionMode;
|
||||
QModelIndex m_indexForLastUncheckedItem;
|
||||
bool m_showCheckBoxes;
|
||||
};
|
||||
|
||||
} // end namespace caf
|
||||
|
Loading…
Reference in New Issue
Block a user