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 )
430 QgsLayerItem( QgsDataItem *parent,
const QString &name,
const QString &path,
const QString &uri,
LayerType layerType,
const QString &providerKey );
434 bool equal(
const QgsDataItem *other )
override;
446 QString
uri()
const {
return mUri; }
467 virtual QString
comments()
const {
return QString(); }
473 static QString layerTypeAsString(
LayerType layerType );
479 static QString iconName(
LayerType layerType );
495 static QIcon iconPoint();
496 static QIcon iconLine();
497 static QIcon iconPolygon();
498 static QIcon iconTable();
499 static QIcon iconRaster();
500 static QIcon iconDefault();
520 static QIcon iconDir();
521 static QIcon iconDataCollection();
559 QIcon
icon()
override;
563 static bool hiddenPath(
const QString &path );
565 QList<QAction *>
actions( QWidget *parent )
override;
570 void directoryChanged();
577 QFileSystemWatcher *mFileSystemWatcher =
nullptr;
631 void mousePressEvent( QMouseEvent *event )
override;
634 void showHideColumn();
663 void addDirectory(
const QString &directory,
const QString &name = QString() );
674 void renameFavorite(
const QString &path,
const QString &name );
677 static QIcon iconFavorites();
679 QVariant
sortKey()
const override;
682 QVector<QgsDataItem *>
createChildren(
const QString &favDir,
const QString &name );
700 QgsZipItem(
QgsDataItem *parent,
const QString &name,
const QString &filePath,
const QString &path );
703 QStringList getZipFileList();
706 static QVector<dataItem_t *> sDataItemPtr
SIP_SKIP;
720 static QgsDataItem *itemFromPath(
QgsDataItem *parent,
const QString &filePath,
const QString &name,
const QString &path ) SIP_FACTORY
SIP_PYNAME( itemFromFilePath );
722 static QIcon iconZip();
743 QgsProjectHomeItem(
QgsDataItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
745 QIcon
icon()
override;
746 QVariant
sortKey()
const override;
761 QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
766 void rename(
const QString &name );
776 #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
Get 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
Return 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 *)
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