Skip to content

Commit

Permalink
Avoid 'geometry' field name being translated when creating new Spatia…
Browse files Browse the repository at this point in the history
…Lite layer (#6059)
  • Loading branch information
DelazJ authored and nirvn committed Jan 15, 2018
1 parent ded9b09 commit b4be39f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
12 changes: 6 additions & 6 deletions src/app/qgsnewspatialitelayerdialog.cpp
Expand Up @@ -31,6 +31,7 @@
#include "qgsspatialiteutils.h"
#include "qgslogger.h"
#include "qgssettings.h"
#include "qgsgui.h"

#include <QPushButton>
#include <QLineEdit>
Expand All @@ -44,6 +45,8 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
: QDialog( parent, fl )
{
setupUi( this );
QgsGui::instance()->enableAutoGeometryRestore( this );

connect( mAddAttributeButton, &QToolButton::clicked, this, &QgsNewSpatialiteLayerDialog::mAddAttributeButton_clicked );
connect( mRemoveAttributeButton, &QToolButton::clicked, this, &QgsNewSpatialiteLayerDialog::mRemoveAttributeButton_clicked );
connect( mGeometryTypeBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewSpatialiteLayerDialog::mGeometryTypeBox_currentIndexChanged );
Expand All @@ -53,9 +56,6 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsNewSpatialiteLayerDialog::buttonBox_accepted );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsNewSpatialiteLayerDialog::buttonBox_rejected );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/NewSpatiaLiteLayer/geometry" ) ).toByteArray() );

mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconTableLayer.svg" ) ), tr( "No geometry" ), QStringLiteral( "" ) );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point" ), QStringLiteral( "POINT" ) );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "Line" ), QStringLiteral( "LINESTRING" ) );
Expand All @@ -68,6 +68,7 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
mGeometryWithZCheckBox->setEnabled( false );
mGeometryWithMCheckBox->setEnabled( false );
leGeometryColumn->setEnabled( false );
leGeometryColumn->setText( "geometry" );

mAddAttributeButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionNewAttribute.svg" ) ) );
mRemoveAttributeButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeleteAttribute.svg" ) ) );
Expand All @@ -76,6 +77,7 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
mTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldFloat.svg" ) ), tr( "Decimal number" ), "real" );

// Populate the database list from the stored connections
QgsSettings settings;
settings.beginGroup( QStringLiteral( "SpatiaLite/connections" ) );
QStringList keys = settings.childGroups();
QStringList::Iterator it = keys.begin();
Expand Down Expand Up @@ -112,8 +114,7 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W

QgsNewSpatialiteLayerDialog::~QgsNewSpatialiteLayerDialog()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/NewSpatiaLiteLayer/geometry" ), saveGeometry() );

}

void QgsNewSpatialiteLayerDialog::mGeometryTypeBox_currentIndexChanged( int index )
Expand Down Expand Up @@ -502,4 +503,3 @@ void QgsNewSpatialiteLayerDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "managing_data_source/create_layers.html#creating-a-new-spatialite-layer" ) );
}

55 changes: 37 additions & 18 deletions src/ui/qgsnewspatialitelayerdialogbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>490</width>
<width>470</width>
<height>627</height>
</rect>
</property>
Expand Down Expand Up @@ -51,8 +51,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>598</height>
<width>450</width>
<height>560</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
Expand Down Expand Up @@ -124,7 +124,7 @@
<cstring>mGeometryTypeBox</cstring>
</property>
</widget>
</item>
</item>
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="mGeometryTypeBox">
<property name="enabled">
Expand Down Expand Up @@ -157,8 +157,21 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
Expand Down Expand Up @@ -193,12 +206,12 @@
</item>
</layout>
</item>
<item row="5" colspan="3">
<item row="5" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox1">
<property name="title">
<string>New field</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="textLabel1">
<property name="sizePolicy">
Expand Down Expand Up @@ -283,7 +296,7 @@
</layout>
</widget>
</item>
<item row="6" colspan="3">
<item row="6" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Fields list</string>
Expand Down Expand Up @@ -357,9 +370,9 @@
</layout>
</widget>
</item>
<item row="7" colspan="3">
<widget class="QgsCollapsibleGroupBox" name="groupBox">
<property name="title">
<item row="7" column="0" colspan="3">
<widget class="QgsCollapsibleGroupBox" name="groupBox" native="true">
<property name="title" stdset="0">
<string>Advanced options</string>
</property>
<property name="collapsed" stdset="0">
Expand All @@ -385,10 +398,7 @@
</sizepolicy>
</property>
<property name="toolTip">
<string>Name for the new layer</string>
</property>
<property name="text">
<string>geometry</string>
<string>Name of the geometry column</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -432,21 +442,30 @@
<header>qgsscrollarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QWidget</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>scrollArea</tabstop>
<tabstop>mDatabaseComboBox</tabstop>
<tabstop>toolButtonNewDatabase</tabstop>
<tabstop>leLayerName</tabstop>
<tabstop>leGeometryColumn</tabstop>
<tabstop>mGeometryTypeBox</tabstop>
<tabstop>mGeometryWithZCheckBox</tabstop>
<tabstop>mGeometryWithMCheckBox</tabstop>
<tabstop>leSRID</tabstop>
<tabstop>pbnFindSRID</tabstop>
<tabstop>checkBoxPrimaryKey</tabstop>
<tabstop>mNameEdit</tabstop>
<tabstop>mTypeBox</tabstop>
<tabstop>mAddAttributeButton</tabstop>
<tabstop>mAttributeView</tabstop>
<tabstop>mRemoveAttributeButton</tabstop>
<tabstop>leGeometryColumn</tabstop>
<tabstop>checkBoxPrimaryKey</tabstop>
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
Expand Down

0 comments on commit b4be39f

Please sign in to comment.