21 #include "qgis_core.h" 22 #include <QFileSystemWatcher> 23 #include <QFutureWatcher> 29 #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 );
156 virtual QList<QAction *> actions( QWidget *parent );
166 virtual QList<QMenu *> menus( QWidget *parent );
180 virtual bool handleDrop(
const QMimeData * , Qt::DropAction ) {
return false; }
188 virtual bool handleDoubleClick();
240 virtual bool rename(
const QString &name );
256 virtual void setCapabilities( Capabilities capabilities ) { mCapabilities = capabilities; }
261 static int findItem( QVector<QgsDataItem *> items,
QgsDataItem *item );
276 QVector<QgsDataItem *>
children()
const {
return mChildren; }
277 virtual QIcon icon();
284 QString
name()
const {
return mName; }
291 void setName(
const QString &name );
293 QString
path()
const {
return mPath; }
294 void setPath(
const QString &path ) { mPath = path; }
296 static QString pathComponent(
const QString &component );
308 virtual QVariant sortKey()
const;
315 void setSortKey(
const QVariant &key );
321 void setIcon(
const QIcon &icon ) { mIcon = icon; }
322 void setIconName(
const QString &iconName ) { mIconName = iconName; }
328 static void deleteLater( QVector<QgsDataItem *> &items );
331 void moveToThread( QThread *targetThread );
334 virtual void populate(
const QVector<QgsDataItem *> &children );
339 virtual void refresh(
const QVector<QgsDataItem *> &children );
379 virtual void deleteLater();
383 virtual void populate(
bool foreground =
false );
386 virtual void depopulate();
388 virtual void refresh();
391 virtual void refreshConnections();
393 virtual void childrenCreated();
396 void beginInsertItems(
QgsDataItem *parent,
int first,
int last );
397 void endInsertItems();
398 void beginRemoveItems(
QgsDataItem *parent,
int first,
int last );
399 void endRemoveItems();
409 void connectionsChanged();
421 static QVector<QgsDataItem *> runCreateChildren(
QgsDataItem *item );
424 bool mDeferredDelete;
425 QFutureWatcher< QVector <QgsDataItem *> > *mFutureWatcher;
430 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDataItem::Capabilities )
458 QgsLayerItem( QgsDataItem *parent,
const QString &name,
const QString &path,
const QString &uri,
LayerType layerType,
const QString &providerKey );
462 bool equal(
const QgsDataItem *other )
override;
480 QString
uri()
const {
return mUri; }
501 virtual QString
comments()
const {
return QString(); }
507 static QString layerTypeAsString(
LayerType layerType );
513 static QString iconName(
LayerType layerType );
516 virtual bool deleteLayer();
532 static QIcon iconPoint();
533 static QIcon iconLine();
534 static QIcon iconPolygon();
535 static QIcon iconTable();
536 static QIcon iconRaster();
537 static QIcon iconDefault();
539 static QIcon iconMesh();
563 static QIcon iconDir();
569 static QIcon iconDataCollection();
577 static QIcon openDirIcon();
583 static QIcon homeDirIcon();
615 QIcon
icon()
override;
621 static bool hiddenPath(
const QString &path );
625 void directoryChanged();
632 QFileSystemWatcher *mFileSystemWatcher =
nullptr;
688 void mousePressEvent( QMouseEvent *event )
override;
691 void showHideColumn();
720 void addDirectory(
const QString &directory,
const QString &name = QString() );
731 void renameFavorite(
const QString &path,
const QString &name );
734 static QIcon iconFavorites();
736 QVariant
sortKey()
const override;
739 QVector<QgsDataItem *>
createChildren(
const QString &favDir,
const QString &name );
757 QgsZipItem(
QgsDataItem *parent,
const QString &name,
const QString &filePath,
const QString &path );
760 QStringList getZipFileList();
763 static QVector<dataItem_t *> sDataItemPtr
SIP_SKIP;
777 static QgsDataItem *itemFromPath(
QgsDataItem *parent,
const QString &filePath,
const QString &name,
const QString &path ) SIP_FACTORY
SIP_PYNAME( itemFromFilePath );
779 static QIcon iconZip();
800 QgsProjectHomeItem(
QgsDataItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
802 QIcon
icon()
override;
803 QVariant
sortKey()
const override;
818 QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
820 bool rename(
const QString &name )
override;
830 #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.
virtual bool handleDrop(const QMimeData *, Qt::DropAction)
Attempts to process the mime data dropped on this item.
void addChild(QgsDataItem *item)
void setIcon(const QIcon &icon)
virtual bool rename(const QString &name)
Sets a new name for the item, and returns true if the item was successfully renamed.
Abstract base class for spatial data provider implementations.
void setToolTip(const QString &msg)
const QgsCoordinateReferenceSystem & crs
virtual QWidget * paramWidget()
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.
LayerType
Types of layers that can be added to a map.
virtual void setCapabilities(Capabilities capabilities)
Sets the capabilities for the data item.
Children not yet created.
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.
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.
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.
QgsDataItem * dataItem_t(QString, QgsDataItem *)
Data item that can be used to represent QGIS projects.
void setPath(const QString &path)
virtual bool acceptDrop()
Returns whether the item accepts drag and dropped layers - e.g.
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.