Skip to content
Permalink
Browse files

Initial implementation

  • Loading branch information
elpaso committed Nov 4, 2015
1 parent 8c86aab commit 842753e3414f18f41b78cc416269b27b1be6f6e2
Showing with 118 additions and 9 deletions.
  1. +2 −0 src/app/qgsfieldsproperties.cpp
  2. +35 −0 src/core/qgsvectorlayer.cpp
  3. +15 −2 src/core/qgsvectorlayer.h
  4. +66 −7 src/ui/qgsfieldspropertiesbase.ui
@@ -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 );
@@ -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() )
{
@@ -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 );
@@ -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 );
@@ -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
@@ -1789,7 +1801,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
*/
QgsConditionalLayerStyles *conditionalStyles() const;

public slots:
public slots:
/**
* Select feature by its ID
*
@@ -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 */
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>613</width>
<width>719</width>
<height>634</height>
</rect>
</property>
@@ -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">
@@ -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">
@@ -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">
@@ -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">
@@ -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>
@@ -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>

0 comments on commit 842753e

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