Skip to content
Permalink
Browse files

[need-docs] Reorganize the new memory layer (#5804)

  • Loading branch information
DelazJ authored and nirvn committed Dec 7, 2017
1 parent 571bf54 commit bac80aa93a650a5254333ebddd8f337563674800
Showing with 76 additions and 129 deletions.
  1. +30 −34 src/gui/qgsnewmemorylayerdialog.cpp
  2. +1 −0 src/gui/qgsnewmemorylayerdialog.h
  3. +45 −95 src/ui/qgsnewmemorylayerdialogbase.ui
@@ -54,9 +54,20 @@ QgsNewMemoryLayerDialog::QgsNewMemoryLayerDialog( QWidget *parent, Qt::WindowFla
QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/NewMemoryLayer/geometry" ) ).toByteArray() );

mPointRadioButton->setChecked( true );
mGeometryTypeBox->addItem( tr( "Non spatial" ), QgsWkbTypes::NoGeometry );
mGeometryTypeBox->addItem( tr( "Point" ), QgsWkbTypes::Point );
mGeometryTypeBox->addItem( tr( "Line" ), QgsWkbTypes::LineString );
mGeometryTypeBox->addItem( tr( "Polygon" ), QgsWkbTypes::Polygon );
mGeometryTypeBox->addItem( tr( "Multi point" ), QgsWkbTypes::MultiPoint );
mGeometryTypeBox->addItem( tr( "Multi line" ), QgsWkbTypes::MultiLineString );
mGeometryTypeBox->addItem( tr( "Multi polygon" ), QgsWkbTypes::MultiPolygon );

mGeometryWithZCheckBox->setEnabled( false );
mGeometryWithMCheckBox->setEnabled( false );

mNameLineEdit->setText( tr( "New scratch layer" ) );

connect( mGeometryTypeBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewMemoryLayerDialog::geometryTypeChanged );
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsNewMemoryLayerDialog::showHelp );
}

@@ -68,45 +79,30 @@ QgsNewMemoryLayerDialog::~QgsNewMemoryLayerDialog()

QgsWkbTypes::Type QgsNewMemoryLayerDialog::selectedType() const
{
QgsWkbTypes::Type wkbType = QgsWkbTypes::Unknown;
if ( !buttonGroupGeometry->isChecked() )
{
wkbType = QgsWkbTypes::NoGeometry;
}
else if ( mPointRadioButton->isChecked() )
{
wkbType = QgsWkbTypes::Point;
}
else if ( mLineRadioButton->isChecked() )
{
wkbType = QgsWkbTypes::LineString;
}
else if ( mPolygonRadioButton->isChecked() )
{
wkbType = QgsWkbTypes::Polygon;
}
else if ( mMultiPointRadioButton->isChecked() )
{
wkbType = QgsWkbTypes::MultiPoint;
}
else if ( mMultiLineRadioButton->isChecked() )
{
wkbType = QgsWkbTypes::MultiLineString;
}
else if ( mMultiPolygonRadioButton->isChecked() )
{
wkbType = QgsWkbTypes::MultiPolygon;
}
QgsWkbTypes::Type geomType = QgsWkbTypes::Unknown;
geomType = static_cast<QgsWkbTypes::Type>
( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );

if ( wkbType != QgsWkbTypes::Unknown && wkbType != QgsWkbTypes::NoGeometry )
if ( geomType != QgsWkbTypes::Unknown && geomType != QgsWkbTypes::NoGeometry )
{
if ( mGeometryWithZCheckBox->isChecked() )
wkbType = QgsWkbTypes::addZ( wkbType );
geomType = QgsWkbTypes::addZ( geomType );
if ( mGeometryWithMCheckBox->isChecked() )
wkbType = QgsWkbTypes::addM( wkbType );
geomType = QgsWkbTypes::addM( geomType );
}

return wkbType;
return geomType;
}

void QgsNewMemoryLayerDialog::geometryTypeChanged( int )
{
QgsWkbTypes::Type geomType = static_cast<QgsWkbTypes::Type>
( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );

bool isSpatial = geomType != QgsWkbTypes::NoGeometry;
mGeometryWithZCheckBox->setEnabled( isSpatial );
mGeometryWithMCheckBox->setEnabled( isSpatial );
mCrsSelector->setEnabled( isSpatial );
}

void QgsNewMemoryLayerDialog::setCrs( const QgsCoordinateReferenceSystem &crs )
@@ -71,6 +71,7 @@ class GUI_EXPORT QgsNewMemoryLayerDialog: public QDialog, private Ui::QgsNewMemo

private slots:

void geometryTypeChanged( int index );
void showHelp();
};

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>444</width>
<height>304</height>
<height>233</height>
</rect>
</property>
<property name="sizePolicy">
@@ -24,100 +24,54 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="buttonGroupGeometry">
<property name="title">
<string>Geometry type and CRS</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QRadioButton" name="mMultiPointRadioButton">
<property name="text">
<string>Multipoint</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="mMultiPolygonRadioButton">
<property name="text">
<string>Multipolygon</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="mPolygonRadioButton">
<property name="text">
<string>Polygon</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="mPointRadioButton">
<property name="text">
<string>Point</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="mLineRadioButton">
<property name="text">
<string>Line</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="mMultiLineRadioButton">
<property name="text">
<string>Multiline</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QCheckBox" name="mGeometryWithZCheckBox">
<property name="text">
<string>Include Z dimension</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mGeometryWithMCheckBox">
<property name="text">
<string>Include M values</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="2">
<widget class="QCheckBox" name="mGeometryWithMCheckBox">
<property name="text">
<string>Include M values</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Geometry type</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Layer name</string>
</property>
</widget>
</item>
<item>
<item row="2" column="1">
<widget class="QCheckBox" name="mGeometryWithZCheckBox">
<property name="text">
<string>Include Z dimension</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="mGeometryTypeBox"/>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="mNameLineEdit"/>
</item>
<item row="3" column="0" colspan="3">
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -168,15 +122,11 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonGroupGeometry</tabstop>
<tabstop>mPointRadioButton</tabstop>
<tabstop>mLineRadioButton</tabstop>
<tabstop>mPolygonRadioButton</tabstop>
<tabstop>mMultiPointRadioButton</tabstop>
<tabstop>mMultiLineRadioButton</tabstop>
<tabstop>mMultiPolygonRadioButton</tabstop>
<tabstop>mCrsSelector</tabstop>
<tabstop>mNameLineEdit</tabstop>
<tabstop>mGeometryTypeBox</tabstop>
<tabstop>mGeometryWithZCheckBox</tabstop>
<tabstop>mGeometryWithMCheckBox</tabstop>
<tabstop>mCrsSelector</tabstop>
</tabstops>
<resources/>
<connections>

0 comments on commit bac80aa

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