Skip to content
Permalink
Browse files

Fix saving field configurations

  • Loading branch information
m-kuhn committed Aug 31, 2016
1 parent a9464d7 commit 504badb41f5c5df8273a93a41977fc1a6b3db137
Showing with 15 additions and 15 deletions.
  1. +10 −10 src/app/qgsfieldsproperties.cpp
  2. +5 −2 src/core/qgseditformconfig.cpp
  3. +0 −3 src/core/qgseditformconfig_p.h
@@ -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 )
{
@@ -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++ )
{
@@ -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() );
@@ -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
@@ -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 );
@@ -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;

0 comments on commit 504badb

Please sign in to comment.
You can’t perform that action at this time.