QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
QgsDataItemGuiProvider Class Referenceabstract

Abstract base class for providers which affect how QgsDataItem items behave within the application GUI. More...

#include <qgsdataitemguiprovider.h>

Public Member Functions

virtual ~QgsDataItemGuiProvider ()=default
 
virtual bool acceptDrop (QgsDataItem *item, QgsDataItemGuiContext context)
 Providers should return true if the drops are allowed (handleDrop() should be implemented in that case as well).
 
virtual QWidget * createParamWidget (QgsDataItem *item, QgsDataItemGuiContext context)
 Creates source widget from data item for QgsBrowserPropertiesWidget By default it returns nullptr.
 
virtual bool deleteLayer (QgsLayerItem *item, QgsDataItemGuiContext context)
 Tries to permanently delete map layer representing the given item.
 
virtual bool handleDoubleClick (QgsDataItem *item, QgsDataItemGuiContext context)
 Called when a user double clicks on an item.
 
virtual bool handleDrop (QgsDataItem *item, QgsDataItemGuiContext context, const QMimeData *data, Qt::DropAction action)
 Called when a user drops on an item.
 
virtual QString name ()=0
 Returns the provider's name.
 
virtual void populateContextMenu (QgsDataItem *item, QMenu *menu, const QList< QgsDataItem * > &selectedItems, QgsDataItemGuiContext context)
 Called when the given context menu is being populated for the given item, allowing the provider to add its own actions and submenus to the context menu.
 
virtual int precedenceWhenPopulatingMenus () const
 Returns the provider's precedence to use when populating context menus via calls to populateContextMenu().
 
virtual bool rename (QgsDataItem *item, const QString &name, QgsDataItemGuiContext context)
 Sets a new name for the item, and returns true if the item was successfully renamed.
 

Static Public Member Functions

static void notify (const QString &title, const QString &message, QgsDataItemGuiContext context, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1, QWidget *parent=nullptr)
 Notify the user showing a message with title and level If the context has a message bar the message will be shown in the message bar else a message dialog will be used.
 

Detailed Description

Abstract base class for providers which affect how QgsDataItem items behave within the application GUI.

Providers must be registered via QgsDataItemGuiProviderRegistry.

Since
QGIS 3.6

Definition at line 101 of file qgsdataitemguiprovider.h.

Constructor & Destructor Documentation

◆ ~QgsDataItemGuiProvider()

virtual QgsDataItemGuiProvider::~QgsDataItemGuiProvider ( )
virtualdefault

Member Function Documentation

◆ acceptDrop()

bool QgsDataItemGuiProvider::acceptDrop ( QgsDataItem item,
QgsDataItemGuiContext  context 
)
virtual

Providers should return true if the drops are allowed (handleDrop() should be implemented in that case as well).

Since
QGIS 3.10

Definition at line 76 of file qgsdataitemguiprovider.cpp.

◆ createParamWidget()

QWidget * QgsDataItemGuiProvider::createParamWidget ( QgsDataItem item,
QgsDataItemGuiContext  context 
)
virtual

Creates source widget from data item for QgsBrowserPropertiesWidget By default it returns nullptr.

Caller takes responsibility of deleting created.

The function is replacement of QgsDataItem::paramWidget()

Since
QGIS 3.10

Definition at line 86 of file qgsdataitemguiprovider.cpp.

◆ deleteLayer()

bool QgsDataItemGuiProvider::deleteLayer ( QgsLayerItem item,
QgsDataItemGuiContext  context 
)
virtual

Tries to permanently delete map layer representing the given item.

Returns true if the layer was successfully deleted.

Items which implement this method should return the QgsDataItem::Delete capability.

The default implementation does nothing.

Since
QGIS 3.10

Definition at line 66 of file qgsdataitemguiprovider.cpp.

◆ handleDoubleClick()

bool QgsDataItemGuiProvider::handleDoubleClick ( QgsDataItem item,
QgsDataItemGuiContext  context 
)
virtual

Called when a user double clicks on an item.

Providers should return true if the double-click was handled and do not want other providers to handle the double-click, and to prevent the default double-click behavior for items.

Definition at line 71 of file qgsdataitemguiprovider.cpp.

◆ handleDrop()

bool QgsDataItemGuiProvider::handleDrop ( QgsDataItem item,
QgsDataItemGuiContext  context,
const QMimeData *  data,
Qt::DropAction  action 
)
virtual

Called when a user drops on an item.

Providers should return true if the drop was handled and do not want other providers to handle the drop, and to prevent the default drop behavior for items.

Since
QGIS 3.10

Definition at line 81 of file qgsdataitemguiprovider.cpp.

◆ name()

virtual QString QgsDataItemGuiProvider::name ( )
pure virtual

Returns the provider's name.

◆ notify()

void QgsDataItemGuiProvider::notify ( const QString &  title,
const QString &  message,
QgsDataItemGuiContext  context,
Qgis::MessageLevel  level = Qgis::MessageLevel::Info,
int  duration = -1,
QWidget *  parent = nullptr 
)
static

Notify the user showing a message with title and level If the context has a message bar the message will be shown in the message bar else a message dialog will be used.

Since QGIS 3.18, the optional duration argument can be used to specify the message timeout in seconds. If duration is set to 0, then the message must be manually dismissed by the user. A duration of -1 indicates that the default timeout for the message level should be used.

Since
QGIS 3.16

Definition at line 91 of file qgsdataitemguiprovider.cpp.

◆ populateContextMenu()

void QgsDataItemGuiProvider::populateContextMenu ( QgsDataItem item,
QMenu *  menu,
const QList< QgsDataItem * > &  selectedItems,
QgsDataItemGuiContext  context 
)
virtual

Called when the given context menu is being populated for the given item, allowing the provider to add its own actions and submenus to the context menu.

Additionally, providers could potentially alter menus and actions added by other providers if desired, or use standard QMenu API to insert their items and submenus into the desired location within the context menu.

The selectedItems list contains a list of ALL currently selected items within the browser view. Subclasses can utilize this list in order to create actions which operate on multiple items at once, e.g. to allow deletion of multiple layers from a database at once.

When creating a context menu, this method is called for EVERY QgsDataItemGuiProvider within the QgsDataItemGuiProviderRegistry. It is the QgsDataItemGuiProvider subclass' responsibility to test the item and selectedItems for their properties and classes and decide what actions (if any) are appropriate to add to the context menu.

Care must be taken to correctly parent newly created sub menus and actions to the provided menu to avoid memory leaks.

The context argument gives the wider context under which the context menu is being shown, and contains accessors for useful objects like the application message bar.

The base class method has no effect.

Definition at line 51 of file qgsdataitemguiprovider.cpp.

◆ precedenceWhenPopulatingMenus()

int QgsDataItemGuiProvider::precedenceWhenPopulatingMenus ( ) const
virtual

Returns the provider's precedence to use when populating context menus via calls to populateContextMenu().

Providers which return larger values will be called AFTER other providers when the menu is being populated. This allows them to nicely insert their corresponding menu items in the desired location with respect to existing items added by other providers.

The default implementation returns 0.

Since
QGIS 3.22

Definition at line 56 of file qgsdataitemguiprovider.cpp.

◆ rename()

bool QgsDataItemGuiProvider::rename ( QgsDataItem item,
const QString &  name,
QgsDataItemGuiContext  context 
)
virtual

Sets a new name for the item, and returns true if the item was successfully renamed.

Items which implement this method should return the QgsDataItem::Rename capability.

The default implementation does nothing.

Since
QGIS 3.10

Definition at line 61 of file qgsdataitemguiprovider.cpp.


The documentation for this class was generated from the following files: