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();
229 virtual void setCapabilities( Capabilities capabilities ) { mCapabilities = capabilities; }
234 static int findItem( QVector<QgsDataItem *> items,
QgsDataItem *item );
249 QVector<QgsDataItem *>
children()
const {
return mChildren; }
250 virtual QIcon icon();
257 QString
name()
const {
return mName; }
264 void setName(
const QString &name );
266 QString
path()
const {
return mPath; }
267 void setPath(
const QString &path ) { mPath = path; }
269 static QString pathComponent(
const QString &component );
281 virtual QVariant sortKey()
const;
288 void setSortKey(
const QVariant &key );
294 void setIcon(
const QIcon &icon ) { mIcon = icon; }
295 void setIconName(
const QString &iconName ) { mIconName = iconName; }
301 static void deleteLater( QVector<QgsDataItem *> &items );
304 void moveToThread( QThread *targetThread );
307 virtual void populate(
const QVector<QgsDataItem *> &children );
312 virtual void refresh(
const QVector<QgsDataItem *> &children );
352 virtual void deleteLater();
356 virtual void populate(
bool foreground =
false );
359 virtual void depopulate();
361 virtual void refresh();
364 virtual void refreshConnections();
366 virtual void childrenCreated();
369 void beginInsertItems(
QgsDataItem *parent,
int first,
int last );
370 void endInsertItems();
371 void beginRemoveItems(
QgsDataItem *parent,
int first,
int last );
372 void endRemoveItems();
382 void connectionsChanged();
394 static QVector<QgsDataItem *> runCreateChildren(
QgsDataItem *item );
397 bool mDeferredDelete;
398 QFutureWatcher< QVector <QgsDataItem *> > *mFutureWatcher;
403 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDataItem::Capabilities )
431 QgsLayerItem( QgsDataItem *parent,
const QString &name,
const QString &path,
const QString &uri,
LayerType layerType,
const QString &providerKey );
435 bool equal(
const QgsDataItem *other )
override;
447 QString
uri()
const {
return mUri; }
468 virtual QString
comments()
const {
return QString(); }
474 static QString layerTypeAsString(
LayerType layerType );
480 static QString iconName(
LayerType layerType );
496 static QIcon iconPoint();
497 static QIcon iconLine();
498 static QIcon iconPolygon();
499 static QIcon iconTable();
500 static QIcon iconRaster();
501 static QIcon iconDefault();
503 static QIcon iconMesh();
523 static QIcon iconDir();
524 static QIcon iconDataCollection();
562 QIcon
icon()
override;
566 static bool hiddenPath(
const QString &path );
568 QList<QAction *>
actions( QWidget *parent )
override;
573 void directoryChanged();
580 QFileSystemWatcher *mFileSystemWatcher =
nullptr;
636 void mousePressEvent( QMouseEvent *event )
override;
639 void showHideColumn();
668 void addDirectory(
const QString &directory,
const QString &name = QString() );
679 void renameFavorite(
const QString &path,
const QString &name );
682 static QIcon iconFavorites();
684 QVariant
sortKey()
const override;
687 QVector<QgsDataItem *>
createChildren(
const QString &favDir,
const QString &name );
705 QgsZipItem(
QgsDataItem *parent,
const QString &name,
const QString &filePath,
const QString &path );
708 QStringList getZipFileList();
711 static QVector<dataItem_t *> sDataItemPtr
SIP_SKIP;
725 static QgsDataItem *itemFromPath(
QgsDataItem *parent,
const QString &filePath,
const QString &name,
const QString &path ) SIP_FACTORY
SIP_PYNAME( itemFromFilePath );
727 static QIcon iconZip();
748 QgsProjectHomeItem(
QgsDataItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
750 QIcon
icon()
override;
751 QVariant
sortKey()
const override;
753 QList<QAction *>
actions( QWidget *parent )
override;
769 QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
774 void rename(
const QString &name );
784 #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.
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)
Abstract base class for spatial data provider implementations.
void setToolTip(const QString &msg)
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.
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.
virtual QList< QAction * > actions(QWidget *parent)
Returns the list of actions available for this item.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
bool deferredDelete()
The item is scheduled to be deleted.
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 *)
QList< QAction * > actions(QWidget *parent) override
Returns the list of actions available for this item.
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