Rename QgsLayerStylingPanelFactory to QgsMapLayerConfigWidgetFactory

- Move QgsMapLayerPropertiesFactory into single factory object for
  dock and properties
This commit is contained in:
Nathan 2016-07-03 21:11:18 +10:00
parent 38e65c3f75
commit fdf16e3c92
36 changed files with 243 additions and 455 deletions

View File

@ -105,7 +105,8 @@
%Include qgsmaplayeractionregistry.sip
%Include qgsmaplayercombobox.sip
%Include qgsmaplayermodel.sip
%Include qgsmaplayerpropertiesfactory.sip
%Include qgsmaplayerconfigwidget.sip
%Include qgsmaplayerconfigwidgetfactory.sip
%Include qgsmaplayerproxymodel.sip
%Include qgsmapmouseevent.sip
%Include qgsmapoverviewcanvas.sip
@ -120,7 +121,6 @@
%Include qgsmaptoolpan.sip
%Include qgsmaptooltouch.sip
%Include qgsmaptoolzoom.sip
%Include qgsmapstylepanel.sip
%Include qgsmaplayerstylemanagerwidget.sip
%Include qgsmessagebar.sip
%Include qgsmessagebaritem.sip
@ -164,7 +164,6 @@
%Include qgsunitselectionwidget.sip
%Include qgsuserinputdockwidget.sip
%Include qgsvariableeditorwidget.sip
%Include qgsvectorlayerpropertiespage.sip
%Include qgsvectorlayertools.sip
%Include qgsvertexmarker.sip

View File

@ -284,19 +284,13 @@ class QgisInterface : QObject
* @note Ownership of the factory is not transferred, and the factory must
* be unregistered when plugin is unloaded.
* @see unregisterMapLayerPropertiesFactory() */
virtual void registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
/** Unregister a previously registered tab in the vector layer properties dialog.
* @note added in QGIS 2.16
* @see registerMapLayerPropertiesFactory()
*/
virtual void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
/** Register a new tab in the layer properties dialog */
virtual void registerMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
/** Unregister a previously registered tab in the layer properties dialog */
virtual void unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
// @todo is this deprecated in favour of QgsContextHelp?
/** Open a url in the users browser. By default the QGIS doc directory is used

View File

@ -0,0 +1,29 @@
/** \ingroup gui
* \class QgsMapLayerConfigWidget
* \class A panel widget that can be shown in the map style dock
* \note added in QGIS 2.16
*/
class QgsMapLayerConfigWidget : public QgsPanelWidget
{
%TypeHeaderCode
#include <qgsmaplayerconfigwidget.h>
%End
public:
/**
* @brief A panel widget that can be shown in the map style dock
* @param layer The layer active in the dock.
* @param canvas The canvas object.
* @param parent The parent of the widget.
* @note The widget is created each time the panel is selected in the dock.
* Keep the loading light as possible for speed in the UI.
*/
QgsMapLayerConfigWidget(QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0);
public slots:
/**
* @brief Called when changes to the layer need to be made.
* Will be called when live update is enabled.
*/
virtual void apply() = 0;
};

View File

@ -0,0 +1,48 @@
/** \ingroup gui
* \class QgsMapLayerConfigWidgetFactory
* \note added in QGIS 2.16
* Factory class for creating custom map layer property pages
*/
class QgsMapLayerConfigWidgetFactory
{
%TypeHeaderCode
#include <qgsmaplayerconfigwidgetfactory.h>
%End
public:
/** Constructor */
QgsMapLayerConfigWidgetFactory();
/** Destructor */
virtual ~QgsMapLayerConfigWidgetFactory();
/**
* @brief The icon that will be shown in the UI for the panel.
* @return A QIcon for the panel icon.
*/
virtual QIcon icon() const;
/**
* @brief The title of the panel.
* @note This may or may not be shown to the user.
* @return Title of the panel
*/
virtual QString title() const;
/**
* @brief Check if the layer is supported for this widget.
* @return True if this layer is supported for this widget
*/
virtual bool supportsLayer( QgsMapLayer *layer ) const;
/**
* @brief Factory fucntion to create the widget on demand as needed by the dock.
* @note This function is called each time the panel is selected. Keep it light for better UX.
* @param layer The active layer in the dock.
* @param canvas The map canvas.
* @param dockWidget True of the widget will be shown a dock style widget.
* @param parent The parent of the widget.
* @return A new QgsMapStylePanel which is shown in the map style dock.
*/
virtual QgsMapLayerConfigWidget* createWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget* parent /TransferThis/ = 0) const = 0 /Factory/;
};

View File

@ -1,34 +0,0 @@
/** \ingroup gui
* \class QgsMapLayerPropertiesFactory
* \note added in QGIS 2.16
* Factory class for creating custom map layer property pages
*/
class QgsMapLayerPropertiesFactory
{
%TypeHeaderCode
#include <qgsmaplayerpropertiesfactory.h>
%End
public:
/** Constructor */
QgsMapLayerPropertiesFactory();
/** Destructor */
virtual ~QgsMapLayerPropertiesFactory();
/**
* @brief Create a new properties page
* @param layer The layer for which to create the page
* @param parent The parent widget
* @return The new properties page instance
*/
virtual QgsVectorLayerPropertiesPage* createVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget* parent ) = 0;
/**
* @brief Creates the QListWidgetItem for the properties page
* @param layer The layer for which to create the item
* @param view The parent QListView
* @return The QListWidgetItem for the properties page
*/
virtual QListWidgetItem* createVectorLayerPropertiesItem( QgsVectorLayer* layer, QListWidget* view ) = 0 /Factory/;
};

View File

@ -2,7 +2,7 @@
* @brief The QgsMapLayerStyleManagerWidget class which is used to visually manage
* the layer styles.
*/
class QgsMapLayerStyleManagerWidget : QgsLayerStylingPanel
class QgsMapLayerStyleManagerWidget : QgsMapLayerConfigWidget
{
%TypeHeaderCode
#include "qgsmaplayerstylemanagerwidget.h"

View File

@ -1,86 +0,0 @@
/** \ingroup gui
* \class A panel widget that can be shown in the map style dock
* \note added in QGIS 2.16
*/
class QgsLayerStylingPanel : public QgsPanelWidget
{
%TypeHeaderCode
#include <qgsmapstylepanel.h>
%End
public:
/**
* @brief A panel widget that can be shown in the map style dock
* @param layer The layer active in the dock.
* @param canvas The canvas object.
* @param parent The parent of the widget.
* @note The widget is created each time the panel is selected in the dock.
* Keep the loading light as possible for speed in the UI.
*/
QgsLayerStylingPanel(QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0);
signals:
/**
* @brief Nofity the map style dock that something has changed and
* we need to update the map.
* You should emit this when any of the widgets are changed if live
* update is enabled apply() will get called to apply the changes to the layer.
*/
void widgetChanged();
public slots:
/**
* @brief Called when changes to the layer need to be made.
* Will be called when live update is enabled.
*/
virtual void apply() = 0;
};
/** \ingroup gui
* \class QgsLayerStylingPanelFactory
* \note added in QGIS 2.16
*/
class QgsLayerStylingPanelFactory
{
%TypeHeaderCode
#include <qgsmapstylepanel.h>
%End
public:
typedef QFlags<QgsMapLayer::LayerType> LayerTypesFlags;
/** Constructor */
QgsLayerStylingPanelFactory();
/** Destructor */
virtual ~QgsLayerStylingPanelFactory();
/**
* @brief The icon that will be shown in the UI for the panel.
* @return A QIcon for the panel icon.
*/
virtual QIcon icon() = 0;
/**
* @brief The title of the panel..
* @note This may or may not be shown to the user.
* @return Title of the panel
*/
virtual QString title() = 0;
/**
* @brief Check if the layer is supported for this widget.
* @return True if this layer is supported for this widget
*/
virtual bool supportsLayer( QgsMapLayer *layer ) = 0;
/**
* @brief Factory fucntion to create the widget on demand as needed by the dock.
* @note This function is called each time the panel is selected. Keep it light for better UX.
* @param layer The active layer in the dock.
* @param canvas The map canvas.
* @param parent The parent of the widget.
* @return A new QgsLayerStylingPanel which is shown in the map style dock.
*/
virtual QgsLayerStylingPanel* createPanel( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget* parent /TransferThis/ ) = 0 /Factory/;
};

View File

@ -1,22 +0,0 @@
/** \ingroup gui
* \class QgsVectorLayerPropertiesPage
* \note added in QGIS 2.16
* Base class for custom vector layer property pages
*/
class QgsVectorLayerPropertiesPage : QWidget
{
%TypeHeaderCode
#include <qgsvectorlayerpropertiespage.h>
%End
public:
/** Constructor for QgsVectorLayerPropertiesPage.
* @param parent parent widget
*/
explicit QgsVectorLayerPropertiesPage( QWidget *parent /TransferThis/ = 0 );
public slots:
/** Apply changes */
virtual void apply() = 0;
};

View File

@ -1,4 +1,4 @@
class QgsRendererRasterPropertiesWidget : QgsLayerStylingPanel
class QgsRendererRasterPropertiesWidget : QgsMapLayerConfigWidget
{
%TypeHeaderCode
#include <qgsrendererrasterpropertieswidget.h>

View File

@ -776,7 +776,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mMapStylingDock = new QgsDockWidget( this );
mMapStylingDock->setWindowTitle( tr( "Layer Styling" ) );
mMapStylingDock->setObjectName( "LayerStyling" );
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mMapStylePanelFactories );
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mMapLayerPanelFactories );
mMapStylingDock->setWidget( mMapStyleWidget );
connect( mMapStyleWidget, SIGNAL( styleChanged( QgsMapLayer* ) ), this, SLOT( updateLabelToolButtons() ) );
connect( mMapStylingDock, SIGNAL( visibilityChanged( bool ) ), mActionStyleDock, SLOT( setChecked( bool ) ) );
@ -9123,28 +9123,18 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory )
#endif
}
void QgisApp::registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory )
void QgisApp::registerMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory )
{
mMapLayerPropertiesFactories << factory;
}
void QgisApp::unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory )
{
mMapLayerPropertiesFactories.removeAll( factory );
}
void QgisApp::registerMapStylePanelFactory( QgsLayerStylingPanelFactory *factory )
{
mMapStylePanelFactories << factory;
mMapLayerPanelFactories << factory;
if ( mMapStyleWidget )
mMapStyleWidget->setPageFactories( mMapStylePanelFactories );
mMapStyleWidget->setPageFactories( mMapLayerPanelFactories );
}
void QgisApp::unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory *factory )
void QgisApp::unregisterMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory )
{
mMapStylePanelFactories.removeAll( factory );
mMapLayerPanelFactories.removeAll( factory );
if ( mMapStyleWidget )
mMapStyleWidget->setPageFactories( mMapStylePanelFactories );
mMapStyleWidget->setPageFactories( mMapLayerPanelFactories );
}
/** Get a pointer to the currently selected map layer */
@ -11367,7 +11357,7 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )
#else
QgsVectorLayerProperties *vlp = new QgsVectorLayerProperties( vlayer, this );
#endif
Q_FOREACH ( QgsMapLayerPropertiesFactory* factory, mMapLayerPropertiesFactories )
Q_FOREACH ( QgsMapLayerConfigWidgetFactory* factory, mMapLayerPanelFactories )
{
vlp->addPropertiesPageFactory( factory );
}

View File

@ -57,8 +57,7 @@ class QgsLayerTreeMapCanvasBridge;
class QgsLayerTreeView;
class QgsMapCanvas;
class QgsMapLayer;
class QgsMapLayerPropertiesFactory;
class QgsLayerStylingPanelFactory;
class QgsMapLayerConfigWidgetFactory;
class QgsMapTip;
class QgsMapTool;
class QgsMapToolAdvancedDigitizing;
@ -508,16 +507,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void parseVersionInfo( QNetworkReply* reply, int& latestVersion, QStringList& versionInfo );
/** Register a new tab in the layer properties dialog */
void registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory );
void registerMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory );
/** Unregister a previously registered tab in the layer properties dialog */
void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory );
/** Register a new tab in the layer properties dialog */
void registerMapStylePanelFactory( QgsLayerStylingPanelFactory* factory );
/** Unregister a previously registered tab in the layer properties dialog */
void unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory* factory );
void unregisterMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory );
public slots:
void layerTreeViewDoubleClicked( const QModelIndex& index );
@ -1779,8 +1772,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsSnappingUtils* mSnappingUtils;
QList<QgsMapLayerPropertiesFactory*> mMapLayerPropertiesFactories;
QList<QgsLayerStylingPanelFactory*> mMapStylePanelFactories;
QList<QgsMapLayerConfigWidgetFactory*> mMapLayerPanelFactories;
QDateTime mProjectLastModified;

View File

@ -475,26 +475,16 @@ bool QgisAppInterface::unregisterMainWindowAction( QAction* action )
return QgsShortcutsManager::instance()->unregisterAction( action );
}
void QgisAppInterface::registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory )
void QgisAppInterface::registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory )
{
qgis->registerMapLayerPropertiesFactory( factory );
}
void QgisAppInterface::unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory )
void QgisAppInterface::unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory )
{
qgis->unregisterMapLayerPropertiesFactory( factory );
}
void QgisAppInterface::registerMapStylePanelFactory( QgsLayerStylingPanelFactory *factory )
{
qgis->registerMapStylePanelFactory( factory );
}
void QgisAppInterface::unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory *factory )
{
qgis->unregisterMapStylePanelFactory( factory );
}
//! Menus
Q_DECL_DEPRECATED QMenu *QgisAppInterface::fileMenu() { return qgis->projectMenu(); }
QMenu *QgisAppInterface::projectMenu() { return qgis->projectMenu(); }

View File

@ -293,19 +293,13 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
* @note Ownership of the factory is not transferred, and the factory must
* be unregistered when plugin is unloaded.
* @see unregisterMapLayerPropertiesFactory() */
virtual void registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) override;
virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) override;
/** Unregister a previously registered tab in the vector layer properties dialog.
* @note added in QGIS 2.16
* @see registerMapLayerPropertiesFactory()
*/
virtual void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) override;
/** Register a new tab in the layer properties dialog */
virtual void registerMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) override;
/** Unregister a previously registered tab in the layer properties dialog */
virtual void unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) override;
virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) override;
/** Accessors for inserting items into menus and toolbars.
* An item can be inserted before any existing action.

View File

@ -25,7 +25,7 @@
#include "qgisapp.h"
QgsLabelingWidget::QgsLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canvas, QWidget* parent )
: QgsLayerStylingPanel( layer, canvas, parent )
: QgsMapLayerConfigWidget( layer, canvas, parent )
, mLayer( layer )
, mCanvas( canvas )
, mWidget( nullptr )

View File

@ -21,7 +21,7 @@
#include <qgspallabeling.h>
#include "qgsvectorlayerlabeling.h"
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
class QgsLabelingGui;
class QgsMapCanvas;
@ -32,7 +32,7 @@ class QgsMapLayer;
/**
* Master widget for configuration of labeling of a vector layer
*/
class QgsLabelingWidget : public QgsLayerStylingPanel, private Ui::QgsLabelingWidget
class QgsLabelingWidget : public QgsMapLayerConfigWidget, private Ui::QgsLabelingWidget
{
Q_OBJECT
public:

View File

@ -38,11 +38,12 @@
#include "qgsrendererv2registry.h"
#include "qgsmaplayerregistry.h"
#include "qgsrasterlayer.h"
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
#include "qgsmaplayerstylemanagerwidget.h"
#include "qgsruntimeprofiler.h"
QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas* canvas, QList<QgsLayerStylingPanelFactory*> pages, QWidget *parent )
QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas* canvas, QList<QgsMapLayerConfigWidgetFactory*> pages, QWidget *parent )
: QWidget( parent )
, mNotSupportedPage( 0 )
, mLayerPage( 1 )
@ -70,7 +71,7 @@ QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas* canvas, QList<QgsLay
mStyleManagerFactory = new QgsLayerStyleManagerWidgetFactory();
QList<QgsLayerStylingPanelFactory*> l;
QList<QgsMapLayerConfigWidgetFactory*> l;
setPageFactories( pages );
connect( mUndoButton, SIGNAL( pressed() ), this, SLOT( undo() ) );
@ -91,7 +92,7 @@ QgsLayerStylingWidget::~QgsLayerStylingWidget()
delete mStyleManagerFactory;
}
void QgsLayerStylingWidget::setPageFactories( QList<QgsLayerStylingPanelFactory *> factories )
void QgsLayerStylingWidget::setPageFactories( QList<QgsMapLayerConfigWidgetFactory *> factories )
{
mPageFactories = factories;
// Always append the style manager factory at the bottom of the list
@ -170,7 +171,7 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer )
mOptionsListWidget->addItem( histogramItem );
}
Q_FOREACH ( QgsLayerStylingPanelFactory* factory, mPageFactories )
Q_FOREACH ( QgsMapLayerConfigWidgetFactory* factory, mPageFactories )
{
if ( factory->supportsLayer( layer ) )
{
@ -242,7 +243,7 @@ void QgsLayerStylingWidget::apply()
mRasterStyleWidget->apply();
styleWasChanged = true;
}
else if ( QgsLayerStylingPanel* widget = qobject_cast<QgsLayerStylingPanel*>( current ) )
else if ( QgsMapLayerConfigWidget* widget = qobject_cast<QgsMapLayerConfigWidget*>( current ) )
{
widget->apply();
styleWasChanged = true;
@ -316,7 +317,7 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
// TODO Make all widgets use this method.
if ( mUserPages.contains( row ) )
{
QgsLayerStylingPanel* panel = mUserPages[row]->createPanel( mCurrentLayer, mMapCanvas, mWidgetStack );
QgsMapLayerConfigWidget* panel = mUserPages[row]->createWidget( mCurrentLayer, mMapCanvas, mWidgetStack );
if ( panel )
{
connect( panel, SIGNAL( widgetChanged( QgsPanelWidget* ) ), this, SLOT( autoApply() ) );
@ -477,23 +478,24 @@ void QgsMapLayerStyleCommand::redo()
mLayer->triggerRepaint();
}
QIcon QgsLayerStyleManagerWidgetFactory::icon()
QIcon QgsLayerStyleManagerWidgetFactory::icon() const
{
return QgsApplication::getThemeIcon( "propertyicons/stylepreset.svg" );
}
QString QgsLayerStyleManagerWidgetFactory::title()
QString QgsLayerStyleManagerWidgetFactory::title() const
{
return QString();
}
QgsLayerStylingPanel *QgsLayerStyleManagerWidgetFactory::createPanel( QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent )
QgsMapLayerConfigWidget *QgsLayerStyleManagerWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const
{
Q_UNUSED( dockMode );
return new QgsMapLayerStyleManagerWidget( layer, canvas, parent );
}
bool QgsLayerStyleManagerWidgetFactory::supportsLayer( QgsMapLayer *layer )
bool QgsLayerStyleManagerWidgetFactory::supportsLayer( QgsMapLayer *layer ) const
{
return ( layer->type() == QgsMapLayer::VectorLayer || layer->type() == QgsMapLayer::RasterLayer );
}

View File

@ -27,7 +27,8 @@
#include <QTimer>
#include "ui_qgsmapstylingwidgetbase.h"
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
#include "qgsmaplayerconfigwidgetfactory.h"
class QgsLabelingWidget;
class QgsMapLayer;
@ -36,16 +37,15 @@ class QgsRendererV2PropertiesDialog;
class QgsRendererRasterPropertiesWidget;
class QgsUndoWidget;
class QgsRasterHistogramWidget;
class QgsLayerStylingPanelFactory;
class QgsMapLayerStyleManagerWidget;
class APP_EXPORT QgsLayerStyleManagerWidgetFactory : public QgsLayerStylingPanelFactory
class APP_EXPORT QgsLayerStyleManagerWidgetFactory : public QgsMapLayerConfigWidgetFactory
{
public:
QIcon icon() override;
QString title() override;
QgsLayerStylingPanel *createPanel( QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent ) override;
bool supportsLayer( QgsMapLayer *layer ) override;
QIcon icon() const override;
QString title() const override;
QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const override;
bool supportsLayer( QgsMapLayer *layer ) const override;
};
class APP_EXPORT QgsMapLayerStyleCommand : public QUndoCommand
@ -76,11 +76,11 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
History,
};
QgsLayerStylingWidget( QgsMapCanvas *canvas, QList<QgsLayerStylingPanelFactory *> pages, QWidget *parent = 0 );
QgsLayerStylingWidget( QgsMapCanvas *canvas, QList<QgsMapLayerConfigWidgetFactory *> pages, QWidget *parent = 0 );
~QgsLayerStylingWidget();
QgsMapLayer* layer() { return mCurrentLayer; }
void setPageFactories( QList<QgsLayerStylingPanelFactory*> factories );
void setPageFactories( QList<QgsMapLayerConfigWidgetFactory *> factories );
/** Sets whether updates of the styling widget are blocked. This can be called to prevent
* the widget being refreshed multiple times when a batch of layer style changes are
@ -122,8 +122,8 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
QgsMapLayer* mCurrentLayer;
QgsLabelingWidget *mLabelingWidget;
QgsRendererRasterPropertiesWidget* mRasterStyleWidget;
QList<QgsLayerStylingPanelFactory*> mPageFactories;
QMap<int, QgsLayerStylingPanelFactory*> mUserPages;
QList<QgsMapLayerConfigWidgetFactory*> mPageFactories;
QMap<int, QgsMapLayerConfigWidgetFactory*> mUserPages;
QgsLayerStyleManagerWidgetFactory* mStyleManagerFactory;
};

View File

@ -35,7 +35,7 @@
#include "qgslabel.h"
#include "qgsgenericprojectionselector.h"
#include "qgslogger.h"
#include "qgsmaplayerpropertiesfactory.h"
#include "qgsmaplayerconfigwidgetfactory.h"
#include "qgsmaplayerregistry.h"
#include "qgsmaplayerstyleguiutils.h"
#include "qgspluginmetadata.h"
@ -45,7 +45,6 @@
#include "qgsloadstylefromdbdialog.h"
#include "qgsvectorlayer.h"
#include "qgsvectorlayerproperties.h"
#include "qgsvectorlayerpropertiespage.h"
#include "qgsconfig.h"
#include "qgsvectordataprovider.h"
#include "qgsquerybuilder.h"
@ -328,14 +327,18 @@ void QgsVectorLayerProperties::setLabelCheckBox()
labelCheckBox->setCheckState( Qt::Checked );
}
void QgsVectorLayerProperties::addPropertiesPageFactory( QgsMapLayerPropertiesFactory* factory )
void QgsVectorLayerProperties::addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory* factory )
{
QListWidgetItem* item = factory->createVectorLayerPropertiesItem( mLayer, mOptionsListWidget );
QListWidgetItem* item = new QListWidgetItem();
item->setIcon( factory->icon() );
item->setText( factory->title() );
item->setToolTip( factory->title() );
if ( item )
{
mOptionsListWidget->addItem( item );
QgsVectorLayerPropertiesPage* page = factory->createVectorLayerPropertiesPage( mLayer, this );
QgsMapLayerConfigWidget* page = factory->createWidget( mLayer, nullptr, this );
mLayerPropertiesPages << page;
mOptionsStackedWidget->addWidget( page );
}
@ -628,7 +631,7 @@ void QgsVectorLayerProperties::apply()
diagramPropertiesDialog->apply();
// apply all plugin dialogs
Q_FOREACH ( QgsVectorLayerPropertiesPage* page, mLayerPropertiesPages )
Q_FOREACH ( QgsMapLayerConfigWidget* page, mLayerPropertiesPages )
{
page->apply();
}

View File

@ -42,8 +42,8 @@ class QgsLabelingWidget;
class QgsDiagramProperties;
class QgsFieldsProperties;
class QgsRendererV2PropertiesDialog;
class QgsMapLayerPropertiesFactory;
class QgsVectorLayerPropertiesPage;
class QgsMapLayerConfigWidgetFactory;
class QgsMapLayerConfigWidget;
class QgsPanelWidget;
class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private Ui::QgsVectorLayerPropertiesBase
@ -78,7 +78,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
bool deleteAttribute( int attr );
/** Adds a properties page factory to the vector layer properties dialog. */
void addPropertiesPageFactory( QgsMapLayerPropertiesFactory *factory );
void addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory *factory );
public slots:
@ -198,7 +198,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
QList< QgsVectorJoinInfo > mOldJoins;
//! A list of additional pages provided by plugins
QList<QgsVectorLayerPropertiesPage*> mLayerPropertiesPages;
QList<QgsMapLayerConfigWidget*> mLayerPropertiesPages;
/** Previous layer style. Used to reset style to previous state if new style
* was loaded but dialog is cancelled */

View File

@ -244,7 +244,7 @@ SET(QGIS_GUI_SRCS
qgsmaplayeractionregistry.cpp
qgsmaplayercombobox.cpp
qgsmaplayermodel.cpp
qgsmaplayerpropertiesfactory.cpp
qgsmaplayerconfigwidgetfactory.cpp
qgsmaplayerproxymodel.cpp
qgsmaplayerstylemanagerwidget.cpp
qgsmapmouseevent.cpp
@ -259,7 +259,7 @@ SET(QGIS_GUI_SRCS
qgsmaptoolidentifyfeature.cpp
qgsmaptoolpan.cpp
qgsmaptoolzoom.cpp
qgsmapstylepanel.cpp
qgsmaplayerconfigwidget.cpp
qgsmessagebar.cpp
qgsmessagebaritem.cpp
qgsmessagelogviewer.cpp
@ -303,7 +303,6 @@ SET(QGIS_GUI_SRCS
qgsunitselectionwidget.cpp
qgsuserinputdockwidget.cpp
qgsvariableeditorwidget.cpp
qgsvectorlayerpropertiespage.cpp
qgsvertexmarker.cpp
)
@ -411,7 +410,7 @@ SET(QGIS_GUI_MOC_HDRS
qgsmaptoolidentifyfeature.h
qgsmaptoolpan.h
qgsmaptoolzoom.h
qgsmapstylepanel.h
qgsmaplayerconfigwidget.h
qgsmessagebar.h
qgsmessagebaritem.h
qgsmessagelogviewer.h
@ -449,7 +448,6 @@ SET(QGIS_GUI_MOC_HDRS
qgsunitselectionwidget.h
qgsuserinputdockwidget.h
qgsvariableeditorwidget.h
qgsvectorlayerpropertiespage.h
raster/qgsmultibandcolorrendererwidget.h
raster/qgspalettedrendererwidget.h
@ -631,7 +629,7 @@ SET(QGIS_GUI_HDRS
qgsmapcanvassnapper.h
qgsmapcanvassnappingutils.h
qgsmapcanvastracer.h
qgsmaplayerpropertiesfactory.h
qgsmaplayerconfigwidgetfactory.h
qgsmapmouseevent.h
qgsmaptip.h
qgsnumericsortlistviewitem.h

View File

@ -34,8 +34,7 @@ class QgsLayerTreeView;
class QgsLegendInterface;
class QgsMapCanvas;
class QgsMapLayer;
class QgsMapLayerPropertiesFactory;
class QgsLayerStylingPanelFactory;
class QgsMapLayerConfigWidgetFactory;
class QgsMessageBar;
class QgsPluginManagerInterface;
class QgsRasterLayer;
@ -335,19 +334,13 @@ class GUI_EXPORT QgisInterface : public QObject
* @note Ownership of the factory is not transferred, and the factory must
* be unregistered when plugin is unloaded.
* @see unregisterMapLayerPropertiesFactory() */
virtual void registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
/** Unregister a previously registered tab in the vector layer properties dialog.
* @note added in QGIS 2.16
* @see registerMapLayerPropertiesFactory()
*/
virtual void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
/** Register a new tab in the layer properties dialog */
virtual void registerMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
/** Unregister a previously registered tab in the layer properties dialog */
virtual void unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
// @todo is this deprecated in favour of QgsContextHelp?
/** Open a url in the users browser. By default the QGIS doc directory is used

View File

@ -12,23 +12,13 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
#include "qgspanelwidget.h"
QgsLayerStylingPanel::QgsLayerStylingPanel( QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent )
QgsMapLayerConfigWidget::QgsMapLayerConfigWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent )
: QgsPanelWidget( parent )
, mLayer( layer )
, mMapCanvas( canvas )
{
}
QgsLayerStylingPanelFactory::QgsLayerStylingPanelFactory()
{
}
QgsLayerStylingPanelFactory::~QgsLayerStylingPanelFactory()
{
}

View File

@ -1,5 +1,5 @@
/***************************************************************************
qgsmapstylepanel.h
qgsmaplayerconfigwidget.h
---------------------
begin : June 2016
copyright : (C) 2016 by Nathan Woodrow
@ -24,11 +24,11 @@
class QgsMapCanvas;
/** \ingroup gui
* \class QgsLayerStylingPanel
* \class QgsMapLayerConfigWidget
* \brief A panel widget that can be shown in the map style dock
* \note added in QGIS 2.16
*/
class GUI_EXPORT QgsLayerStylingPanel : public QgsPanelWidget
class GUI_EXPORT QgsMapLayerConfigWidget : public QgsPanelWidget
{
Q_OBJECT
public:
@ -41,7 +41,7 @@ class GUI_EXPORT QgsLayerStylingPanel : public QgsPanelWidget
* @note The widget is created each time the panel is selected in the dock.
* Keep the loading light as possible for speed in the UI.
*/
QgsLayerStylingPanel( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0 );
QgsMapLayerConfigWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0 );
public slots:
/**
@ -55,51 +55,4 @@ class GUI_EXPORT QgsLayerStylingPanel : public QgsPanelWidget
QgsMapCanvas* mMapCanvas;
};
/** \ingroup gui
* \class QgsLayerStylingPanelFactory
* \note added in QGIS 2.16
*/
class GUI_EXPORT QgsLayerStylingPanelFactory
{
public:
Q_DECLARE_FLAGS( LayerTypesFlags, QgsMapLayer::LayerType )
/** Constructor */
QgsLayerStylingPanelFactory();
/** Destructor */
virtual ~QgsLayerStylingPanelFactory();
/**
* @brief The icon that will be shown in the UI for the panel.
* @return A QIcon for the panel icon.
*/
virtual QIcon icon() = 0;
/**
* @brief The title of the panel.
* @note This may or may not be shown to the user.
* @return Title of the panel
*/
virtual QString title() = 0;
/**
* @brief Check if the layer is supported for this widget.
* @return True if this layer is supported for this widget
*/
virtual bool supportsLayer( QgsMapLayer *layer ) = 0;
/**
* @brief Factory fucntion to create the widget on demand as needed by the dock.
* @note This function is called each time the panel is selected. Keep it light for better UX.
* @param layer The active layer in the dock.
* @param canvas The map canvas.
* @param parent The parent of the widget.
* @return A new QgsMapStylePanel which is shown in the map style dock.
*/
virtual QgsLayerStylingPanel* createPanel( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget* parent ) = 0;
};
#endif // QGSMAPSTYLEPANEL_H

View File

@ -1,5 +1,5 @@
/***************************************************************************
qgslayeroptionsfactory.cpp
qgsmaplayerconfigwidgetfactory.cpp
--------------------------------------
Date : 9.7.2013
Copyright : (C) 2013 Matthias Kuhn
@ -13,12 +13,18 @@
* *
***************************************************************************/
#include "qgsmaplayerpropertiesfactory.h"
#include "qgsmaplayerconfigwidgetfactory.h"
QgsMapLayerPropertiesFactory::QgsMapLayerPropertiesFactory()
QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory()
{
}
QgsMapLayerPropertiesFactory::~QgsMapLayerPropertiesFactory()
QgsMapLayerConfigWidgetFactory::~QgsMapLayerConfigWidgetFactory()
{
}
bool QgsMapLayerConfigWidgetFactory::supportsLayer( QgsMapLayer *layer ) const
{
Q_UNUSED( layer );
return true;
}

View File

@ -0,0 +1,68 @@
/***************************************************************************
qgslayeroptionsfactory.h
--------------------------------------
Date : 9.7.2013
Copyright : (C) 2013 Matthias Kuhn
Email : matthias dot kuhn at gmx dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLAYERPROPERTIESFACTORY_H
#define QGSLAYERPROPERTIESFACTORY_H
#include <QListWidgetItem>
#include "qgsmaplayerconfigwidget.h"
/** \ingroup gui
* \class QgsMapLayerPropertiesFactory
* \note added in QGIS 2.16
* Factory class for creating custom map layer property pages
*/
class GUI_EXPORT QgsMapLayerConfigWidgetFactory
{
public:
/** Constructor */
QgsMapLayerConfigWidgetFactory();
/** Destructor */
virtual ~QgsMapLayerConfigWidgetFactory();
/**
* @brief The icon that will be shown in the UI for the panel.
* @return A QIcon for the panel icon.
*/
virtual QIcon icon() const { return QIcon(); }
/**
* @brief The title of the panel.
* @note This may or may not be shown to the user.
* @return Title of the panel
*/
virtual QString title() const { return QString(); }
/**
* @brief Check if the layer is supported for this widget.
* @return True if this layer is supported for this widget
*/
virtual bool supportsLayer( QgsMapLayer *layer ) const;
/**
* @brief Factory fucntion to create the widget on demand as needed by the dock.
* @note This function is called each time the panel is selected. Keep it light for better UX.
* @param layer The active layer in the dock.
* @param canvas The map canvas.
* @param dockWidget True of the widget will be shown a dock style widget.
* @param parent The parent of the widget.
* @return A new QgsMapStylePanel which is shown in the map style dock.
*/
virtual QgsMapLayerConfigWidget* createWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget* parent = 0 ) const = 0;
};
#endif // QGSLAYERPROPERTIESFACTORY_H

View File

@ -1,54 +0,0 @@
/***************************************************************************
qgslayeroptionsfactory.h
--------------------------------------
Date : 9.7.2013
Copyright : (C) 2013 Matthias Kuhn
Email : matthias dot kuhn at gmx dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLAYERPROPERTIESFACTORY_H
#define QGSLAYERPROPERTIESFACTORY_H
#include <QListWidgetItem>
#include "qgsvectorlayerpropertiespage.h"
/** \ingroup gui
* \class QgsMapLayerPropertiesFactory
* \note added in QGIS 2.16
* Factory class for creating custom map layer property pages
*/
class GUI_EXPORT QgsMapLayerPropertiesFactory
{
public:
/** Constructor */
QgsMapLayerPropertiesFactory();
/** Destructor */
virtual ~QgsMapLayerPropertiesFactory();
/**
* @brief Create a new properties page
* @param layer The layer for which to create the page
* @param parent The parent widget
* @return The new properties page instance
*/
virtual QgsVectorLayerPropertiesPage* createVectorLayerPropertiesPage( QgsVectorLayer* layer, QWidget* parent ) = 0;
/**
* @brief Creates the QListWidgetItem for the properties page
* @param layer The layer for which to create the item
* @param view The parent QListView
* @return The QListWidgetItem for the properties page
*/
virtual QListWidgetItem* createVectorLayerPropertiesItem( QgsVectorLayer* layer, QListWidget* view ) = 0;
};
#endif // QGSLAYERPROPERTIESFACTORY_H

View File

@ -24,7 +24,7 @@
#include "qgslogger.h"
#include "qgsmaplayer.h"
#include "qgsmapcanvas.h"
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
#include "qgsmaplayerstylemanager.h"
#include "qgsvectordataprovider.h"
#include "qgsrasterdataprovider.h"
@ -33,7 +33,7 @@
QgsMapLayerStyleManagerWidget::QgsMapLayerStyleManagerWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent )
: QgsLayerStylingPanel( layer, canvas, parent )
: QgsMapLayerConfigWidget( layer, canvas, parent )
{
mModel = new QStandardItemModel( this );
mStyleList = new QListView( this );

View File

@ -19,7 +19,7 @@
#include <QListView>
#include <QStandardItemModel>
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
class QgsMapLayer;
class QgsMapCanvas;
@ -29,7 +29,7 @@ class QgsMapCanvas;
* @brief The QgsMapLayerStyleManagerWidget class which is used to visually manage
* the layer styles.
*/
class GUI_EXPORT QgsMapLayerStyleManagerWidget : public QgsLayerStylingPanel
class GUI_EXPORT QgsMapLayerStyleManagerWidget : public QgsMapLayerConfigWidget
{
Q_OBJECT
public:

View File

@ -1,22 +0,0 @@
/***************************************************************************
qgsvectorlayerpropertiespage.cpp
--------------------------------------
Date : 8.7.2013
Copyright : (C) 2013 Matthias Kuhn
Email : matthias dot kuhn at gmx dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsvectorlayerpropertiespage.h"
QgsVectorLayerPropertiesPage::QgsVectorLayerPropertiesPage( QWidget *parent )
: QWidget( parent )
{
}

View File

@ -1,43 +0,0 @@
/***************************************************************************
qgsvectorlayerpropertiespage.h
--------------------------------------
Date : 8.7.2013
Copyright : (C) 2013 Matthias Kuhn
Email : matthias dot kuhn at gmx dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSVECTORLAYERPROPERTIESPAGE_H
#define QGSVECTORLAYERPROPERTIESPAGE_H
#include <QWidget>
class QgsVectorLayer;
/** \ingroup gui
* \class QgsVectorLayerPropertiesPage
* \note added in QGIS 2.16
* Base class for custom vector layer property pages
*/
class GUI_EXPORT QgsVectorLayerPropertiesPage : public QWidget
{
Q_OBJECT
public:
/** Constructor for QgsVectorLayerPropertiesPage.
* @param parent parent widget
*/
explicit QgsVectorLayerPropertiesPage( QWidget *parent = nullptr );
public slots:
/** Apply changes */
virtual void apply() = 0;
};
#endif // QGSVECTORLAYERPROPERTIESPAGE_H

View File

@ -55,7 +55,7 @@
//#define RASTER_HISTOGRAM_BINS 256
QgsRasterHistogramWidget::QgsRasterHistogramWidget( QgsRasterLayer* lyr, QWidget *parent )
: QgsLayerStylingPanel( lyr, nullptr, parent )
: QgsMapLayerConfigWidget( lyr, nullptr, parent )
, mRasterLayer( lyr )
, mRendererWidget( nullptr )
{

View File

@ -19,7 +19,7 @@
#include "ui_qgsrasterhistogramwidgetbase.h"
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
class QgsRasterLayer;
class QgsRasterRendererWidget;
@ -37,7 +37,7 @@ typedef QPointF QwtDoublePoint;
*@author Etienne Tourigny
*/
class GUI_EXPORT QgsRasterHistogramWidget : public QgsLayerStylingPanel, private Ui::QgsRasterHistogramWidgetBase
class GUI_EXPORT QgsRasterHistogramWidget : public QgsMapLayerConfigWidget, private Ui::QgsRasterHistogramWidgetBase
{
Q_OBJECT

View File

@ -37,7 +37,7 @@
QgsRasterTransparencyWidget::QgsRasterTransparencyWidget( QgsRasterLayer *layer, QgsMapCanvas* canvas, QWidget *parent )
: QgsLayerStylingPanel( layer, canvas, parent )
: QgsMapLayerConfigWidget( layer, canvas, parent )
, TRSTRING_NOT_SET( tr( "Not Set" ) )
, mRasterLayer( layer )
, mMapCanvas( canvas )

View File

@ -19,7 +19,7 @@
#include "ui_qgsrastertransparencywidget.h"
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
class QgsRasterLayer;
class QgsRasterRenderer;
@ -31,7 +31,7 @@ class QgsPoint;
/** \ingroup gui
* @brief Widget to control a layers transparency and related options
*/
class GUI_EXPORT QgsRasterTransparencyWidget : public QgsLayerStylingPanel, private Ui::QgsRasterTransparencyWidget
class GUI_EXPORT QgsRasterTransparencyWidget : public QgsMapLayerConfigWidget, private Ui::QgsRasterTransparencyWidget
{
Q_OBJECT
public:

View File

@ -47,7 +47,7 @@ static void _initRendererWidgetFunctions()
QgsRendererRasterPropertiesWidget::QgsRendererRasterPropertiesWidget( QgsMapLayer *layer, QgsMapCanvas* canvas, QWidget *parent )
: QgsLayerStylingPanel( layer, canvas, parent )
: QgsMapLayerConfigWidget( layer, canvas, parent )
, mRendererWidget( nullptr )
{
mRasterLayer = qobject_cast<QgsRasterLayer*>( layer );

View File

@ -20,7 +20,7 @@
#include "ui_qgsrendererrasterpropswidgetbase.h"
#include "qgsmapstylepanel.h"
#include "qgsmaplayerconfigwidget.h"
class QgsRasterLayer;
@ -30,7 +30,7 @@ class QgsRasterRendererWidget;
/** \ingroup gui
* \class QgsRendererRasterPropertiesWidget
*/
class GUI_EXPORT QgsRendererRasterPropertiesWidget : public QgsLayerStylingPanel, private Ui::QgsRendererRasterPropsWidgetBase
class GUI_EXPORT QgsRendererRasterPropertiesWidget : public QgsMapLayerConfigWidget, private Ui::QgsRendererRasterPropsWidgetBase
{
Q_OBJECT