Skip to content

Commit

Permalink
Rename methods in QgsPanelWidgetStack for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 6, 2016
1 parent 3b0486c commit fbdc414
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 25 deletions.
8 changes: 8 additions & 0 deletions doc/api_break.dox
Expand Up @@ -1090,6 +1090,14 @@ be used instead of a null pointer if no transformation is required.</li>
<li>prepareGeometry() and geometryRequiresPreparation() now take a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.</li>
</ul>

\subsection qgis_api_break_3_0_QgsPanelWidgetStack QgsPanelWidgetStack

<ul>
<li>addMainPanel() has been renamed to setMainPanel()</li>
<li>mainWidget() has been renamed to mainPanel()</li>
<li>takeMainWidget() has been renamed to takeMainPanel()</li>
</ul>

\subsection qgis_api_break_3_0_QgsPluginLayer QgsPluginLayer

<ul>
Expand Down
19 changes: 13 additions & 6 deletions python/gui/qgspanelwidgetstack.sip
Expand Up @@ -19,26 +19,33 @@ class QgsPanelWidgetStack: public QWidget
QgsPanelWidgetStack( QWidget* parent = nullptr );

/**
* Adds the main widget to the stack and selects it for the user
* Adds the main panel widget to the stack and selects it for the user
* The main widget can not be closed and only the showPanel signal is attached
* to handle children widget opening panels.
* @param panel The panel to set as the first widget in the stack.
* @note a stack can have only one main panel. Any existing main panel
* should be removed by first calling takeMainPanel().
* @see mainPanel()
* @see takeMainPanel()
*/
void addMainPanel( QgsPanelWidget* panel );
void setMainPanel( QgsPanelWidget* panel );

/**
* The main widget that is set in the stack. The main widget can not be closed
* The main panel widget that is set in the stack. The main widget can not be closed
* and doesn't display a back button.
* @return The main QgsPanelWidget that is active in the stack.
* @see setMainPanel()
*/
QgsPanelWidget* mainWidget();
QgsPanelWidget* mainPanel();

/**
* Removes the main widget from the stack and transfers ownsership to the
* Removes the main panel widget from the stack and transfers ownsership to the
* caller.
* @return The main widget that is set in the stack.
* @see mainPanel()
* @see setMainPanel()
*/
QgsPanelWidget* takeMainWidget();
QgsPanelWidget* takeMainPanel();

/**
* Clear the stack of all widgets. Unless the panels autoDelete is set to false
Expand Down
19 changes: 9 additions & 10 deletions src/app/qgslayerstylingwidget.cpp
Expand Up @@ -226,7 +226,7 @@ void QgsLayerStylingWidget::apply()

QString undoName = "Style Change";

QWidget* current = mWidgetStack->mainWidget();
QWidget* current = mWidgetStack->mainPanel();

bool styleWasChanged = false;
if ( QgsLabelingWidget* widget = qobject_cast<QgsLabelingWidget*>( current ) )
Expand Down Expand Up @@ -307,7 +307,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()

mStackedWidget->setCurrentIndex( mLayerPage );

QgsPanelWidget* current = mWidgetStack->takeMainWidget();
QgsPanelWidget* current = mWidgetStack->takeMainPanel();
if ( current )
{
if ( QgsLabelingWidget* widget = qobject_cast<QgsLabelingWidget*>( current ) )
Expand All @@ -334,15 +334,14 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
if ( panel )
{
connect( panel, SIGNAL( widgetChanged( QgsPanelWidget* ) ), this, SLOT( autoApply() ) );
panel->setDockMode( true );
mWidgetStack->addMainPanel( panel );
mWidgetStack->setMainPanel( panel );
}
}

// The last widget is always the undo stack.
if ( row == mOptionsListWidget->count() - 1 )
{
mWidgetStack->addMainPanel( mUndoWidget );
mWidgetStack->setMainPanel( mUndoWidget );
}
else if ( mCurrentLayer->type() == QgsMapLayer::VectorLayer )
{
Expand All @@ -359,7 +358,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
QgsPanelWidgetWrapper* wrapper = new QgsPanelWidgetWrapper( styleWidget, mStackedWidget );
wrapper->setDockMode( true );
connect( styleWidget, SIGNAL( showPanel( QgsPanelWidget* ) ), wrapper, SLOT( openPanel( QgsPanelWidget* ) ) );
mWidgetStack->addMainPanel( wrapper );
mWidgetStack->setMainPanel( wrapper );
break;
}
case 1: // Labels
Expand All @@ -371,7 +370,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
connect( mLabelingWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
}
mLabelingWidget->setLayer( vlayer );
mWidgetStack->addMainPanel( mLabelingWidget );
mWidgetStack->setMainPanel( mLabelingWidget );
break;
}
default:
Expand All @@ -388,14 +387,14 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
mRasterStyleWidget = new QgsRendererRasterPropertiesWidget( rlayer, mMapCanvas, mWidgetStack );
mRasterStyleWidget->setDockMode( true );
connect( mRasterStyleWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
mWidgetStack->addMainPanel( mRasterStyleWidget );
mWidgetStack->setMainPanel( mRasterStyleWidget );
break;
case 1: // Transparency
{
QgsRasterTransparencyWidget* transwidget = new QgsRasterTransparencyWidget( rlayer, mMapCanvas, mWidgetStack );
transwidget->setDockMode( true );
connect( transwidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
mWidgetStack->addMainPanel( transwidget );
mWidgetStack->setMainPanel( transwidget );
break;
}
case 2: // Histogram
Expand All @@ -417,7 +416,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
widget->setRendererWidget( name, mRasterStyleWidget->currentRenderWidget() );
widget->setDockMode( true );

mWidgetStack->addMainPanel( widget );
mWidgetStack->setMainPanel( widget );
}
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgspanelwidgetstack.cpp
Expand Up @@ -32,7 +32,7 @@ QgsPanelWidgetStack::QgsPanelWidgetStack( QWidget *parent )
connect( mBackButton, SIGNAL( pressed() ), this, SLOT( acceptCurrentPanel() ) );
}

void QgsPanelWidgetStack::addMainPanel( QgsPanelWidget *panel )
void QgsPanelWidgetStack::setMainPanel( QgsPanelWidget *panel )
{
// TODO Don't allow adding another main widget or else that would be strange for the user.
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ),
Expand All @@ -43,12 +43,12 @@ void QgsPanelWidgetStack::addMainPanel( QgsPanelWidget *panel )
mStackedWidget->setCurrentIndex( 0 );
}

QgsPanelWidget *QgsPanelWidgetStack::mainWidget()
QgsPanelWidget *QgsPanelWidgetStack::mainPanel()
{
return qobject_cast<QgsPanelWidget*>( mStackedWidget->widget( 0 ) );
}

QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget()
QgsPanelWidget *QgsPanelWidgetStack::takeMainPanel()
{
QWidget* widget = mStackedWidget->widget( 0 );
mStackedWidget->removeWidget( widget );
Expand Down
19 changes: 13 additions & 6 deletions src/gui/qgspanelwidgetstack.h
Expand Up @@ -43,26 +43,33 @@ class GUI_EXPORT QgsPanelWidgetStack : public QWidget, private Ui::QgsRendererWi
QgsPanelWidgetStack( QWidget* parent = nullptr );

/**
* Adds the main widget to the stack and selects it for the user
* Adds the main panel widget to the stack and selects it for the user
* The main widget can not be closed and only the showPanel signal is attached
* to handle children widget opening panels.
* @param panel The panel to set as the first widget in the stack.
* @note a stack can have only one main panel. Any existing main panel
* should be removed by first calling takeMainPanel().
* @see mainPanel()
* @see takeMainPanel()
*/
void addMainPanel( QgsPanelWidget* panel );
void setMainPanel( QgsPanelWidget* panel );

/**
* The main widget that is set in the stack. The main widget can not be closed
* The main panel widget that is set in the stack. The main widget can not be closed
* and doesn't display a back button.
* @return The main QgsPanelWidget that is active in the stack.
* @see setMainPanel()
*/
QgsPanelWidget* mainWidget();
QgsPanelWidget* mainPanel();

/**
* Removes the main widget from the stack and transfers ownsership to the
* Removes the main panel widget from the stack and transfers ownsership to the
* caller.
* @return The main widget that is set in the stack.
* @see mainPanel()
* @see setMainPanel()
*/
QgsPanelWidget* takeMainWidget();
QgsPanelWidget* takeMainPanel();

/**
* Clear the stack of all widgets. Unless the panels autoDelete is set to false
Expand Down

0 comments on commit fbdc414

Please sign in to comment.