Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Nov 4, 2015
1 parent 8c86aab commit 842753e
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/app/qgsfieldsproperties.cpp
Expand Up @@ -843,6 +843,8 @@ void QgsFieldsProperties::apply()
if ( mEditorLayoutComboBox->currentIndex() == QgsVectorLayer::UiFileLayout )
mLayer->setEditForm( leEditForm->text() );
mLayer->setEditFormInit( leEditFormInit->text() );
mLayer->setEditFormInitUseCode( leEditFormInitUseCode->isChecked() );
// TODO: mLayer->setEditFormInitCode( leEditFormInitCode->text() );
mLayer->setFeatureFormSuppress(( QgsVectorLayer::FeatureFormSuppress )mFormSuppressCmbBx->currentIndex() );

mLayer->setExcludeAttributesWMS( excludeAttributesWMS );
Expand Down
35 changes: 35 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -1781,6 +1781,18 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
mEditFormInit = editFormInitNode.toElement().text();
}

QDomNode editFormInitCodeNode = node.namedItem( "editforminitcode" );
if ( !editFormInitCodeNode.isNull() )
{
mEditFormInitCode = editFormInitCodeNode.toElement().text();
}

QDomNode editFormInitUseCodeNode = node.namedItem( "editforminitusecode" );
if ( !editFormInitCodeNode.isNull() )
{
mEditFormInitUseCode = (bool) editFormInitUseCodeNode.toElement().text().toInt();
}

QDomNode fFSuppNode = node.namedItem( "featformsuppress" );
if ( fFSuppNode.isNull() )
{
Expand Down Expand Up @@ -2043,6 +2055,14 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
efiField.appendChild( doc.createTextNode( mEditFormInit ) );
node.appendChild( efiField );

QDomElement efiucField = doc.createElement( "editforminitusecode" );
efiucField.appendChild( doc.createTextNode( mEditFormInitUseCode ? "1" : "0") );
node.appendChild( efiucField );

QDomElement eficField = doc.createElement( "editforminitcode" );
eficField.appendChild( doc.createTextNode( mEditFormInitCode ) );
node.appendChild( eficField );

QDomElement fFSuppElem = doc.createElement( "featformsuppress" );
QDomText fFSuppText = doc.createTextNode( QString::number( featureFormSuppress() ) );
fFSuppElem.appendChild( fFSuppText );
Expand Down Expand Up @@ -2826,11 +2846,26 @@ QString QgsVectorLayer::editFormInit()
return mEditFormInit;
}

QString QgsVectorLayer::editFormInitCode()
{
return mEditFormInitCode;
}

void QgsVectorLayer::setEditFormInit( const QString& function )
{
mEditFormInit = function;
}

void QgsVectorLayer::setEditFormInitUseCode( const bool useCode )
{
mEditFormInitUseCode = useCode;
}

void QgsVectorLayer::setEditFormInitCode( const QString& code )
{
mEditFormInitCode = code;
}

QMap< QString, QVariant > QgsVectorLayer::valueMap( int idx )
{
return editorWidgetV2Config( idx );
Expand Down
17 changes: 15 additions & 2 deletions src/core/qgsvectorlayer.h
Expand Up @@ -1628,9 +1628,21 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Get python function for edit form initialization */
QString editFormInit();

/** Get python code for edit form initialization */
QString editFormInitCode();

/** Reeturn if python code has to be loaded for edit form initialization */
bool editFormInitUseCode();

/** Set python function for edit form initialization */
void setEditFormInit( const QString& function );

/** Set python code for edit form initialization */
void setEditFormInitCode( const QString& code);

/** Set python code for edit form initialization */
void setEditFormInitUseCode( const bool useCode);

/**
* Access value map
* @deprecated Use editorWidgetV2Config() instead
Expand Down Expand Up @@ -1789,7 +1801,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
QgsConditionalLayerStyles *conditionalStyles() const;

public slots:
public slots:
/**
* Select feature by its ID
*
Expand Down Expand Up @@ -2141,7 +2153,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Defines the default layout to use for the attribute editor (Drag and drop, UI File, Generated) */
EditorLayout mEditorLayout;

QString mEditForm, mEditFormInit;
QString mEditForm, mEditFormInit, mEditFormInitCode;
bool mEditFormInitUseCode;

/** Type of feature form suppression after feature creation
* @note added in 2.1 */
Expand Down
73 changes: 66 additions & 7 deletions src/ui/qgsfieldspropertiesbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>613</width>
<width>719</width>
<height>634</height>
</rect>
</property>
Expand Down Expand Up @@ -113,6 +113,20 @@ MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.<
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="leEditFormInitUseCode">
<property name="text">
<string>use code</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="leButtonOpenEditor">
<property name="text">
<string>Open editor</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="7">
Expand All @@ -128,7 +142,16 @@ MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.<
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<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 row="0" column="0">
Expand Down Expand Up @@ -254,7 +277,16 @@ MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.<
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<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 row="0" column="1">
Expand Down Expand Up @@ -295,10 +327,19 @@ MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.<
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout_5">
<property name="horizontalSpacing">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="margin">
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
Expand All @@ -319,7 +360,16 @@ MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.<
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<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>
Expand Down Expand Up @@ -415,7 +465,16 @@ MyForms.py must live on PYTHONPATH, .qgis/python, or inside the project folder.<
<bool>true</bool>
</property>
<layout class="QGridLayout" name="mDesignerListLayout">
<property name="margin">
<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>
</layout>
Expand Down

0 comments on commit 842753e

Please sign in to comment.