Skip to content
Permalink
Browse files

attribute editor layout selection etc.

  • Loading branch information
signedav committed Nov 2, 2017
1 parent 90546b0 commit c3716474a1348a2ecdc6ed1e9ce913614c7a3661
@@ -45,7 +45,7 @@ class APP_EXPORT QgsAttributeRelationEdit: public QWidget, private Ui::QgsAttrib
/**
* Setter for combo cardinality item
*/
void setCardinalityCombo( const QString &cardinalityComboItem, const QVariant &auserData = QVariant() );
void setCardinalityCombo( const QString &cardinalityComboItem, const QVariant &auserData = QVariant() );

/**
* Setter for combo cardinality
@@ -44,6 +44,8 @@ QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer,
connect( mAvailableWidgetsTree, &QTreeWidget::itemSelectionChanged, this, &QgsAttributesFormProperties::onAttributeSelectionChanged );
connect( mAddTabOrGroupButton, &QAbstractButton::clicked, this, &QgsAttributesFormProperties::addTabOrGroupButton );
connect( mRemoveTabOrGroupButton, &QAbstractButton::clicked, this, &QgsAttributesFormProperties::removeTabOrGroupButton );
connect( mEditorLayoutComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged );
connect( pbnSelectEditForm, &QToolButton::clicked, this, &QgsAttributesFormProperties::pbnSelectEditForm_clicked );
}


@@ -57,6 +59,12 @@ void QgsAttributesFormProperties::init()
initAvailableWidgetsTree();
initFormLayoutTree();

mEditorLayoutComboBox->setCurrentIndex( mLayer->editFormConfig().layout() );
mEditorLayoutComboBox_currentIndexChanged( mEditorLayoutComboBox->currentIndex() );

QgsEditFormConfig cfg = mLayer->editFormConfig();
mEditFormLineEdit->setText( cfg.uiForm() );

mAttributeTypeDialog->setEnabled( false );
mAttributeRelationEdit->setEnabled( false );
}
@@ -118,7 +126,8 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
}


void QgsAttributesFormProperties::storeAttributeTypeDialog(){
void QgsAttributesFormProperties::storeAttributeTypeDialog()
{
FieldConfig cfg;

cfg.mEditable = mAttributeTypeDialog->fieldEditable();
@@ -201,7 +210,7 @@ void QgsAttributesFormProperties::loadAttributeRelationEdit()
Q_FOREACH ( const QgsRelation &nmrel, QgsProject::instance()->relationManager()->referencingRelations( relation.referencingLayer() ) )
{
if ( nmrel.fieldPairs().at( 0 ).referencingField() != relation.fieldPairs().at( 0 ).referencingField() )
mAttributeRelationEdit->setCardinalityCombo( QStringLiteral( "%1 (%2)" ).arg( nmrel.referencedLayer()->name(), nmrel.fieldPairs().at( 0 ).referencedField() ), nmrel.id() );
mAttributeRelationEdit->setCardinalityCombo( QStringLiteral( "%1 (%2)" ).arg( nmrel.referencedLayer()->name(), nmrel.fieldPairs().at( 0 ).referencedField() ), nmrel.id() );
}

mAttributeRelationEdit->setCardinality( cfg.mCardinality );
@@ -353,13 +362,13 @@ void QgsAttributesFormProperties::onAttributeSelectionChanged()
{
case DnDTreeItemData::Relation:
{
mAttributeTypeDialog->setEnabled( false );
mAttributeTypeDialog->setVisible( false );
loadAttributeRelationEdit();
break;
}
case DnDTreeItemData::Field:
{
mAttributeRelationEdit->setEnabled( false );
mAttributeRelationEdit->setVisible( false );
loadAttributeTypeDialog();
break;
}
@@ -506,6 +515,40 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid
return widgetDef;
}

void QgsAttributesFormProperties::mEditorLayoutComboBox_currentIndexChanged( int index )
{
switch ( index )
{
case 0:
mFormLayoutWidget->setVisible( false );
mUiFileFrame->setVisible( false );
break;

case 1:
mFormLayoutWidget->setVisible( true );
mUiFileFrame->setVisible( false );
break;

case 2:
mFormLayoutWidget->setVisible( false );
mUiFileFrame->setVisible( true );
break;
}
}

void QgsAttributesFormProperties::pbnSelectEditForm_clicked()
{
QgsSettings myQSettings;
QString lastUsedDir = myQSettings.value( QStringLiteral( "style/lastUIDir" ), QDir::homePath() ).toString();
QString uifilename = QFileDialog::getOpenFileName( this, tr( "Select edit form" ), lastUsedDir, tr( "UI file" ) + " (*.ui)" );

if ( uifilename.isNull() )
return;

QFileInfo fi( uifilename );
myQSettings.setValue( QStringLiteral( "style/lastUIDir" ), fi.path() );
mEditFormLineEdit->setText( uifilename );
}

void QgsAttributesFormProperties::apply()
{
@@ -570,10 +613,11 @@ void QgsAttributesFormProperties::apply()
editFormConfig.addTab( createAttributeEditorWidget( tabItem, nullptr, false ) );
}

/*
editFormConfig.setUiForm( mEditFormLineEdit->text() );

editFormConfig.setLayout( ( QgsEditFormConfig::EditorLayout ) mEditorLayoutComboBox->currentIndex() );

/*
// Init function configuration
editFormConfig.setInitFunction( mInitFunctionLineEdit->text() );
editFormConfig.setInitCode( mInitCodeEditorPython->text() );
@@ -218,6 +218,8 @@ class APP_EXPORT QgsAttributesFormProperties : public QWidget, private Ui_QgsAtt
private slots:
void addTabOrGroupButton();
void removeTabOrGroupButton();
void mEditorLayoutComboBox_currentIndexChanged( int index );
void pbnSelectEditForm_clicked();
};


@@ -61,10 +61,6 @@ QgsSourceFieldsProperties::~QgsSourceFieldsProperties()
void QgsSourceFieldsProperties::init()
{
loadRows();

//not used here: mEditorLayoutComboBox->setCurrentIndex( mLayer->editFormConfig().layout() );
//used here????? mFormSuppressCmbBx->setCurrentIndex( mLayer->editFormConfig().suppress() );
//not used here: loadAttributeEditorTree();
}

void QgsSourceFieldsProperties::loadRows()
@@ -6,27 +6,53 @@
<rect>
<x>0</x>
<y>0</y>
<width>625</width>
<height>359</height>
<width>653</width>
<height>556</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QWidget" name="widget_2" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Attribute editor layout</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mEditorLayoutComboBox">
<item>
<property name="text">
<string>Autogenerate</string>
</property>
</item>
<item>
<property name="text">
<string>Drag and drop designer</string>
</property>
</item>
<item>
<property name="text">
<string>Provide ui-file</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -45,7 +71,9 @@
</widget>
</item>
<item row="0" column="1" rowspan="6">
<widget class="QWidget" name="mFormLayoutWidget" native="true"/>
<widget class="QWidget" name="mFormLayoutWidget" native="true">
<zorder>pushButton</zorder>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="mRemoveTabOrGroupButton">
@@ -81,6 +109,35 @@
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="mUiFileFrame" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Edit UI</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mEditFormLineEdit"/>
</item>
<item>
<widget class="QToolButton" name="pbnSelectEditForm">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>

0 comments on commit c371647

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