QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
21 #include "qgis_core.h"
22 #include <QFileSystemWatcher>
23 #include <QFutureWatcher>
28 #include <QTreeWidget>
55 if ( qobject_cast<QgsLayerItem *>( sipCpp ) )
56 sipType = sipType_QgsLayerItem;
57 else if ( qobject_cast<QgsErrorItem *>( sipCpp ) )
58 sipType = sipType_QgsErrorItem;
59 else if ( qobject_cast<QgsDirectoryItem *>( sipCpp ) )
60 sipType = sipType_QgsDirectoryItem;
61 else if ( qobject_cast<QgsFavoritesItem *>( sipCpp ) )
62 sipType = sipType_QgsFavoritesItem;
63 else if ( qobject_cast<QgsZipItem *>( sipCpp ) )
64 sipType = sipType_QgsZipItem;
65 else if ( qobject_cast<QgsDataCollectionItem *>( sipCpp ) )
66 sipType = sipType_QgsDataCollectionItem;
67 else if ( qobject_cast<QgsProjectItem *>( sipCpp ) )
68 sipType = sipType_QgsProjectItem;
114 virtual bool layerCollection()
const;
122 virtual QVector<QgsDataItem *> createChildren()
SIP_FACTORY;
140 virtual void setState( State state );
155 virtual void deleteChildItem(
QgsDataItem *child );
185 virtual QList<QAction *> actions( QWidget *parent );
195 virtual QList<QMenu *> menus( QWidget *parent );
223 virtual bool handleDoubleClick();
252 Q_DECLARE_FLAGS( Capabilities, Capability )
278 Q_DECL_DEPRECATED
virtual bool rename(
const QString &name )
SIP_DEPRECATED;
294 virtual void setCapabilities( Capabilities capabilities ) { mCapabilities = capabilities; }
299 static int findItem( QVector<QgsDataItem *> items,
QgsDataItem *item );
316 QVector<QgsDataItem *>
children()
const {
return mChildren; }
317 virtual QIcon icon();
324 QString
name()
const {
return mName; }
331 void setName(
const QString &name );
333 QString
path()
const {
return mPath; }
334 void setPath(
const QString &path ) { mPath = path; }
344 QString providerKey()
const;
354 void setProviderKey(
const QString &value );
357 static QString pathComponent(
const QString &component );
369 virtual QVariant sortKey()
const;
376 void setSortKey(
const QVariant &key );
382 void setIcon(
const QIcon &icon ) { mIcon = icon; }
383 void setIconName(
const QString &iconName ) { mIconName = iconName; }
389 static void deleteLater( QVector<QgsDataItem *> &items );
392 void moveToThread( QThread *targetThread );
395 virtual void populate(
const QVector<QgsDataItem *> &children );
400 virtual void refresh(
const QVector<QgsDataItem *> &children );
443 virtual void deleteLater();
447 virtual void populate(
bool foreground =
false );
450 virtual void depopulate();
452 virtual void refresh();
460 virtual void refreshConnections(
const QString &providerKey = QString() );
462 virtual void childrenCreated();
491 static QVector<QgsDataItem *> runCreateChildren(
QgsDataItem *item );
494 bool mDeferredDelete;
495 QFutureWatcher< QVector <QgsDataItem *> > *mFutureWatcher;
529 QgsLayerItem(
QgsDataItem *parent,
const QString &name,
const QString &path,
const QString &uri, LayerType layerType,
const QString &providerKey );
548 static LayerType typeFromMapLayer(
QgsMapLayer *layer );
551 QString
uri()
const {
return mUri; }
572 virtual QString
comments()
const {
return QString(); }
578 static QString layerTypeAsString( LayerType layerType );
584 static QString iconName( LayerType layerType );
600 QStringList mSupportedCRS;
602 QStringList mSupportFormats;
605 static QIcon iconPoint();
606 static QIcon iconLine();
607 static QIcon iconPolygon();
608 static QIcon iconTable();
609 static QIcon iconRaster();
610 static QIcon iconDefault();
612 static QIcon iconMesh();
614 static QIcon iconVectorTile();
617 virtual QString layerName()
const {
return name(); }
651 static QIcon iconDir();
657 static QIcon iconDataCollection();
665 static QIcon openDirIcon();
671 static QIcon homeDirIcon();
791 QIcon
icon()
override;
793 bool hasDragEnabled()
const override {
return true; }
797 static bool hiddenPath(
const QString &path );
801 void directoryChanged();
808 QFileSystemWatcher *mFileSystemWatcher =
nullptr;
868 void mousePressEvent( QMouseEvent *event )
override;
871 void showHideColumn();
900 void addDirectory(
const QString &directory,
const QString &name = QString() );
911 void renameFavorite(
const QString &path,
const QString &name );
914 static QIcon iconFavorites();
916 QVariant
sortKey()
const override;
919 QVector<QgsDataItem *>
createChildren(
const QString &favDir,
const QString &name );
940 QgsZipItem(
QgsDataItem *parent,
const QString &name,
const QString &filePath,
const QString &path,
const QString &providerKey = QString() );
943 QStringList getZipFileList();
946 static QVector<dataItem_t *> sDataItemPtr
SIP_SKIP;
962 static QIcon iconZip();
994 const QString &connectionUri,
995 const QString &providerKey,
996 const QString &schema,
997 const QString &tableName );
1003 QIcon
icon()
override;
1008 QString schema()
const;
1013 QString tableName()
const;
1018 QString connectionUri()
const;
1035 QString mConnectionUri;
1036 std::unique_ptr<QgsAbstractDatabaseProviderConnection::TableProperty> mTableProperty;
1062 QIcon
icon()
override;
1089 QgsProjectHomeItem(
QgsDataItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
1091 QIcon
icon()
override;
1092 QVariant
sortKey()
const override;
1108 QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
1110 bool rename(
const QString &name )
override;
1121 #endif // QGSDATAITEM_H
void setIconName(const QString &iconName)
QMap< QString, QIcon > mIconMap
A Collection: logical collection of layers or subcollections, e.g.
@ Favorites
Represents a favorite item.
void addChild(QgsDataItem *item)
void setIcon(const QIcon &icon)
Abstract base class for spatial data provider implementations.
virtual Capabilities capabilities2() const
Returns the capabilities for the data item.
A zip file: contains layers, using GDAL/OGR VSIFILE mechanism.
static QIcon iconDataCollection()
Returns the standard browser data collection icon.
const QgsCoordinateReferenceSystem & crs
QgsMapLayerType
Types of layers that can be added to a map.
virtual QVariant sortKey() const
Returns the sorting key for the item.
void setToolTip(const QString &msg)
Manages storage of a set of bookmarks.
QString name() const
Returns the name of the item (the displayed text for the item).
A layer field item, information about the connection URI, the schema and the table as well as the lay...
void dataChanged(QgsDataItem *item)
QVariant mSortKey
Custom sort key. If invalid, name() will be used for sorting instead.
A collection of field items with some internal logic to retrieve the fields and a the vector layer in...
void beginRemoveItems(QgsDataItem *parent, int first, int last)
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
The TableProperty class represents a database table or view.
QString dirPath() const
Returns the full path to the directory the item represents.
#define Q_NOWARN_DEPRECATED_POP
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
virtual QgsMimeDataUtils::Uri mimeUri() const
Returns mime URI for the data item.
virtual Q_DECL_DEPRECATED bool rename(const QString &name)
Sets a new name for the item, and returns true if the item was successfully renamed.
QgsDataItem * dataItem_t(QString, QgsDataItem *)
Data item that can be used to represent QGIS projects.
A directory: contains subdirectories and layers.
QgsDataItem * parent() const
Gets item parent.
bool hasDragEnabled() const override
Returns true if the item may be dragged.
virtual Q_DECL_DEPRECATED QWidget * paramWidget()
Returns source widget from data item for QgsBrowserPropertiesWidget.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
virtual Q_DECL_DEPRECATED bool acceptDrop()
Returns whether the item accepts drag and dropped layers - e.g.
@ Populating
Creating children in separate thread (populating or refreshing)
@ Project
Represents a QGIS project.
virtual bool hasDragEnabled() const
Returns true if the item may be dragged.
QString qgsVsiPrefix(const QString &path)
@ NotPopulated
Children not yet created.
Animated icon is keeping an animation running if there are listeners connected to frameChanged.
This class represents a coordinate reference system (CRS).
virtual void setCapabilities(Capabilities capabilities)
Sets the capabilities for the data item.
void connectionsChanged(const QString &providerKey=QString())
Emitted when the connections of the provider with the specified providerKey have changed.
static QString vsiPrefix(const QString &uri)
Data item that can be used to report problems (e.g.
Capabilities mCapabilities
virtual QString comments() const
Returns comments of the layer.
void setPath(const QString &path)
Represents a vector layer which manages a vector based data sets.
Base class for all map layer types.
QVector< QgsDataItem * > mChildren
@ Fields
Collection of fields.
virtual Q_DECL_DEPRECATED bool handleDrop(const QMimeData *, Qt::DropAction)
Attempts to process the mime data dropped on this item.
virtual void setState(State state)
Set item state.
QStringList supportedCrs() const
Returns the supported CRS.
QVector< QgsDataItem * > children() const
Item that represents a layer that can be opened with one of the providers.
bool deferredDelete()
The item is scheduled to be deleted.
@ Custom
Custom item type.
A Collection that represents a root group of connections from a single data provider.
static QStringList sProviderNames
QString providerKey() const
Returns provider key.
Contains various Favorites directories.
@ Field
Vector layer field.
Base class for all items in the model.
#define Q_NOWARN_DEPRECATED_PUSH
QStringList supportedFormats() const
Returns the supported formats.
void stateChanged(QgsDataItem *item, QgsDataItem::State oldState)
~QgsConnectionsRootItem() override=default
bool hasDragEnabled() const override
Returns true if the item may be dragged.
A Collection that represents a database schema item.
virtual QVector< QgsDataItem * > createChildren()
Create children.
void beginInsertItems(QgsDataItem *parent, int first, int last)
QString uri() const
Returns layer uri or empty string if layer cannot be created.
virtual void childrenCreated()
Encapsulate a field in an attribute table or data source.