QGIS API Documentation 3.43.0-Master (9e873c7bc91)
Loading...
Searching...
No Matches
qgsdataitemguiprovider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdataitemguiprovider.h
3 --------------------------------------
4 Date : October 2018
5 Copyright : (C) 2018 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSDATAITEMGUIPROVIDER_H
17#define QGSDATAITEMGUIPROVIDER_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21#include "qgis.h"
22#include <QList>
23#include <QWidget>
24#include <QMimeData>
25#include <QString>
26#include <QMenu>
27
28class QgsDataItem;
29class QgsMessageBar;
30class QgsLayerItem;
32class QgsMapCanvas;
33
42class GUI_EXPORT QgsDataItemGuiContext
43{
44 public:
46
54 QgsMessageBar *messageBar() const;
55
63 void setMessageBar( QgsMessageBar *bar );
64
73 void setMapCanvas( QgsMapCanvas *canvas );
74
81 QgsMapCanvas *mapCanvas() const;
82
89 QgsBrowserTreeView *view() const;
90
97 void setView( QgsBrowserTreeView *view );
98
99 private:
100 QgsMessageBar *mMessageBar = nullptr;
101
102 QgsBrowserTreeView *mView = nullptr;
103
104 QgsMapCanvas *mCanvas = nullptr;
105};
106
108
121{
122 public:
123 virtual ~QgsDataItemGuiProvider() = default;
124
128 virtual QString name() = 0;
129
154 virtual void populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context );
155
167 virtual int precedenceWhenPopulatingMenus() const;
168
178 virtual bool rename( QgsDataItem *item, const QString &name, QgsDataItemGuiContext context );
179
190 virtual bool deleteLayer( QgsLayerItem *item, QgsDataItemGuiContext context );
191
197 virtual bool handleDoubleClick( QgsDataItem *item, QgsDataItemGuiContext context );
198
204 virtual bool acceptDrop( QgsDataItem *item, QgsDataItemGuiContext context );
205
212 virtual bool handleDrop( QgsDataItem *item, QgsDataItemGuiContext context, const QMimeData *data, Qt::DropAction action );
213
223 virtual QWidget *createParamWidget( QgsDataItem *item, QgsDataItemGuiContext context ) SIP_FACTORY;
224
236 static void notify( const QString &title, const QString &message, QgsDataItemGuiContext context, Qgis::MessageLevel level = Qgis::MessageLevel::Info, int duration = -1, QWidget *parent = nullptr );
237};
238
239#endif // QGSDATAITEMGUIPROVIDER_H
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Definition qgis.h:154
@ Info
Information message.
Definition qgis.h:155
The QgsBrowserTreeView class extends QTreeView with save/restore tree state functionality.
Encapsulates the context in which a QgsDataItem is shown within the application GUI.
QgsDataItemGuiContext()=default
Abstract base class for providers which affect how QgsDataItem items behave within the application GU...
virtual ~QgsDataItemGuiProvider()=default
virtual QString name()=0
Returns the provider's name.
Base class for all items in the model.
Definition qgsdataitem.h:46
Item that represents a layer that can be opened with one of the providers.
Map canvas is a class for displaying all GIS data types on a canvas.
A bar for displaying non-blocking messages to the user.
#define SIP_FACTORY
Definition qgis_sip.h:76
Q_DECLARE_METATYPE(QgsDataItemGuiContext)