Skip to content

Commit e097443

Browse files
committed
Fix globe plugin
1 parent 7dd6104 commit e097443

18 files changed

+400
-294
lines changed

python/gui/gui.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
%Include qgsorderbydialog.sip
137137
%Include qgsowssourceselect.sip
138138
%Include qgspanelwidget.sip
139+
%Include qgspanelwidgetstack.sip
139140
%Include qgspixmaplabel.sip
140141
%Include qgspluginmanagerinterface.sip
141142
%Include qgsprevieweffect.sip

python/gui/qgsmaplayerconfigwidgetfactory.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class QgsMapLayerConfigWidgetFactory
2929
*/
3030
virtual QString title() const;
3131

32+
virtual bool supportsStyleDock() const;
33+
34+
virtual bool supportLayerPropertiesDialog() const;
35+
3236
/**
3337
* @brief Check if the layer is supported for this widget.
3438
* @return True if this layer is supported for this widget

python/gui/qgspanelwidget.sip

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -156,75 +156,3 @@ class QgsPanelWidgetWrapper: public QgsPanelWidget
156156
*/
157157
QWidget* widget();
158158
};
159-
160-
/**
161-
* A stack widget to manage panels in the interface. Handles the open and close events
162-
* for added panels.
163-
* Any widgets that want to have a non blocking panel based interface should use this
164-
* class to manage the panels.
165-
*/
166-
class QgsPanelWidgetStack: public QWidget
167-
{
168-
%TypeHeaderCode
169-
#include "qgspanelwidget.h"
170-
%End
171-
public:
172-
173-
/**
174-
* A stack widget to manage panels in the interface. Handles the open and close events
175-
* for added panels.
176-
* @param parent
177-
*/
178-
QgsPanelWidgetStack( QWidget* parent = nullptr );
179-
180-
/**
181-
* Adds the main widget to the stack and selects it for the user
182-
* The main widget can not be closed and only the showPanel signal is attached
183-
* to handle children widget opening panels.
184-
* @param panel The panel to set as the first widget in the stack.
185-
*/
186-
void addMainPanel( QgsPanelWidget* panel );
187-
188-
/**
189-
* The main widget that is set in the stack. The main widget can not be closed
190-
* and doesn't display a back button.
191-
* @return The main QgsPanelWidget that is active in the stack.
192-
*/
193-
QgsPanelWidget* mainWidget();
194-
195-
/**
196-
* Removes the main widget from the stack and transfers ownsership to the
197-
* caller.
198-
* @return The main widget that is set in the stack.
199-
*/
200-
QgsPanelWidget* takeMainWidget();
201-
202-
/**
203-
* Clear the stack of all widgets. Unless the panels autoDelete is set to false
204-
* the widget will be deleted.
205-
*/
206-
void clear();
207-
208-
209-
public slots:
210-
/**
211-
* Accept the current active widget in the stack.
212-
*
213-
* Calls the panelAccepeted signal on the active widget.
214-
*/
215-
void acceptCurrentPanel();
216-
217-
/**
218-
* Show a panel in the stack widget. Will connect to the panels showPanel event to handle
219-
* nested panels. Auto switches the the given panel for the user.
220-
* @param panel The panel to show.
221-
*/
222-
void showPanel( QgsPanelWidget* panel );
223-
224-
/**
225-
* Closes the panel in the widget. Will also delete the widget.
226-
* This slot is normally auto connected to panelAccepted when a panel is shown.
227-
* @param panel The panel to close.
228-
*/
229-
void closePanel( QgsPanelWidget* panel );
230-
};

python/gui/qgspanelwidgetstack.sip

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* A stack widget to manage panels in the interface. Handles the open and close events
3+
* for added panels.
4+
* Any widgets that want to have a non blocking panel based interface should use this
5+
* class to manage the panels.
6+
*/
7+
class QgsPanelWidgetStack: public QWidget
8+
{
9+
%TypeHeaderCode
10+
#include "qgspanelwidgetstack.h"
11+
%End
12+
public:
13+
14+
/**
15+
* A stack widget to manage panels in the interface. Handles the open and close events
16+
* for added panels.
17+
* @param parent
18+
*/
19+
QgsPanelWidgetStack( QWidget* parent = nullptr );
20+
21+
/**
22+
* Adds the main widget to the stack and selects it for the user
23+
* The main widget can not be closed and only the showPanel signal is attached
24+
* to handle children widget opening panels.
25+
* @param panel The panel to set as the first widget in the stack.
26+
*/
27+
void addMainPanel( QgsPanelWidget* panel );
28+
29+
/**
30+
* The main widget that is set in the stack. The main widget can not be closed
31+
* and doesn't display a back button.
32+
* @return The main QgsPanelWidget that is active in the stack.
33+
*/
34+
QgsPanelWidget* mainWidget();
35+
36+
/**
37+
* Removes the main widget from the stack and transfers ownsership to the
38+
* caller.
39+
* @return The main widget that is set in the stack.
40+
*/
41+
QgsPanelWidget* takeMainWidget();
42+
43+
/**
44+
* Clear the stack of all widgets. Unless the panels autoDelete is set to false
45+
* the widget will be deleted.
46+
*/
47+
void clear();
48+
49+
50+
public slots:
51+
/**
52+
* Accept the current active widget in the stack.
53+
*
54+
* Calls the panelAccepeted signal on the active widget.
55+
*/
56+
void acceptCurrentPanel();
57+
58+
/**
59+
* Show a panel in the stack widget. Will connect to the panels showPanel event to handle
60+
* nested panels. Auto switches the the given panel for the user.
61+
* @param panel The panel to show.
62+
*/
63+
void showPanel( QgsPanelWidget* panel );
64+
65+
/**
66+
* Closes the panel in the widget. Will also delete the widget.
67+
* This slot is normally auto connected to panelAccepted when a panel is shown.
68+
* @param panel The panel to close.
69+
*/
70+
void closePanel( QgsPanelWidget* panel );
71+
};

python/gui/raster/qgsrastertransparencywidget.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @brief Widget to control a layers transparency and related options
33
*/
4-
class QgsRasterTransparencyWidget: QgsPanelWidgetStack
4+
class QgsRasterTransparencyWidget: QgsMapLayerConfigWidget
55
{
66
%TypeHeaderCode
77
#include <qgsrastertransparencywidget.h>

src/app/qgslayerstylingwidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer )
173173

174174
Q_FOREACH ( QgsMapLayerConfigWidgetFactory* factory, mPageFactories )
175175
{
176-
if ( factory->supportsLayer( layer ) )
176+
if ( factory->supportsStyleDock() && factory->supportsLayer( layer ) )
177177
{
178178
QListWidgetItem* item = new QListWidgetItem( factory->icon(), QString() );
179179
mOptionsListWidget->addItem( item );

src/app/qgsvectorlayerproperties.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,21 @@ void QgsVectorLayerProperties::setLabelCheckBox()
329329

330330
void QgsVectorLayerProperties::addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory* factory )
331331
{
332+
if ( !factory->supportLayerPropertiesDialog() )
333+
{
334+
return;
335+
}
336+
332337
QListWidgetItem* item = new QListWidgetItem();
333338
item->setIcon( factory->icon() );
334339
item->setText( factory->title() );
335340
item->setToolTip( factory->title() );
336341

337-
if ( item )
338-
{
339-
mOptionsListWidget->addItem( item );
342+
mOptionsListWidget->addItem( item );
340343

341-
QgsMapLayerConfigWidget* page = factory->createWidget( mLayer, nullptr, false, this );
342-
mLayerPropertiesPages << page;
343-
mOptionsStackedWidget->addWidget( page );
344-
}
344+
QgsMapLayerConfigWidget* page = factory->createWidget( mLayer, nullptr, false, this );
345+
mLayerPropertiesPages << page;
346+
mOptionsStackedWidget->addWidget( page );
345347
}
346348

347349
void QgsVectorLayerProperties::insertField()

src/gui/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ SET(QGIS_GUI_SRCS
275275
qgsowssourceselect.cpp
276276
qgssourceselectdialog.cpp
277277
qgspanelwidget.cpp
278+
qgspanelwidgetstack.cpp
278279
qgspixmaplabel.cpp
279280
qgspluginmanagerinterface.cpp
280281
qgsprevieweffect.cpp
@@ -425,6 +426,7 @@ SET(QGIS_GUI_MOC_HDRS
425426
qgsowssourceselect.h
426427
qgssourceselectdialog.h
427428
qgspanelwidget.h
429+
qgspanelwidgetstack.h
428430
qgspixmaplabel.h
429431
qgspluginmanagerinterface.h
430432
qgsprevieweffect.h

src/gui/qgsmaplayerconfigwidgetfactory.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory
4747
*/
4848
virtual QString title() const { return QString(); }
4949

50+
/**
51+
* Flag if widget is supported for use in style dock.
52+
* @return True if supported
53+
*/
54+
virtual bool supportsStyleDock() const { return false; }
55+
56+
/**
57+
* Flag if widget is supported for use in layer properties dialog.
58+
* @return True if supported
59+
*/
60+
virtual bool supportLayerPropertiesDialog() const { return false; }
61+
5062
/**
5163
* @brief Check if the layer is supported for this widget.
5264
* @return True if this layer is supported for this widget

src/gui/qgspanelwidget.cpp

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <QPushButton>
1717
#include <QDialog>
1818
#include <QSettings>
19+
#include <QVBoxLayout>
1920

2021
#include "qgspanelwidget.h"
2122
#include "qgslogger.h"
@@ -84,117 +85,6 @@ void QgsPanelWidget::keyPressEvent( QKeyEvent *event )
8485
}
8586
}
8687

87-
QgsPanelWidgetStack::QgsPanelWidgetStack( QWidget *parent )
88-
: QWidget( parent )
89-
{
90-
setupUi( this );
91-
clear();
92-
93-
connect( mBackButton, SIGNAL( pressed() ), this, SLOT( acceptCurrentPanel() ) );
94-
}
95-
96-
void QgsPanelWidgetStack::addMainPanel( QgsPanelWidget *panel )
97-
{
98-
// TODO Don't allow adding another main widget or else that would be strange for the user.
99-
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ),
100-
// using unique connection because addMainPanel() may be called multiple times
101-
// for a panel, so showPanel() slot could be invoked more times from one signal
102-
Qt::UniqueConnection );
103-
mStackedWidget->insertWidget( 0, panel );
104-
mStackedWidget->setCurrentIndex( 0 );
105-
}
106-
107-
QgsPanelWidget *QgsPanelWidgetStack::mainWidget()
108-
{
109-
return qobject_cast<QgsPanelWidget*>( mStackedWidget->widget( 0 ) );
110-
}
111-
112-
QgsPanelWidget *QgsPanelWidgetStack::takeMainWidget()
113-
{
114-
QWidget* widget = mStackedWidget->widget( 0 );
115-
mStackedWidget->removeWidget( widget );
116-
return qobject_cast<QgsPanelWidget*>( widget );
117-
}
118-
119-
void QgsPanelWidgetStack::clear()
120-
{
121-
for ( int i = mStackedWidget->count(); i >= 0; i-- )
122-
{
123-
if ( QgsPanelWidget* panelWidget = qobject_cast<QgsPanelWidget*>( mStackedWidget->widget( i ) ) )
124-
{
125-
mStackedWidget->removeWidget( panelWidget );
126-
if ( panelWidget->autoDelete() )
127-
{
128-
panelWidget->deleteLater();
129-
}
130-
}
131-
else if ( QWidget* widget = mStackedWidget->widget( i ) )
132-
{
133-
mStackedWidget->removeWidget( widget );
134-
widget->deleteLater();
135-
}
136-
}
137-
mTitles.clear();
138-
mTitleText->hide();
139-
mBackButton->hide();
140-
this->updateBreadcrumb();
141-
}
142-
143-
void QgsPanelWidgetStack::acceptCurrentPanel()
144-
{
145-
// You can't accept the main panel.
146-
if ( mStackedWidget->currentIndex() == 0 )
147-
return;
148-
149-
QgsPanelWidget* widget = qobject_cast<QgsPanelWidget*>( mStackedWidget->currentWidget() );
150-
widget->acceptPanel();
151-
}
152-
153-
void QgsPanelWidgetStack::showPanel( QgsPanelWidget *panel )
154-
{
155-
mTitles.push( panel->panelTitle() );
156-
157-
connect( panel, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( closePanel( QgsPanelWidget* ) ) );
158-
connect( panel, SIGNAL( showPanel( QgsPanelWidget* ) ), this, SLOT( showPanel( QgsPanelWidget* ) ) );
159-
160-
int index = mStackedWidget->addWidget( panel );
161-
mStackedWidget->setCurrentIndex( index );
162-
mBackButton->show();
163-
mTitleText->show();
164-
165-
this->updateBreadcrumb();
166-
}
167-
168-
void QgsPanelWidgetStack::closePanel( QgsPanelWidget *panel )
169-
{
170-
mTitles.pop();
171-
mStackedWidget->setCurrentIndex( mStackedWidget->currentIndex() - 1 );
172-
mStackedWidget->removeWidget( panel );
173-
if ( panel->autoDelete() )
174-
{
175-
panel->deleteLater();
176-
}
177-
178-
if ( mStackedWidget->currentIndex() == 0 )
179-
{
180-
mBackButton->hide();
181-
mTitleText->hide();
182-
}
183-
this->updateBreadcrumb();
184-
}
185-
186-
void QgsPanelWidgetStack::updateBreadcrumb()
187-
{
188-
QString breadcrumb;
189-
Q_FOREACH ( QString title, mTitles )
190-
{
191-
breadcrumb += QString( " %1 >" ).arg( title );
192-
}
193-
// Remove the last
194-
breadcrumb.chop( 1 );
195-
mTitleText->setText( breadcrumb );
196-
}
197-
19888
QgsPanelWidgetWrapper::QgsPanelWidgetWrapper( QWidget *widget, QWidget *parent )
19989
: QgsPanelWidget( parent )
20090
, mWidget( widget )

0 commit comments

Comments
 (0)