21 #include "qgis_core.h" 22 #include <QFileSystemWatcher> 23 #include <QFutureWatcher> 28 #include <QTreeWidget> 54 if ( qobject_cast<QgsLayerItem *>( sipCpp ) )
55 sipType = sipType_QgsLayerItem;
56 else if ( qobject_cast<QgsErrorItem *>( sipCpp ) )
57 sipType = sipType_QgsErrorItem;
58 else if ( qobject_cast<QgsDirectoryItem *>( sipCpp ) )
59 sipType = sipType_QgsDirectoryItem;
60 else if ( qobject_cast<QgsFavoritesItem *>( sipCpp ) )
61 sipType = sipType_QgsFavoritesItem;
62 else if ( qobject_cast<QgsZipItem *>( sipCpp ) )
63 sipType = sipType_QgsZipItem;
64 else if ( qobject_cast<QgsDataCollectionItem *>( sipCpp ) )
65 sipType = sipType_QgsDataCollectionItem;
66 else if ( qobject_cast<QgsProjectItem *>( sipCpp ) )
67 sipType = sipType_QgsProjectItem;
100 virtual QVector<QgsDataItem *> createChildren()
SIP_FACTORY;
118 virtual void setState(
State state );
133 virtual void deleteChildItem(
QgsDataItem *child );
163 virtual QList<QAction *> actions( QWidget *parent );
173 virtual QList<QMenu *> menus( QWidget *parent );
201 virtual bool handleDoubleClick();
256 Q_DECL_DEPRECATED
virtual bool rename(
const QString &name )
SIP_DEPRECATED;
272 virtual void setCapabilities( Capabilities capabilities ) { mCapabilities = capabilities; }
277 static int findItem( QVector<QgsDataItem *> items,
QgsDataItem *item );
292 QVector<QgsDataItem *>
children()
const {
return mChildren; }
293 virtual QIcon icon();
300 QString
name()
const {
return mName; }
307 void setName(
const QString &name );
309 QString
path()
const {
return mPath; }
310 void setPath(
const QString &path ) { mPath = path; }
312 static QString pathComponent(
const QString &component );
324 virtual QVariant sortKey()
const;
331 void setSortKey(
const QVariant &key );
337 void setIcon(
const QIcon &icon ) { mIcon = icon; }
338 void setIconName(
const QString &iconName ) { mIconName = iconName; }
344 static void deleteLater( QVector<QgsDataItem *> &items );
347 void moveToThread( QThread *targetThread );
350 virtual void populate(
const QVector<QgsDataItem *> &children );
355 virtual void refresh(
const QVector<QgsDataItem *> &children );
395 virtual void deleteLater();
399 virtual void populate(
bool foreground =
false );
402 virtual void depopulate();
404 virtual void refresh();
407 virtual void refreshConnections();
409 virtual void childrenCreated();
412 void beginInsertItems(
QgsDataItem *parent,
int first,
int last );
413 void endInsertItems();
414 void beginRemoveItems(
QgsDataItem *parent,
int first,
int last );
415 void endRemoveItems();
425 void connectionsChanged();
437 static QVector<QgsDataItem *> runCreateChildren(
QgsDataItem *item );
440 bool mDeferredDelete;
441 QFutureWatcher< QVector <QgsDataItem *> > *mFutureWatcher;
446 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDataItem::Capabilities )
474 QgsLayerItem( QgsDataItem *parent,
const QString &name,
const QString &path,
const QString &uri,
LayerType layerType,
const QString &providerKey );
478 bool equal(
const QgsDataItem *other )
override;
496 QString
uri()
const {
return mUri; }
517 virtual QString
comments()
const {
return QString(); }
523 static QString layerTypeAsString(
LayerType layerType );
529 static QString iconName(
LayerType layerType );
553 static QIcon iconPoint();
554 static QIcon iconLine();
555 static QIcon iconPolygon();
556 static QIcon iconTable();
557 static QIcon iconRaster();
558 static QIcon iconDefault();
560 static QIcon iconMesh();
584 static QIcon iconDir();
590 static QIcon iconDataCollection();
598 static QIcon openDirIcon();
604 static QIcon homeDirIcon();
636 QIcon
icon()
override;
642 static bool hiddenPath(
const QString &path );
646 void directoryChanged();
653 QFileSystemWatcher *mFileSystemWatcher =
nullptr;
710 void mousePressEvent( QMouseEvent *event )
override;
713 void showHideColumn();
742 void addDirectory(
const QString &directory,
const QString &name = QString() );
753 void renameFavorite(
const QString &path,
const QString &name );
756 static QIcon iconFavorites();
758 QVariant
sortKey()
const override;
761 QVector<QgsDataItem *>
createChildren(
const QString &favDir,
const QString &name );
779 QgsZipItem(
QgsDataItem *parent,
const QString &name,
const QString &filePath,
const QString &path );
782 QStringList getZipFileList();
785 static QVector<dataItem_t *> sDataItemPtr
SIP_SKIP;
799 static QgsDataItem *itemFromPath(
QgsDataItem *parent,
const QString &filePath,
const QString &name,
const QString &path ) SIP_FACTORY
SIP_PYNAME( itemFromFilePath );
801 static QIcon iconZip();
822 QgsProjectHomeItem(
QgsDataItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
824 QIcon
icon()
override;
825 QVariant
sortKey()
const override;
841 QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
843 bool rename(
const QString &name )
override;
854 #endif // QGSDATAITEM_H A Collection: logical collection of layers or subcollections, e.g.
virtual QVariant sortKey() const
Returns the sorting key for the item.
QStringList mSupportFormats
The list of supported formats.
Base class for all map layer types.
virtual void childrenCreated()
virtual QString layerName() const
QString providerKey() const
Returns provider key.
QString name() const
Returns the name of the item (the displayed text for the item).
QVariant mSortKey
Custom sort key. If invalid, name() will be used for sorting instead.
QString mProviderKey
The provider key.
void addChild(QgsDataItem *item)
#define Q_NOWARN_DEPRECATED_PUSH
void setIcon(const QIcon &icon)
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.
Manages storage of a set of bookmarks.
Abstract base class for spatial data provider implementations.
void setToolTip(const QString &msg)
const QgsCoordinateReferenceSystem & crs
A zip file: contains layers, using GDAL/OGR VSIFILE mechanism.
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
QStringList mSupportedCRS
The list of supported CRS.
QgsDataItem * parent() const
Gets item parent.
virtual void setCapabilities(Capabilities capabilities)
Sets the capabilities for the data item.
Children not yet created.
virtual Q_DECL_DEPRECATED bool acceptDrop()
Returns whether the item accepts drag and dropped layers - e.g.
Creating children in separate thread (populating or refreshing)
Data item that can be used to report problems (e.g.
virtual bool hasDragEnabled() const
Returns true if the item may be dragged.
virtual QgsMimeDataUtils::Uri mimeUri() const
Returns mime URI for the data item.
A directory: contains subdirectories and layers.
static QStringList sProviderNames
Base class for all items in the model.
virtual Q_DECL_DEPRECATED QWidget * paramWidget()
Returns source widget from data item for QgsBrowserPropertiesWidget.
Capabilities mCapabilities
virtual void setState(State state)
Set item state.
QVector< QgsDataItem * > children() const
bool hasDragEnabled() const override
Returns true if the item may be dragged.
#define Q_NOWARN_DEPRECATED_POP
bool hasDragEnabled() const override
Returns true if the item may be dragged.
Contains various Favorites directories.
QStringList supportedFormats() const
Returns the supported formats.
QString qgsVsiPrefix(const QString &path)
This class represents a coordinate reference system (CRS).
Animated icon is keeping an animation running if there are listeners connected to frameChanged...
QString uri() const
Returns layer uri or empty string if layer cannot be created.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
bool deferredDelete()
The item is scheduled to be deleted.
QString dirPath() const
Returns the full path to the directory the item represents.
virtual QVector< QgsDataItem * > createChildren()
Create children.
Represents a QGIS project.
Item that represents a layer that can be opened with one of the providers.
virtual Q_DECL_DEPRECATED bool handleDrop(const QMimeData *, Qt::DropAction)
Attempts to process the mime data dropped on this item.
QgsDataItem * dataItem_t(QString, QgsDataItem *)
QgsMapLayerType
Types of layers that can be added to a map.
Data item that can be used to represent QGIS projects.
void setPath(const QString &path)
LayerType mLayerType
The layer type.
QVector< QgsDataItem * > mChildren
virtual QString comments() const
Returns comments of the layer.
bool hasDragEnabled() const override
Returns true if the item may be dragged.
Represents a favorite item.
QStringList supportedCrs() const
Returns the supported CRS.
void setIconName(const QString &iconName)
static QString vsiPrefix(const QString &uri)
QMap< QString, QIcon > mIconMap
virtual Capabilities capabilities2() const
Returns the capabilities for the data item.