mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #8888 from OPM/8887-fix-reorder-capability
Fix reorder capability
This commit is contained in:
@@ -59,7 +59,7 @@ void RicEclipsePropertyFilterInsertExec::redo()
|
|||||||
RimEclipsePropertyFilterCollection* propertyFilterCollection = nullptr;
|
RimEclipsePropertyFilterCollection* propertyFilterCollection = nullptr;
|
||||||
m_propertyFilter->firstAncestorOrThisOfTypeAsserted( propertyFilterCollection );
|
m_propertyFilter->firstAncestorOrThisOfTypeAsserted( propertyFilterCollection );
|
||||||
|
|
||||||
size_t index = propertyFilterCollection->propertyFilters.index( m_propertyFilter );
|
size_t index = propertyFilterCollection->propertyFilters.indexOf( m_propertyFilter );
|
||||||
CVF_ASSERT( index < propertyFilterCollection->propertyFilters.size() );
|
CVF_ASSERT( index < propertyFilterCollection->propertyFilters.size() );
|
||||||
|
|
||||||
RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter( propertyFilterCollection, index );
|
RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter( propertyFilterCollection, index );
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ std::vector<RicCreateMultipleFracturesOptionItemUi*> RiuCreateMultipleFractionsU
|
|||||||
void RiuCreateMultipleFractionsUi::insertOptionItem( RicCreateMultipleFracturesOptionItemUi* insertAfterThisObject,
|
void RiuCreateMultipleFractionsUi::insertOptionItem( RicCreateMultipleFracturesOptionItemUi* insertAfterThisObject,
|
||||||
RicCreateMultipleFracturesOptionItemUi* objectToInsert )
|
RicCreateMultipleFracturesOptionItemUi* objectToInsert )
|
||||||
{
|
{
|
||||||
size_t index = m_options.index( insertAfterThisObject );
|
size_t index = m_options.indexOf( insertAfterThisObject );
|
||||||
if ( index < m_options.size() - 1 )
|
if ( index < m_options.size() - 1 )
|
||||||
{
|
{
|
||||||
m_options.insert( index + 1, objectToInsert );
|
m_options.insert( index + 1, objectToInsert );
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ void RicGeoMechPropertyFilterInsertExec::redo()
|
|||||||
RimGeoMechPropertyFilterCollection* propertyFilterCollection = m_propertyFilter->parentContainer();
|
RimGeoMechPropertyFilterCollection* propertyFilterCollection = m_propertyFilter->parentContainer();
|
||||||
CVF_ASSERT( propertyFilterCollection );
|
CVF_ASSERT( propertyFilterCollection );
|
||||||
|
|
||||||
size_t index = propertyFilterCollection->propertyFilters.index( m_propertyFilter );
|
size_t index = propertyFilterCollection->propertyFilters.indexOf( m_propertyFilter );
|
||||||
CVF_ASSERT( index < propertyFilterCollection->propertyFilters.size() );
|
CVF_ASSERT( index < propertyFilterCollection->propertyFilters.size() );
|
||||||
|
|
||||||
RicGeoMechPropertyFilterFeatureImpl::insertPropertyFilter( propertyFilterCollection, index );
|
RicGeoMechPropertyFilterFeatureImpl::insertPropertyFilter( propertyFilterCollection, index );
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ void RimUserDefinedPolylinesAnnotation::appendTarget( const cvf::Vec3d& defaultP
|
|||||||
void RimUserDefinedPolylinesAnnotation::insertTarget( const RimPolylineTarget* targetToInsertBefore,
|
void RimUserDefinedPolylinesAnnotation::insertTarget( const RimPolylineTarget* targetToInsertBefore,
|
||||||
RimPolylineTarget* targetToInsert )
|
RimPolylineTarget* targetToInsert )
|
||||||
{
|
{
|
||||||
size_t index = m_targets.index( targetToInsertBefore );
|
size_t index = m_targets.indexOf( targetToInsertBefore );
|
||||||
if ( index < m_targets.size() )
|
if ( index < m_targets.size() )
|
||||||
m_targets.insert( index, targetToInsert );
|
m_targets.insert( index, targetToInsert );
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ std::vector<RimPolylineTarget*> RimPolygonFilter::activeTargets() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert )
|
void RimPolygonFilter::insertTarget( const RimPolylineTarget* targetToInsertBefore, RimPolylineTarget* targetToInsert )
|
||||||
{
|
{
|
||||||
size_t index = m_targets.index( targetToInsertBefore );
|
size_t index = m_targets.indexOf( targetToInsertBefore );
|
||||||
if ( index < m_targets.size() )
|
if ( index < m_targets.size() )
|
||||||
m_targets.insert( index, targetToInsert );
|
m_targets.insert( index, targetToInsert );
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ QString RimFishbones::generatedName() const
|
|||||||
dynamic_cast<caf::PdmChildArrayField<RimFishbones*>*>( this->parentField() );
|
dynamic_cast<caf::PdmChildArrayField<RimFishbones*>*>( this->parentField() );
|
||||||
CVF_ASSERT( container );
|
CVF_ASSERT( container );
|
||||||
|
|
||||||
size_t index = container->index( this ) + 1;
|
size_t index = container->indexOf( this ) + 1;
|
||||||
return QString( "Fishbone %1" ).arg( index );
|
return QString( "Fishbone %1" ).arg( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ size_t RimDepthTrackPlot::plotCount() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
size_t RimDepthTrackPlot::plotIndex( const RimWellLogTrack* plot ) const
|
size_t RimDepthTrackPlot::plotIndex( const RimWellLogTrack* plot ) const
|
||||||
{
|
{
|
||||||
return m_plots.index( plot );
|
return m_plots.indexOf( plot );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ size_t RimMultiPlot::plotCount() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
size_t RimMultiPlot::plotIndex( const RimPlot* plot ) const
|
size_t RimMultiPlot::plotIndex( const RimPlot* plot ) const
|
||||||
{
|
{
|
||||||
return m_plots.index( plot );
|
return m_plots.indexOf( plot );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ std::vector<RimPressureTableItem*> RimPressureTable::items() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimPressureTable::insertItem( RimPressureTableItem* insertBefore, RimPressureTableItem* item )
|
void RimPressureTable::insertItem( RimPressureTableItem* insertBefore, RimPressureTableItem* item )
|
||||||
{
|
{
|
||||||
size_t index = m_pressureTableItems.index( insertBefore );
|
size_t index = m_pressureTableItems.indexOf( insertBefore );
|
||||||
item->changed.connect( this, &RimPressureTable::onTableChanged );
|
item->changed.connect( this, &RimPressureTable::onTableChanged );
|
||||||
if ( index < m_pressureTableItems.size() )
|
if ( index < m_pressureTableItems.size() )
|
||||||
m_pressureTableItems.insert( index, item );
|
m_pressureTableItems.insert( index, item );
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ void RimSurfaceCollection::deleteSubCollection( const QString& name )
|
|||||||
auto coll = getSubCollection( name );
|
auto coll = getSubCollection( name );
|
||||||
if ( coll )
|
if ( coll )
|
||||||
{
|
{
|
||||||
auto index = m_subCollections.index( coll );
|
auto index = m_subCollections.indexOf( coll );
|
||||||
m_subCollections.erase( index );
|
m_subCollections.erase( index );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1176,7 +1176,7 @@ void RimWellLogTrack::insertCurve( RimWellLogCurve* curve, size_t index )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimWellLogTrack::removeCurve( RimWellLogCurve* curve )
|
void RimWellLogTrack::removeCurve( RimWellLogCurve* curve )
|
||||||
{
|
{
|
||||||
size_t index = m_curves.index( curve );
|
size_t index = m_curves.indexOf( curve );
|
||||||
if ( index < m_curves.size() )
|
if ( index < m_curves.size() )
|
||||||
{
|
{
|
||||||
m_curves[index]->detach();
|
m_curves[index]->detach();
|
||||||
@@ -2014,7 +2014,7 @@ caf::PdmFieldHandle* RimWellLogTrack::userDescriptionField()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
size_t RimWellLogTrack::curveIndex( RimWellLogCurve* curve )
|
size_t RimWellLogTrack::curveIndex( RimWellLogCurve* curve )
|
||||||
{
|
{
|
||||||
return m_curves.index( curve );
|
return m_curves.indexOf( curve );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ bool RimWellMeasurementCollection::isEmpty() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimWellMeasurementCollection::insertMeasurement( RimWellMeasurement* insertBefore, RimWellMeasurement* measurement )
|
void RimWellMeasurementCollection::insertMeasurement( RimWellMeasurement* insertBefore, RimWellMeasurement* measurement )
|
||||||
{
|
{
|
||||||
size_t index = m_measurements.index( insertBefore );
|
size_t index = m_measurements.indexOf( insertBefore );
|
||||||
if ( index < m_measurements.size() )
|
if ( index < m_measurements.size() )
|
||||||
m_measurements.insert( index, measurement );
|
m_measurements.insert( index, measurement );
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ std::vector<RimWellPathAttribute*> RimWellPathAttributeCollection::attributes()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimWellPathAttributeCollection::insertAttribute( RimWellPathAttribute* insertBefore, RimWellPathAttribute* attribute )
|
void RimWellPathAttributeCollection::insertAttribute( RimWellPathAttribute* insertBefore, RimWellPathAttribute* attribute )
|
||||||
{
|
{
|
||||||
size_t index = m_attributes.index( insertBefore );
|
size_t index = m_attributes.indexOf( insertBefore );
|
||||||
if ( index < m_attributes.size() )
|
if ( index < m_attributes.size() )
|
||||||
m_attributes.insert( index, attribute );
|
m_attributes.insert( index, attribute );
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ std::pair<RimWellPathTarget*, RimWellPathTarget*>
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimWellPathGeometryDef::insertTarget( const RimWellPathTarget* targetToInsertBefore, RimWellPathTarget* targetToInsert )
|
void RimWellPathGeometryDef::insertTarget( const RimWellPathTarget* targetToInsertBefore, RimWellPathTarget* targetToInsert )
|
||||||
{
|
{
|
||||||
size_t index = m_wellTargets.index( targetToInsertBefore );
|
size_t index = m_wellTargets.indexOf( targetToInsertBefore );
|
||||||
if ( index < m_wellTargets.size() )
|
if ( index < m_wellTargets.size() )
|
||||||
m_wellTargets.insert( index, targetToInsert );
|
m_wellTargets.insert( index, targetToInsert );
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
void insertAt( int indexAfter, std::unique_ptr<PdmObjectHandle> obj );
|
void insertAt( int indexAfter, std::unique_ptr<PdmObjectHandle> obj );
|
||||||
PdmObjectHandle* at( size_t index ) override;
|
PdmObjectHandle* at( size_t index ) override;
|
||||||
void setValue( const std::vector<DataType*>& objects );
|
void setValue( const std::vector<DataType*>& objects );
|
||||||
|
size_t indexOf( const PdmObjectHandle* obj ) const override;
|
||||||
|
|
||||||
virtual void deleteAllChildObjectsAsync();
|
virtual void deleteAllChildObjectsAsync();
|
||||||
|
|
||||||
@@ -85,8 +86,7 @@ public:
|
|||||||
void insert( size_t indexAfter, const std::vector<PdmPointer<DataType>>& objects );
|
void insert( size_t indexAfter, const std::vector<PdmPointer<DataType>>& objects );
|
||||||
size_t count( const DataType* pointer ) const;
|
size_t count( const DataType* pointer ) const;
|
||||||
|
|
||||||
void erase( size_t index ) override;
|
void erase( size_t index ) override;
|
||||||
size_t index( const DataType* pointer ) const;
|
|
||||||
|
|
||||||
typename std::vector<PdmPointer<DataType>>::iterator begin() { return m_pointers.begin(); };
|
typename std::vector<PdmPointer<DataType>>::iterator begin() { return m_pointers.begin(); };
|
||||||
typename std::vector<PdmPointer<DataType>>::iterator end() { return m_pointers.end(); };
|
typename std::vector<PdmPointer<DataType>>::iterator end() { return m_pointers.end(); };
|
||||||
|
|||||||
@@ -138,6 +138,23 @@ size_t PdmChildArrayField<DataType*>::count( const DataType* pointer ) const
|
|||||||
return itemCount;
|
return itemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
template <typename DataType>
|
||||||
|
size_t PdmChildArrayField<DataType*>::indexOf( const PdmObjectHandle* obj ) const
|
||||||
|
{
|
||||||
|
for ( size_t i = 0; i < m_pointers.size(); ++i )
|
||||||
|
{
|
||||||
|
if ( obj == m_pointers[i].rawPtr() )
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( size_t )( -1 ); // Undefined size_t > m_pointers.size();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Empty the container without deleting the objects pointed to.
|
/// Empty the container without deleting the objects pointed to.
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -196,23 +213,6 @@ void PdmChildArrayField<DataType*>::erase( size_t index )
|
|||||||
m_pointers.erase( m_pointers.begin() + index );
|
m_pointers.erase( m_pointers.begin() + index );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
/// Get the index of the given object pointer
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
template <typename DataType>
|
|
||||||
size_t PdmChildArrayField<DataType*>::index( const DataType* pointer ) const
|
|
||||||
{
|
|
||||||
for ( size_t i = 0; i < m_pointers.size(); ++i )
|
|
||||||
{
|
|
||||||
if ( pointer == m_pointers[i].p() )
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( size_t )( -1 ); // Undefined size_t > m_pointers.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Assign objects to the field, replacing the current child objects
|
/// Assign objects to the field, replacing the current child objects
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -189,3 +189,11 @@ PdmFieldReorderCapability* PdmFieldReorderCapability::reorderCapabilityOfParentC
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
size_t PdmFieldReorderCapability::indexOf( PdmObjectHandle* pdmObject )
|
||||||
|
{
|
||||||
|
return m_field->indexOf( pdmObject );
|
||||||
|
}
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
PdmFieldReorderCapability( PdmPtrArrayFieldHandle* field, bool giveOwnership );
|
PdmFieldReorderCapability( PdmPtrArrayFieldHandle* field, bool giveOwnership );
|
||||||
|
|
||||||
|
size_t indexOf( PdmObjectHandle* pdmObject );
|
||||||
|
|
||||||
bool canItemBeMovedUp( size_t index ) const;
|
bool canItemBeMovedUp( size_t index ) const;
|
||||||
bool canItemBeMovedDown( size_t index ) const;
|
bool canItemBeMovedDown( size_t index ) const;
|
||||||
|
|
||||||
|
|||||||
@@ -50,11 +50,12 @@ public:
|
|||||||
|
|
||||||
// Reimplementation of PdmPointersFieldHandle methods
|
// Reimplementation of PdmPointersFieldHandle methods
|
||||||
|
|
||||||
virtual size_t size() const { return m_pointers.size(); }
|
size_t size() const override { return m_pointers.size(); }
|
||||||
virtual bool empty() const { return m_pointers.empty(); }
|
bool empty() const override { return m_pointers.empty(); }
|
||||||
virtual void clear();
|
void clear() override;
|
||||||
virtual void insertAt( int indexAfter, PdmObjectHandle* obj );
|
void insertAt( int indexAfter, PdmObjectHandle* obj ) override;
|
||||||
virtual PdmObjectHandle* at( size_t index );
|
PdmObjectHandle* at( size_t index ) override;
|
||||||
|
size_t indexOf( const PdmObjectHandle* obj ) const override;
|
||||||
|
|
||||||
// std::vector-like access
|
// std::vector-like access
|
||||||
|
|
||||||
@@ -66,9 +67,8 @@ public:
|
|||||||
void insert( size_t indexAfter, const std::vector<PdmPointer<DataType>>& objects );
|
void insert( size_t indexAfter, const std::vector<PdmPointer<DataType>>& objects );
|
||||||
size_t count( const DataType* pointer ) const;
|
size_t count( const DataType* pointer ) const;
|
||||||
|
|
||||||
void erase( size_t index );
|
void erase( size_t index ) override;
|
||||||
size_t index( DataType* pointer );
|
void removePtr( PdmObjectHandle* object );
|
||||||
void removePtr( PdmObjectHandle* object );
|
|
||||||
|
|
||||||
typename std::vector<PdmPointer<DataType>>::iterator begin() { return m_pointers.begin(); };
|
typename std::vector<PdmPointer<DataType>>::iterator begin() { return m_pointers.begin(); };
|
||||||
typename std::vector<PdmPointer<DataType>>::iterator end() { return m_pointers.end(); };
|
typename std::vector<PdmPointer<DataType>>::iterator end() { return m_pointers.end(); };
|
||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
std::vector<DataType*> ptrReferencedObjects() const;
|
std::vector<DataType*> ptrReferencedObjects() const;
|
||||||
|
|
||||||
// Child objects
|
// Child objects
|
||||||
virtual void ptrReferencedObjects( std::vector<PdmObjectHandle*>* );
|
void ptrReferencedObjects( std::vector<PdmObjectHandle*>* ) override;
|
||||||
|
|
||||||
private: // To be disabled
|
private: // To be disabled
|
||||||
PDM_DISABLE_COPY_AND_ASSIGN( PdmPtrArrayField );
|
PDM_DISABLE_COPY_AND_ASSIGN( PdmPtrArrayField );
|
||||||
|
|||||||
@@ -140,6 +140,23 @@ size_t PdmPtrArrayField<DataType*>::count( const DataType* pointer ) const
|
|||||||
return itemCount;
|
return itemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
template <typename DataType>
|
||||||
|
size_t PdmPtrArrayField<DataType*>::indexOf( const PdmObjectHandle* obj ) const
|
||||||
|
{
|
||||||
|
for ( size_t i = 0; i < m_pointers.size(); ++i )
|
||||||
|
{
|
||||||
|
if ( obj == m_pointers[i].rawPtr() )
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( size_t )( -1 ); // Undefined size_t > m_pointers.size();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Empty the container without deleting the objects pointed to.
|
/// Empty the container without deleting the objects pointed to.
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -170,23 +187,6 @@ void PdmPtrArrayField<DataType*>::erase( size_t index )
|
|||||||
m_pointers.erase( m_pointers.begin() + index );
|
m_pointers.erase( m_pointers.begin() + index );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
/// Get the index of the given object pointer
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
template <typename DataType>
|
|
||||||
size_t PdmPtrArrayField<DataType*>::index( DataType* pointer )
|
|
||||||
{
|
|
||||||
for ( size_t i = 0; i < m_pointers.size(); ++i )
|
|
||||||
{
|
|
||||||
if ( pointer == m_pointers[i].p() )
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( size_t )( -1 ); // Undefined size_t > m_pointers.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Removes all instances of object pointer from the container without deleting the object.
|
/// Removes all instances of object pointer from the container without deleting the object.
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
virtual void insertAt( int indexAfter, PdmObjectHandle* obj ) = 0;
|
virtual void insertAt( int indexAfter, PdmObjectHandle* obj ) = 0;
|
||||||
virtual void erase( size_t index ) = 0;
|
virtual void erase( size_t index ) = 0;
|
||||||
|
virtual size_t indexOf( const PdmObjectHandle* obj ) const = 0;
|
||||||
|
|
||||||
virtual PdmObjectHandle* at( size_t index ) = 0;
|
virtual PdmObjectHandle* at( size_t index ) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -605,12 +605,12 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& subRo
|
|||||||
|
|
||||||
if ( reorderability && filterIndex.row() >= 0 && selection.size() == 1u && selection.front() == uiItem )
|
if ( reorderability && filterIndex.row() >= 0 && selection.size() == 1u && selection.front() == uiItem )
|
||||||
{
|
{
|
||||||
size_t indexInParent = static_cast<size_t>( filterIndex.row() );
|
size_t indexInParentField = reorderability->indexOf( pdmObject );
|
||||||
{
|
{
|
||||||
auto tag = PdmUiTreeViewItemAttribute::Tag::create();
|
auto tag = PdmUiTreeViewItemAttribute::Tag::create();
|
||||||
tag->icon = caf::IconProvider( ":/caf/Up16x16.png" );
|
tag->icon = caf::IconProvider( ":/caf/Up16x16.png" );
|
||||||
tag->selectedOnly = true;
|
tag->selectedOnly = true;
|
||||||
if ( reorderability->canItemBeMovedUp( indexInParent ) )
|
if ( reorderability->canItemBeMovedUp( indexInParentField ) )
|
||||||
{
|
{
|
||||||
tag->clicked.connect( reorderability, &PdmFieldReorderCapability::onMoveItemUp );
|
tag->clicked.connect( reorderability, &PdmFieldReorderCapability::onMoveItemUp );
|
||||||
}
|
}
|
||||||
@@ -625,7 +625,7 @@ void PdmUiTreeViewEditor::updateItemDelegateForSubTree( const QModelIndex& subRo
|
|||||||
auto tag = PdmUiTreeViewItemAttribute::Tag::create();
|
auto tag = PdmUiTreeViewItemAttribute::Tag::create();
|
||||||
tag->icon = IconProvider( ":/caf/Down16x16.png" );
|
tag->icon = IconProvider( ":/caf/Down16x16.png" );
|
||||||
tag->selectedOnly = true;
|
tag->selectedOnly = true;
|
||||||
if ( reorderability->canItemBeMovedDown( indexInParent ) )
|
if ( reorderability->canItemBeMovedDown( indexInParentField ) )
|
||||||
{
|
{
|
||||||
tag->clicked.connect( reorderability, &PdmFieldReorderCapability::onMoveItemDown );
|
tag->clicked.connect( reorderability, &PdmFieldReorderCapability::onMoveItemDown );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,22 +268,34 @@ bool PdmUiTreeViewItemDelegate::editorEvent( QEvent* event,
|
|||||||
{
|
{
|
||||||
if ( event->type() == QEvent::MouseButtonPress )
|
if ( event->type() == QEvent::MouseButtonPress )
|
||||||
{
|
{
|
||||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( event );
|
auto* mouseEvent = static_cast<QMouseEvent*>( event );
|
||||||
|
|
||||||
if ( mouseEvent->button() == Qt::LeftButton && mouseEvent->modifiers() == Qt::NoModifier )
|
if ( mouseEvent->button() == Qt::LeftButton && mouseEvent->modifiers() == Qt::NoModifier )
|
||||||
{
|
{
|
||||||
const PdmUiTreeViewItemAttribute::Tag* tag;
|
const PdmUiTreeViewItemAttribute::Tag* tag;
|
||||||
if ( tagClicked( mouseEvent->pos(), option.rect, itemIndex, &tag ) )
|
if ( tagClicked( mouseEvent->pos(), option.rect, itemIndex, &tag ) )
|
||||||
{
|
{
|
||||||
QModelIndex parentIndex = itemIndex.parent();
|
auto uiItem = m_treeView->uiItemFromModelIndex( itemIndex );
|
||||||
|
|
||||||
auto uiItem = m_treeView->uiItemFromModelIndex( itemIndex );
|
auto* uiObjectHandle = dynamic_cast<PdmUiObjectHandle*>( uiItem );
|
||||||
|
if ( uiObjectHandle )
|
||||||
|
{
|
||||||
|
PdmObjectHandle* pdmObject = uiObjectHandle->objectHandle();
|
||||||
|
if ( pdmObject )
|
||||||
|
{
|
||||||
|
PdmFieldReorderCapability* reorderability =
|
||||||
|
PdmFieldReorderCapability::reorderCapabilityOfParentContainer( pdmObject );
|
||||||
|
|
||||||
|
size_t indexInParent = reorderability->indexOf( pdmObject );
|
||||||
|
tag->clicked.send( indexInParent );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto parentIndex = itemIndex.parent();
|
||||||
auto parentUiItem = m_treeView->uiItemFromModelIndex( parentIndex );
|
auto parentUiItem = m_treeView->uiItemFromModelIndex( parentIndex );
|
||||||
|
|
||||||
tag->clicked.send( (size_t)itemIndex.row() );
|
|
||||||
|
|
||||||
m_treeView->updateSubTree( parentUiItem );
|
m_treeView->updateSubTree( parentUiItem );
|
||||||
m_treeView->selectAsCurrentItem( uiItem );
|
m_treeView->selectAsCurrentItem( uiItem );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user