Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #4514 from nyalldawson/gui_instance
Browse files Browse the repository at this point in the history
Make a new global QgsGui singleton
  • Loading branch information
nyalldawson committed May 14, 2017
2 parents c3c694f + a8b10a2 commit f8f7d60
Show file tree
Hide file tree
Showing 161 changed files with 650 additions and 431 deletions.
2 changes: 1 addition & 1 deletion cmake/FindQGIS.cmake
Expand Up @@ -142,7 +142,7 @@ ELSE(WIN32)
# also get other frameworks' headers folders on OS X
IF (APPLE)
FIND_PATH(QGIS_GUI_INCLUDE_DIR
NAMES qgisgui.h
NAMES qgsguiutils.h
PATHS
${QGIS_BUILD_PATH}/output/lib
${QGIS_MAC_PATH}/Frameworks
Expand Down
25 changes: 22 additions & 3 deletions doc/api_break.dox
Expand Up @@ -63,6 +63,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<table>
<caption id="renamed_classes">Renamed classes</caption>
<tr><th>API 2.x<th>API 3.X
<tr><td>QgisGui<td>QgsGuiUtils
<tr><td>QgsAttributeAction<td>QgsActionManager
<tr><td>QgsAbstractGeometryV2<td>QgsAbstractGeometry
<tr><td>QgsCategorizedSymbolRendererV2<td>QgsCategorizedSymbolRenderer
Expand Down Expand Up @@ -1011,7 +1012,7 @@ QgsEditFormConfig {#qgis_api_break_3_0_QgsEditFormConfig}

- Does no longer inherit QObject
- widgetType() and widgetConfig() now reflect only the user configured values.
QgsEditorWidgetRegistry::instance()->findBest() must be used instead.
QgsEditorWidgetRegistry::findBest() must be used instead.
- widgetConfig(), setWidgetType(), setWidgetConfig() and removeWidgetConfig() now only take a string as first parameter. Access by index has been removed.
- widgetType() has been removed in favor of QgsVectorLayer::editorWidgetSetup()
- expression(), setExpression(), expressionDescription() and setExpressionDescription()
Expand Down Expand Up @@ -1213,6 +1214,7 @@ plugins calling this method will need to be updated.
QgsEditorWidgetRegistry {#qgis_api_break_3_0_QgsEditorWidgetRegistry}
-----------------------

- The instance() singleton was removed. Use QgsGui::editorWidgetRegistry() instead.
- The signature of isFieldSupported() has been changed to return an unsigned
integer (how good it supports the given field) and is now const.

Expand Down Expand Up @@ -1307,6 +1309,12 @@ QgsLayerPropertiesWidget {#qgis_api_break_3_0_QgsLayerPropertiesWidget}
- expressionContext(), setExpressionContext(), setMapCanvas() and mapCanvas() have been removed in favor of setContext()/context()


QgsLayerTreeEmbeddedWidgetRegistry {#qgis_api_break_3_0_QgsLayerTreeEmbeddedWidgetRegistry}
----------------------------------

- QgsLayerTreeEmbeddedWidgetRegistry::instance() has been removed. Use QgsGui::layerTreeEmbeddedWidgetRegistry() instead.


QgsLayerTreeGroup {#qgis_api_break_3_0_QgsLayerTreeGroup}
-----------------

Expand Down Expand Up @@ -1438,6 +1446,13 @@ screenUpdateRequested() were removed. These members have had no effect for a num
- the invalidTransformInput() slot was removed - calling this slot had no effect
- metadata() was renamed to htmlMetadata()


QgsMapLayerActionRegistry {#qgis_api_break_3_0_QgsMapLayerActionRegistry}
-------------------------

- This class is no longer a singleton and instance() has been removed. Instead use QgsGui::mapLayerActionRegistry().


QgsMapOverviewCanvas {#qgis_api_break_3_0_QgsMapOverviewCanvas}
--------------------

Expand Down Expand Up @@ -1822,10 +1837,10 @@ QgsRenderChecker {#qgis_api_break_3_0_QgsRenderChecker}
setExcludeAttributesWms()
- excludeAttributesWFS() and setExcludeAttributesWFS() have been renamed to excludeAttributesWfs() and
setExcludeAttributesWfs()
- editorWidgetV2() and editorWidgetV2Config() have been removed and QgsEditorWidgetRegistry::instance()->findBest() must be used instead.
- editorWidgetV2() and editorWidgetV2Config() have been removed and QgsEditorWidgetRegistry::findBest() must be used instead.
- setEditorWidgetV2(), setEditorWidgetV2Config() have been removed and their equivalent in editFormConfig() must be used instead.
- setCheckedState() is removed. Use `editFormConfig()->setWidgetConfig()` instead.
- valueMap(), valueRelation(), dateFormat(), widgetSize() have been removed. Use QgsEditorWidgetRegistry::instance()->findBest().config() instead.
- valueMap(), valueRelation(), dateFormat(), widgetSize() have been removed. Use QgsEditorWidgetRegistry::findBest().config() instead.


QgsRenderContext {#qgis_api_break_3_0_QgsRenderContext}
Expand Down Expand Up @@ -1909,6 +1924,10 @@ QgsServer {#qgis_api_break_3_0_QgsServer}
- QgsServer::handleRequest( const QString &urlstr ) has been removed in favour of the new
- QgsServer::handleRequest( QgsServerRequest &request, QgsServerResponse &response ) has been added

QgsShortcutsManager {#qgis_api_break_3_0_QgsShortcutsManager}
-------------------

- QgsShortcutsManager::instance() was removed. Use QgsGui::shortcutsManager() instead.


QgsSimpleMarkerSymbolLayer {#qgis_api_break_3_0_QgsSimpleMarkerSymbolLayer}
Expand Down
19 changes: 8 additions & 11 deletions python/gui/editorwidgets/core/qgseditorwidgetregistry.sip
Expand Up @@ -13,24 +13,24 @@
class QgsEditorWidgetRegistry : QObject
{
%Docstring
This class manages all known edit widget factories
This class manages all known edit widget factories.

QgsEditorWidgetRegistry is not usually directly created, but rather accessed through
QgsGui.editorWidgetRegistry().
%End

%TypeHeaderCode
#include "qgseditorwidgetregistry.h"
%End
public:

static QgsEditorWidgetRegistry *instance();
QgsEditorWidgetRegistry();
%Docstring
This class is a singleton and has therefore to be accessed with this method instead
of a constructor.

:return: The one and only instance of the editor widget registry
:rtype: QgsEditorWidgetRegistry
Constructor for QgsEditorWidgetRegistry. QgsEditorWidgetRegistry is not usually directly created, but rather accessed through
QgsGui.editorWidgetRegistry().
%End

static void initEditors( QgsMapCanvas *mapCanvas = 0, QgsMessageBar *messageBar = 0 );
void initEditors( QgsMapCanvas *mapCanvas = 0, QgsMessageBar *messageBar = 0 );
%Docstring
Registers all the default widgets.
Only call this once on startup of an application.
Expand Down Expand Up @@ -171,9 +171,6 @@ class QgsEditorWidgetRegistry : QObject
\param plugin The plugin (ownership is transferred)
%End

protected:
QgsEditorWidgetRegistry();

};

/************************************************************************
Expand Down
1 change: 1 addition & 0 deletions python/gui/gui.sip
Expand Up @@ -81,6 +81,7 @@
%Include qgsfloatingwidget.sip
%Include qgsfocuswatcher.sip
%Include qgsformannotation.sip
%Include qgsgui.sip
%Include qgsgeometryrubberband.sip
%Include qgsgradientcolorrampdialog.sip
%Include qgsgradientstopeditor.sip
Expand Down
7 changes: 1 addition & 6 deletions python/gui/layertree/qgslayertreeembeddedwidgetregistry.sip
Expand Up @@ -47,8 +47,7 @@ class QgsLayerTreeEmbeddedWidgetRegistry

public:

/** Means of accessing canonical single instance */
static QgsLayerTreeEmbeddedWidgetRegistry *instance();
QgsLayerTreeEmbeddedWidgetRegistry();

~QgsLayerTreeEmbeddedWidgetRegistry();

Expand All @@ -66,10 +65,6 @@ class QgsLayerTreeEmbeddedWidgetRegistry
* Returns true on success, false if the provider was not registered. */
bool removeProvider( const QString &providerId );

protected:
//! Protected constructor - use instance() to access the registry.
QgsLayerTreeEmbeddedWidgetRegistry();

private:

QgsLayerTreeEmbeddedWidgetRegistry( const QgsLayerTreeEmbeddedWidgetRegistry &other );
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsbusyindicatordialog.sip
Expand Up @@ -15,7 +15,7 @@ class QgsBusyIndicatorDialog : QDialog
* @param parent parent object (owner)
* @param fl widget flags
*/
QgsBusyIndicatorDialog( const QString &message = "", QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgisGui::ModalDialogFlags );
QgsBusyIndicatorDialog( const QString &message = "", QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags );
~QgsBusyIndicatorDialog();

QString message() const;
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgscharacterselectdialog.sip
Expand Up @@ -4,7 +4,7 @@ class QgsCharacterSelectorDialog : QDialog
#include <qgscharacterselectdialog.h>
%End
public:
QgsCharacterSelectorDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgisGui::ModalDialogFlags );
QgsCharacterSelectorDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags );
~QgsCharacterSelectorDialog();

public slots:
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgscolordialog.sip
Expand Up @@ -23,7 +23,7 @@ class QgsColorDialog : QDialog
%End
public:

QgsColorDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags,
QgsColorDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags,
const QColor &color = QColor() );
%Docstring
Create a new color picker dialog
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgscredentialdialog.sip
Expand Up @@ -20,7 +20,7 @@ class QgsCredentialDialog : QDialog, QgsCredentials
#include "qgscredentialdialog.h"
%End
public:
QgsCredentialDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
QgsCredentialDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
%Docstring
QgsCredentialDialog constructor
%End
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsdialog.sip
Expand Up @@ -21,7 +21,7 @@ class QgsDialog : QDialog
%End
public:

QgsDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags,
QgsDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags,
QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Close,
Qt::Orientation orientation = Qt::Horizontal );
%Docstring
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgserrordialog.sip
Expand Up @@ -17,12 +17,12 @@ class QgsErrorDialog: QDialog
%End
public:

QgsErrorDialog( const QgsError &error, const QString &title, QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
QgsErrorDialog( const QgsError &error, const QString &title, QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
%Docstring
QgsErrorDialog constructor for QgsErrorDialog
%End

static void show( const QgsError &error, const QString &title, QWidget *parent = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
static void show( const QgsError &error, const QString &title, QWidget *parent = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
%Docstring
Show dialog with error
\param error error
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsgroupwmsdatadialog.sip
Expand Up @@ -15,7 +15,7 @@ class QgsGroupWmsDataDialog: QDialog
#include "qgsgroupwmsdatadialog.h"
%End
public:
QgsGroupWmsDataDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
QgsGroupWmsDataDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
%Docstring
Constructor
%End
Expand Down
70 changes: 70 additions & 0 deletions python/gui/qgsgui.sip
@@ -0,0 +1,70 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsgui.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsGui
{
%Docstring
QgsGui is a singleton class containing various registry and other global members
related to GUI classes.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsgui.h"
%End
public:



static QgsGui *instance();
%Docstring
Returns a pointer to the singleton instance.
:rtype: QgsGui
%End

static QgsEditorWidgetRegistry *editorWidgetRegistry();
%Docstring
Returns the global editor widget registry, used for managing all known edit widget factories.
:rtype: QgsEditorWidgetRegistry
%End

static QgsShortcutsManager *shortcutsManager();
%Docstring
Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences.
:rtype: QgsShortcutsManager
%End

static QgsLayerTreeEmbeddedWidgetRegistry *layerTreeEmbeddedWidgetRegistry();
%Docstring
Returns the global layer tree embedded widget registry, used for registering widgets that may be embedded into layer tree view.
:rtype: QgsLayerTreeEmbeddedWidgetRegistry
%End

static QgsMapLayerActionRegistry *mapLayerActionRegistry();
%Docstring
Returns the global map layer action registry, used for registering map layer actions.
:rtype: QgsMapLayerActionRegistry
%End

~QgsGui();

private:
QgsGui( const QgsGui &other );
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsgui.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2 changes: 1 addition & 1 deletion python/gui/qgsludialog.sip
Expand Up @@ -5,7 +5,7 @@ class QgsLUDialog: QDialog
%End

public:
QgsLUDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgisGui::ModalDialogFlags );
QgsLUDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags );
~QgsLUDialog();
QString lowerValue() const;
void setLowerValue( const QString &val );
Expand Down
8 changes: 2 additions & 6 deletions python/gui/qgsmaplayeractionregistry.sip
Expand Up @@ -64,8 +64,8 @@ class QgsMapLayerActionRegistry : QObject
%End

public:
//! Returns the instance pointer, creating the object on the first call
static QgsMapLayerActionRegistry *instance();

QgsMapLayerActionRegistry( QObject *parent = 0 );

~QgsMapLayerActionRegistry();

Expand All @@ -83,10 +83,6 @@ class QgsMapLayerActionRegistry : QObject
/** Returns the default action for a layer*/
QgsMapLayerAction *defaultActionForLayer( QgsMapLayer *layer );

protected:
//! protected constructor
QgsMapLayerActionRegistry( QObject *parent = 0 );

signals:
/** Triggered when an action is added or removed from the registry */
void changed();
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmessagelogviewer.sip
Expand Up @@ -21,7 +21,7 @@ class QgsMessageLogViewer: QDialog
%End
public:

QgsMessageLogViewer( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
QgsMessageLogViewer( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
%Docstring
Create a new message log viewer. The viewer will automatically connect to the system's
QgsApplication.messageLog() instance.
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmessageviewer.sip
Expand Up @@ -6,7 +6,7 @@ class QgsMessageViewer: QDialog, QgsMessageOutput //, Ui::QgsMessageViewer
%End

public:
QgsMessageViewer( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgisGui::ModalDialogFlags );
QgsMessageViewer( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags );
~QgsMessageViewer();

virtual void setMessage( const QString &message, MessageType msgType );
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsnewgeopackagelayerdialog.sip
Expand Up @@ -7,7 +7,7 @@ class QgsNewGeoPackageLayerDialog : QDialog

public:
/** Constructor */
QgsNewGeoPackageLayerDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgisGui::ModalDialogFlags );
QgsNewGeoPackageLayerDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags );

~QgsNewGeoPackageLayerDialog();

Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsnewhttpconnection.sip
Expand Up @@ -6,7 +6,7 @@ class QgsNewHttpConnection : QDialog

public:
//! Constructor
QgsNewHttpConnection( QWidget *parent /TransferThis/ = 0, const QString &baseKey = "/Qgis/connections-wms/", const QString &connName = QString::null, const Qt::WindowFlags &fl = QgisGui::ModalDialogFlags );
QgsNewHttpConnection( QWidget *parent /TransferThis/ = 0, const QString &baseKey = "/Qgis/connections-wms/", const QString &connName = QString::null, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags );
//! Destructor
~QgsNewHttpConnection();
public slots:
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsnewmemorylayerdialog.sip
Expand Up @@ -26,7 +26,7 @@ class QgsNewMemoryLayerDialog: QDialog
:rtype: QgsVectorLayer
%End

QgsNewMemoryLayerDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgisGui::ModalDialogFlags );
QgsNewMemoryLayerDialog( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
~QgsNewMemoryLayerDialog();

QgsWkbTypes::Type selectedType() const;
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsnewnamedialog.sip
Expand Up @@ -23,7 +23,7 @@ class QgsNewNameDialog : QgsDialog
QgsNewNameDialog( const QString& source = QString::null, const QString& initial = QString::null,
const QStringList& extensions = QStringList(), const QStringList& existing = QStringList(),
const QRegExp& regexp = QRegExp(), Qt::CaseSensitivity cs = Qt::CaseSensitive,
QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &flags = QgisGui::ModalDialogFlags );
QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &flags = QgsGuiUtils::ModalDialogFlags );

/** Sets the hint string for the dialog (the text shown above the name
* input box).
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsnewvectorlayerdialog.sip
Expand Up @@ -10,7 +10,7 @@ class QgsNewVectorLayerDialog : QDialog
// @return fileName on success, empty string use aborted, QString::null if creation failed
static QString runAndCreateLayer( QWidget *parent = 0, QString *enc = 0 );

QgsNewVectorLayerDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgisGui::ModalDialogFlags );
QgsNewVectorLayerDialog( QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags );
~QgsNewVectorLayerDialog();
/** Returns the selected geometry type*/
QgsWkbTypes::Type selectedType() const;
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsowssourceselect.sip
Expand Up @@ -23,7 +23,7 @@ class QgsOWSSourceSelect : QDialog
};

//! Constructor
QgsOWSSourceSelect( const QString &service, QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgisGui::ModalDialogFlags, bool managerMode = false, bool embeddedMode = false );
QgsOWSSourceSelect( const QString &service, QWidget *parent /TransferThis/ = 0, const Qt::WindowFlags &fl = QgsGuiUtils::ModalDialogFlags, bool managerMode = false, bool embeddedMode = false );
//! Destructor
~QgsOWSSourceSelect();

Expand Down

0 comments on commit f8f7d60

Please sign in to comment.