Skip to content

Commit

Permalink
[styledock] Layer picker
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jun 2, 2016
1 parent 7433d32 commit 7dd1c59
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
5 changes: 3 additions & 2 deletions src/app/qgsmapstylingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ QgsMapStylingWidget::QgsMapStylingWidget( QgsMapCanvas* canvas, QList<QgsMapStyl
connect( mOptionsListWidget, SIGNAL( currentRowChanged( int ) ), this, SLOT( updateCurrentWidgetLayer() ) );
connect( mLiveApplyCheck, SIGNAL( toggled( bool ) ), mButtonBox->button( QDialogButtonBox::Apply ), SLOT( setDisabled( bool ) ) );
connect( mButtonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( mLayerCombo, SIGNAL( layerChanged( QgsMapLayer* ) ), this, SLOT( setLayer( QgsMapLayer* ) ) );

mButtonBox->button( QDialogButtonBox::Apply )->setEnabled( false );
}
Expand All @@ -64,7 +65,7 @@ void QgsMapStylingWidget::setLayer( QgsMapLayer *layer )
{
if ( !layer || !layer->isSpatial() )
{
mLayerTitle->setText( QString() );
mLayerCombo->setLayer( nullptr );
mStackedWidget->setCurrentIndex( mNotSupportedPage );
return;
}
Expand Down Expand Up @@ -188,7 +189,7 @@ void QgsMapStylingWidget::updateCurrentWidgetLayer()

mUndoWidget->setUndoStack( layer->undoStackStyles() );

mLayerTitle->setText( layer->name() );
whileBlocking( mLayerCombo )->setLayer( layer );

int row = mOptionsListWidget->currentIndex().row();

Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsmaplayercombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ QgsMapLayerComboBox::QgsMapLayerComboBox( QWidget *parent )

void QgsMapLayerComboBox::setLayer( QgsMapLayer *layer )
{
if ( !layer )
{
setCurrentIndex( -1 );
return;
}

QModelIndex idx = mProxyModel->sourceLayerModel()->indexFromLayer( layer );
if ( idx.isValid() )
{
Expand Down
56 changes: 30 additions & 26 deletions src/ui/qgsmapstylingwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>3</number>
</property>
<item row="0" column="0">
Expand All @@ -44,21 +35,12 @@
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout">
<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>
<property name="horizontalSpacing">
<number>3</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
Expand Down Expand Up @@ -153,17 +135,32 @@
</item>
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="textLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Layer name</string>
<string>Layer</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mLayerTitle">
<property name="readOnly">
<bool>true</bool>
<widget class="QgsMapLayerComboBox" name="mLayerCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
</property>
</widget>
</item>
Expand Down Expand Up @@ -208,6 +205,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsMapLayerComboBox</class>
<extends>QComboBox</extends>
<header>qgsmaplayercombobox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../images/images.qrc"/>
</resources>
Expand Down

0 comments on commit 7dd1c59

Please sign in to comment.