Skip to content

Commit

Permalink
Migrate "Hidden" widgets to "Hidden" attribute table columns
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 11, 2016
1 parent 5a2ab50 commit ab7a07a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
29 changes: 25 additions & 4 deletions src/core/qgsattributetableconfig.cpp
Expand Up @@ -146,12 +146,33 @@ void QgsAttributeTableConfig::readXml( const QDomNode& node )

mColumns.append( column );
}
}

if ( configNode.toElement().attribute( "actionWidgetStyle" ) == "buttonList" )
mActionWidgetStyle = ButtonList;
if ( configNode.toElement().attribute( "actionWidgetStyle" ) == "buttonList" )
mActionWidgetStyle = ButtonList;
else
mActionWidgetStyle = DropDown;
}
else
mActionWidgetStyle = DropDown;
{
// Before QGIS 2.16 the attribute table would hide "Hidden" widgets.
// They are migrated to hidden columns here.
QDomNodeList editTypeNodes = node.namedItem( "edittypes" ).childNodes();

for ( int i = 0; i < editTypeNodes.size(); i++ )
{
QDomElement editTypeElement = editTypeNodes.at( i ).toElement();

if ( editTypeElement.attribute( "widgetv2type" ) == "Hidden" )
{
ColumnConfig column;

column.mName = editTypeElement.attribute( "name" );
column.mHidden = true;
column.mType = Field;
mColumns.append( column );
}
}
}
}

void QgsAttributeTableConfig::writeXml( QDomNode& node ) const
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -1862,6 +1862,8 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage

mEditFormConfig->readXml( node );

mAttributeTableConfig.readXml( node );

mConditionalStyles->readXml( node );

return true;
Expand Down Expand Up @@ -2064,6 +2066,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&

// add attribute actions
mActions->writeXML( node, doc );
mAttributeTableConfig.writeXml( node );
mEditFormConfig->writeXml( node );
mConditionalStyles->writeXml( node, doc );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/attributetable/qgsattributetablemodel.cpp
Expand Up @@ -314,7 +314,7 @@ void QgsAttributeTableModel::loadAttributes()
{
const QString widgetType = layer()->editFormConfig()->widgetType( idx );
QgsEditorWidgetFactory* widgetFactory = QgsEditorWidgetRegistry::instance()->factory( widgetType );
if ( widgetFactory && widgetType != "Hidden" )
if ( widgetFactory )
{
mWidgetFactories.append( widgetFactory );
mWidgetConfigs.append( layer()->editFormConfig()->widgetConfig( idx ) );
Expand Down

0 comments on commit ab7a07a

Please sign in to comment.