Skip to content

Commit fbdc414

Browse files
committed
Rename methods in QgsPanelWidgetStack for consistency
1 parent 3b0486c commit fbdc414

File tree

5 files changed

+46
-25
lines changed

5 files changed

+46
-25
lines changed

doc/api_break.dox

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,14 @@ be used instead of a null pointer if no transformation is required.</li>
10901090
<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>
10911091
</ul>
10921092

1093+
\subsection qgis_api_break_3_0_QgsPanelWidgetStack QgsPanelWidgetStack
1094+
1095+
<ul>
1096+
<li>addMainPanel() has been renamed to setMainPanel()</li>
1097+
<li>mainWidget() has been renamed to mainPanel()</li>
1098+
<li>takeMainWidget() has been renamed to takeMainPanel()</li>
1099+
</ul>
1100+
10931101
\subsection qgis_api_break_3_0_QgsPluginLayer QgsPluginLayer
10941102

10951103
<ul>

python/gui/qgspanelwidgetstack.sip

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,33 @@ class QgsPanelWidgetStack: public QWidget
1919
QgsPanelWidgetStack( QWidget* parent = nullptr );
2020

2121
/**
22-
* Adds the main widget to the stack and selects it for the user
22+
* Adds the main panel widget to the stack and selects it for the user
2323
* The main widget can not be closed and only the showPanel signal is attached
2424
* to handle children widget opening panels.
2525
* @param panel The panel to set as the first widget in the stack.
26+
* @note a stack can have only one main panel. Any existing main panel
27+
* should be removed by first calling takeMainPanel().
28+
* @see mainPanel()
29+
* @see takeMainPanel()
2630
*/
27-
void addMainPanel( QgsPanelWidget* panel );
31+
void setMainPanel( QgsPanelWidget* panel );
2832

2933
/**
30-
* The main widget that is set in the stack. The main widget can not be closed
34+
* The main panel widget that is set in the stack. The main widget can not be closed
3135
* and doesn't display a back button.
3236
* @return The main QgsPanelWidget that is active in the stack.
37+
* @see setMainPanel()
3338
*/
34-
QgsPanelWidget* mainWidget();
39+
QgsPanelWidget* mainPanel();
3540

3641
/**
37-
* Removes the main widget from the stack and transfers ownsership to the
42+
* Removes the main panel widget from the stack and transfers ownsership to the
3843
* caller.
3944
* @return The main widget that is set in the stack.
45+
* @see mainPanel()
46+
* @see setMainPanel()
4047
*/
41-
QgsPanelWidget* takeMainWidget();
48+
QgsPanelWidget* takeMainPanel();
4249

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

src/app/qgslayerstylingwidget.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void QgsLayerStylingWidget::apply()
226226

227227
QString undoName = "Style Change";
228228

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

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

308308
mStackedWidget->setCurrentIndex( mLayerPage );
309309

310-
QgsPanelWidget* current = mWidgetStack->takeMainWidget();
310+
QgsPanelWidget* current = mWidgetStack->takeMainPanel();
311311
if ( current )
312312
{
313313
if ( QgsLabelingWidget* widget = qobject_cast<QgsLabelingWidget*>( current ) )
@@ -334,15 +334,14 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
334334
if ( panel )
335335
{
336336
connect( panel, SIGNAL( widgetChanged( QgsPanelWidget* ) ), this, SLOT( autoApply() ) );
337-
panel->setDockMode( true );
338-
mWidgetStack->addMainPanel( panel );
337+
mWidgetStack->setMainPanel( panel );
339338
}
340339
}
341340

342341
// The last widget is always the undo stack.
343342
if ( row == mOptionsListWidget->count() - 1 )
344343
{
345-
mWidgetStack->addMainPanel( mUndoWidget );
344+
mWidgetStack->setMainPanel( mUndoWidget );
346345
}
347346
else if ( mCurrentLayer->type() == QgsMapLayer::VectorLayer )
348347
{
@@ -359,7 +358,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
359358
QgsPanelWidgetWrapper* wrapper = new QgsPanelWidgetWrapper( styleWidget, mStackedWidget );
360359
wrapper->setDockMode( true );
361360
connect( styleWidget, SIGNAL( showPanel( QgsPanelWidget* ) ), wrapper, SLOT( openPanel( QgsPanelWidget* ) ) );
362-
mWidgetStack->addMainPanel( wrapper );
361+
mWidgetStack->setMainPanel( wrapper );
363362
break;
364363
}
365364
case 1: // Labels
@@ -371,7 +370,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
371370
connect( mLabelingWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
372371
}
373372
mLabelingWidget->setLayer( vlayer );
374-
mWidgetStack->addMainPanel( mLabelingWidget );
373+
mWidgetStack->setMainPanel( mLabelingWidget );
375374
break;
376375
}
377376
default:
@@ -388,14 +387,14 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
388387
mRasterStyleWidget = new QgsRendererRasterPropertiesWidget( rlayer, mMapCanvas, mWidgetStack );
389388
mRasterStyleWidget->setDockMode( true );
390389
connect( mRasterStyleWidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
391-
mWidgetStack->addMainPanel( mRasterStyleWidget );
390+
mWidgetStack->setMainPanel( mRasterStyleWidget );
392391
break;
393392
case 1: // Transparency
394393
{
395394
QgsRasterTransparencyWidget* transwidget = new QgsRasterTransparencyWidget( rlayer, mMapCanvas, mWidgetStack );
396395
transwidget->setDockMode( true );
397396
connect( transwidget, SIGNAL( widgetChanged() ), this, SLOT( autoApply() ) );
398-
mWidgetStack->addMainPanel( transwidget );
397+
mWidgetStack->setMainPanel( transwidget );
399398
break;
400399
}
401400
case 2: // Histogram
@@ -417,7 +416,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
417416
widget->setRendererWidget( name, mRasterStyleWidget->currentRenderWidget() );
418417
widget->setDockMode( true );
419418

420-
mWidgetStack->addMainPanel( widget );
419+
mWidgetStack->setMainPanel( widget );
421420
}
422421
break;
423422
}

src/gui/qgspanelwidgetstack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ QgsPanelWidgetStack::QgsPanelWidgetStack( QWidget *parent )
3232
connect( mBackButton, SIGNAL( pressed() ), this, SLOT( acceptCurrentPanel() ) );
3333
}
3434

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

46-
QgsPanelWidget *QgsPanelWidgetStack::mainWidget()
46+
QgsPanelWidget *QgsPanelWidgetStack::mainPanel()
4747
{
4848
return qobject_cast<QgsPanelWidget*>( mStackedWidget->widget( 0 ) );
4949
}
5050

51-
QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget()
51+
QgsPanelWidget *QgsPanelWidgetStack::takeMainPanel()
5252
{
5353
QWidget* widget = mStackedWidget->widget( 0 );
5454
mStackedWidget->removeWidget( widget );

src/gui/qgspanelwidgetstack.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,33 @@ class GUI_EXPORT QgsPanelWidgetStack : public QWidget, private Ui::QgsRendererWi
4343
QgsPanelWidgetStack( QWidget* parent = nullptr );
4444

4545
/**
46-
* Adds the main widget to the stack and selects it for the user
46+
* Adds the main panel widget to the stack and selects it for the user
4747
* The main widget can not be closed and only the showPanel signal is attached
4848
* to handle children widget opening panels.
4949
* @param panel The panel to set as the first widget in the stack.
50+
* @note a stack can have only one main panel. Any existing main panel
51+
* should be removed by first calling takeMainPanel().
52+
* @see mainPanel()
53+
* @see takeMainPanel()
5054
*/
51-
void addMainPanel( QgsPanelWidget* panel );
55+
void setMainPanel( QgsPanelWidget* panel );
5256

5357
/**
54-
* The main widget that is set in the stack. The main widget can not be closed
58+
* The main panel widget that is set in the stack. The main widget can not be closed
5559
* and doesn't display a back button.
5660
* @return The main QgsPanelWidget that is active in the stack.
61+
* @see setMainPanel()
5762
*/
58-
QgsPanelWidget* mainWidget();
63+
QgsPanelWidget* mainPanel();
5964

6065
/**
61-
* Removes the main widget from the stack and transfers ownsership to the
66+
* Removes the main panel widget from the stack and transfers ownsership to the
6267
* caller.
6368
* @return The main widget that is set in the stack.
69+
* @see mainPanel()
70+
* @see setMainPanel()
6471
*/
65-
QgsPanelWidget* takeMainWidget();
72+
QgsPanelWidget* takeMainPanel();
6673

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

0 commit comments

Comments
 (0)