Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix saving field configurations
  • Loading branch information
m-kuhn committed Aug 31, 2016
1 parent a9464d7 commit 504badb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions src/app/qgsfieldsproperties.cpp
Expand Up @@ -935,19 +935,21 @@ void QgsFieldsProperties::apply()
{
QSet<QString> excludeAttributesWMS, excludeAttributesWFS;

QgsEditFormConfig editFormConfig = mLayer->editFormConfig();

for ( int i = 0; i < mFieldsList->rowCount(); i++ )
{
int idx = mFieldsList->item( i, attrIdCol )->text().toInt();
FieldConfig cfg = configForRow( i );

mLayer->editFormConfig().setReadOnly( i, !cfg.mEditable );
mLayer->editFormConfig().setLabelOnTop( i, cfg.mLabelOnTop );
mLayer->editFormConfig().setNotNull( i, cfg.mNotNull );
mLayer->editFormConfig().setExpressionDescription( i, cfg.mConstraintDescription );
mLayer->editFormConfig().setExpression( i, cfg.mConstraint );
editFormConfig.setReadOnly( i, !cfg.mEditable );
editFormConfig.setLabelOnTop( i, cfg.mLabelOnTop );
editFormConfig.setNotNull( i, cfg.mNotNull );
editFormConfig.setExpressionDescription( i, cfg.mConstraintDescription );
editFormConfig.setExpression( i, cfg.mConstraint );

mLayer->editFormConfig().setWidgetType( idx, cfg.mEditorWidgetType );
mLayer->editFormConfig().setWidgetConfig( idx, cfg.mEditorWidgetConfig );
editFormConfig.setWidgetType( idx, cfg.mEditorWidgetType );
editFormConfig.setWidgetConfig( idx, cfg.mEditorWidgetConfig );

if ( mFieldsList->item( i, attrWMSCol )->checkState() == Qt::Unchecked )
{
Expand All @@ -960,7 +962,6 @@ void QgsFieldsProperties::apply()
}

// tabs and groups
QgsEditFormConfig editFormConfig = mLayer->editFormConfig();
editFormConfig.clearTabs();
for ( int t = 0; t < mDesignerTree->invisibleRootItem()->childCount(); t++ )
{
Expand All @@ -969,9 +970,8 @@ void QgsFieldsProperties::apply()
editFormConfig.addTab( createAttributeEditorWidget( tabItem, nullptr, false ) );
}

editFormConfig.setUiForm( mEditFormLineEdit->text() );
editFormConfig.setLayout(( QgsEditFormConfig::EditorLayout ) mEditorLayoutComboBox->currentIndex() );
if ( mEditorLayoutComboBox->currentIndex() == QgsEditFormConfig::UiFileLayout )
editFormConfig.setUiForm( mEditFormLineEdit->text() );

// Init function configuration
editFormConfig.setInitFunction( mInitFunctionLineEdit->text() );
Expand Down
7 changes: 5 additions & 2 deletions src/core/qgseditformconfig.cpp
Expand Up @@ -172,6 +172,9 @@ void QgsEditFormConfig::setLayout( QgsEditFormConfig::EditorLayout editorLayout
{
d.detach();
d->mEditorLayout = editorLayout;

if ( editorLayout == TabLayout )
d->mConfiguredRootContainer = true;
}

QString QgsEditFormConfig::uiForm() const
Expand Down Expand Up @@ -536,9 +539,9 @@ void QgsEditFormConfig::writeXml( QDomNode& node ) const
QDomElement rootElem = d->mInvisibleRootContainer->toDomElement( doc );
QDomNodeList elemList = rootElem.childNodes();

for ( int i = 0; i < elemList.size(); ++i )
while ( !elemList.isEmpty() )
{
tabsElem.appendChild( elemList.at( i ) );
tabsElem.appendChild( elemList.at( 0 ) );
}

node.appendChild( tabsElem );
Expand Down
3 changes: 0 additions & 3 deletions src/core/qgseditformconfig_p.h
Expand Up @@ -60,9 +60,6 @@ class QgsEditFormConfigPrivate : public QSharedData
/** This flag is set if the root container was configured by the user */
bool mConfiguredRootContainer;

/** Map that stores the tab for attributes in the edit form. Key is the tab order and value the tab name*/
QList< QgsEditFormConfig::TabData > mTabs;

QMap< QString, QString> mConstraints;
QMap< QString, QString> mConstraintsDescription;
QMap< QString, bool> mFieldEditables;
Expand Down

0 comments on commit 504badb

Please sign in to comment.