mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-11 00:09:04 -05:00
Hide auxiliary columns which can be edited by "change label properties" map tool
This commit is contained in:
parent
ce2436dc4a
commit
821aadc400
@ -179,6 +179,15 @@ class QgsAuxiliaryLayer : QgsVectorLayer
|
|||||||
:rtype: bool
|
:rtype: bool
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
bool isHiddenProperty( int index ) const;
|
||||||
|
%Docstring
|
||||||
|
Returns true if the underlying field have to be hidden from editing
|
||||||
|
tools like attribute table, false otherwise.
|
||||||
|
|
||||||
|
\param index The index of the field for which visibility is checked
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
static int createProperty( QgsPalLayerSettings::Property property, const QString &providerId, QgsVectorLayer *vlayer );
|
static int createProperty( QgsPalLayerSettings::Property property, const QString &providerId, QgsVectorLayer *vlayer );
|
||||||
%Docstring
|
%Docstring
|
||||||
Create if necessary a new auxiliary field for a PAL property and
|
Create if necessary a new auxiliary field for a PAL property and
|
||||||
|
|||||||
@ -1125,7 +1125,7 @@ Returns true if the provider has been modified since the last commit
|
|||||||
:rtype: bool
|
:rtype: bool
|
||||||
%End
|
%End
|
||||||
|
|
||||||
bool isAuxiliaryField( int index ) const;
|
bool isAuxiliaryField( int index, int &srcIndex ) const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns true if the field comes from the auxiliary layer,
|
Returns true if the field comes from the auxiliary layer,
|
||||||
false otherwise.
|
false otherwise.
|
||||||
|
|||||||
@ -30,6 +30,31 @@ const QString AS_JOINFIELD = "ASPK";
|
|||||||
const QString AS_EXTENSION = "qgd";
|
const QString AS_EXTENSION = "qgd";
|
||||||
const QString AS_JOINPREFIX = "auxiliary_storage_";
|
const QString AS_JOINPREFIX = "auxiliary_storage_";
|
||||||
|
|
||||||
|
const QVector<QgsPalLayerSettings::Property> palHiddenProperties
|
||||||
|
{
|
||||||
|
QgsPalLayerSettings::PositionX,
|
||||||
|
QgsPalLayerSettings::PositionY,
|
||||||
|
QgsPalLayerSettings::Show,
|
||||||
|
QgsPalLayerSettings::LabelRotation,
|
||||||
|
QgsPalLayerSettings::Family,
|
||||||
|
QgsPalLayerSettings::FontStyle,
|
||||||
|
QgsPalLayerSettings::Size,
|
||||||
|
QgsPalLayerSettings::Bold,
|
||||||
|
QgsPalLayerSettings::Italic,
|
||||||
|
QgsPalLayerSettings::Underline,
|
||||||
|
QgsPalLayerSettings::Color,
|
||||||
|
QgsPalLayerSettings::Strikeout,
|
||||||
|
QgsPalLayerSettings::BufferSize,
|
||||||
|
QgsPalLayerSettings::BufferColor,
|
||||||
|
QgsPalLayerSettings::LabelDistance,
|
||||||
|
QgsPalLayerSettings::Hali,
|
||||||
|
QgsPalLayerSettings::Vali,
|
||||||
|
QgsPalLayerSettings::ScaleVisibility,
|
||||||
|
QgsPalLayerSettings::MinScale,
|
||||||
|
QgsPalLayerSettings::MaxScale,
|
||||||
|
QgsPalLayerSettings::AlwaysShow
|
||||||
|
};
|
||||||
|
|
||||||
QgsAuxiliaryField::QgsAuxiliaryField( const QgsPropertyDefinition &def )
|
QgsAuxiliaryField::QgsAuxiliaryField( const QgsPropertyDefinition &def )
|
||||||
: QgsField()
|
: QgsField()
|
||||||
, mPropertyDefinition( def )
|
, mPropertyDefinition( def )
|
||||||
@ -310,6 +335,29 @@ int QgsAuxiliaryLayer::createProperty( QgsDiagramLayerSettings::Property propert
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QgsAuxiliaryLayer::isHiddenProperty( int index ) const
|
||||||
|
{
|
||||||
|
bool hidden = false;
|
||||||
|
|
||||||
|
QgsAuxiliaryField aField( fields().field( index ) );
|
||||||
|
QgsPropertyDefinition def = aField.propertyDefinition();
|
||||||
|
|
||||||
|
if ( def.origin().compare( "labeling" ) == 0 )
|
||||||
|
{
|
||||||
|
Q_FOREACH ( const QgsPalLayerSettings::Property &p, palHiddenProperties )
|
||||||
|
{
|
||||||
|
const QString propName = QgsPalLayerSettings::propertyDefinitions()[ p ].name();
|
||||||
|
if ( propName.compare( def.name() ) == 0 )
|
||||||
|
{
|
||||||
|
hidden = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hidden;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// QgsAuxiliaryStorage
|
// QgsAuxiliaryStorage
|
||||||
//
|
//
|
||||||
|
|||||||
@ -199,6 +199,14 @@ class CORE_EXPORT QgsAuxiliaryLayer : public QgsVectorLayer
|
|||||||
*/
|
*/
|
||||||
virtual bool deleteAttribute( int attr ) override;
|
virtual bool deleteAttribute( int attr ) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the underlying field have to be hidden from editing
|
||||||
|
* tools like attribute table, false otherwise.
|
||||||
|
*
|
||||||
|
* \param index The index of the field for which visibility is checked
|
||||||
|
*/
|
||||||
|
bool isHiddenProperty( int index ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create if necessary a new auxiliary field for a PAL property and
|
* Create if necessary a new auxiliary field for a PAL property and
|
||||||
* activate this property in settings.
|
* activate this property in settings.
|
||||||
|
|||||||
@ -2834,17 +2834,17 @@ bool QgsVectorLayer::isModified() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool QgsVectorLayer::isAuxiliaryField( int index ) const
|
bool QgsVectorLayer::isAuxiliaryField( int index, int &srcIndex ) const
|
||||||
{
|
{
|
||||||
bool auxiliaryField = false;
|
bool auxiliaryField = false;
|
||||||
|
srcIndex = -1;
|
||||||
|
|
||||||
if ( !auxiliaryLayer() )
|
if ( !auxiliaryLayer() )
|
||||||
return auxiliaryField;
|
return auxiliaryField;
|
||||||
|
|
||||||
if ( index >= 0 && fields().fieldOrigin( index ) == QgsFields::OriginJoin )
|
if ( index >= 0 && fields().fieldOrigin( index ) == QgsFields::OriginJoin )
|
||||||
{
|
{
|
||||||
int srcFieldIndex;
|
const QgsVectorLayerJoinInfo *info = mJoinBuffer->joinForFieldIndex( index, fields(), srcIndex );
|
||||||
const QgsVectorLayerJoinInfo *info = mJoinBuffer->joinForFieldIndex( index, fields(), srcFieldIndex );
|
|
||||||
|
|
||||||
if ( info && info->joinLayerId() == auxiliaryLayer()->id() )
|
if ( info && info->joinLayerId() == auxiliaryLayer()->id() )
|
||||||
auxiliaryField = true;
|
auxiliaryField = true;
|
||||||
@ -3073,6 +3073,31 @@ void QgsVectorLayer::updateFields()
|
|||||||
mFields[index].setEditorWidgetSetup( fieldWidgetIterator.value() );
|
mFields[index].setEditorWidgetSetup( fieldWidgetIterator.value() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update attribute table config
|
||||||
|
mAttributeTableConfig.update( fields() );
|
||||||
|
|
||||||
|
if ( auxiliaryLayer() )
|
||||||
|
{
|
||||||
|
QVector<QgsAttributeTableConfig::ColumnConfig> columns = mAttributeTableConfig.columns();
|
||||||
|
|
||||||
|
QVector<QgsAttributeTableConfig::ColumnConfig>::iterator it;
|
||||||
|
for ( it = columns.begin(); it != columns.end(); ++it )
|
||||||
|
{
|
||||||
|
int idx = fields().lookupField( it->name );
|
||||||
|
if ( idx >= 0 )
|
||||||
|
{
|
||||||
|
int srcIdx = -1;
|
||||||
|
if ( !isAuxiliaryField( idx, srcIdx ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( auxiliaryLayer()->isHiddenProperty( srcIdx ) )
|
||||||
|
it->hidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mAttributeTableConfig.setColumns( columns );
|
||||||
|
}
|
||||||
|
|
||||||
if ( oldFields != mFields )
|
if ( oldFields != mFields )
|
||||||
{
|
{
|
||||||
emit updatedFields();
|
emit updatedFields();
|
||||||
|
|||||||
@ -1166,7 +1166,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
|||||||
*
|
*
|
||||||
* \since QGIS 3.0
|
* \since QGIS 3.0
|
||||||
*/
|
*/
|
||||||
bool isAuxiliaryField( int index ) const;
|
bool isAuxiliaryField( int index, int &srcIndex ) const;
|
||||||
|
|
||||||
//! Synchronises with changes in the datasource
|
//! Synchronises with changes in the datasource
|
||||||
virtual void reload() override;
|
virtual void reload() override;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user