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;
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();
239 virtual bool rename(
const QString &name );
255 virtual void setCapabilities( Capabilities capabilities ) { mCapabilities = capabilities; }
260 static int findItem( QVector<QgsDataItem *> items,
QgsDataItem *item );
275 QVector<QgsDataItem *>
children()
const {
return mChildren; }
276 virtual QIcon
icon();
283 QString
name()
const {
return mName; }
290 void setName(
const QString &name );
292 QString
path()
const {
return mPath; }
293 void setPath(
const QString &path ) { mPath = path; }
295 static QString pathComponent(
const QString &component );
307 virtual QVariant sortKey()
const;
314 void setSortKey(
const QVariant &key );
321 void setIconName(
const QString &iconName ) { mIconName = iconName; }
327 static void deleteLater( QVector<QgsDataItem *> &items );
330 void moveToThread( QThread *targetThread );
333 virtual void populate(
const QVector<QgsDataItem *> &children );
338 virtual void refresh(
const QVector<QgsDataItem *> &children );
378 virtual void deleteLater();
382 virtual void populate(
bool foreground =
false );
385 virtual void depopulate();
387 virtual void refresh();
390 virtual void refreshConnections();
392 virtual void childrenCreated();
395 void beginInsertItems(
QgsDataItem *parent,
int first,
int last );
396 void endInsertItems();
397 void beginRemoveItems(
QgsDataItem *parent,
int first,
int last );
398 void endRemoveItems();
408 void connectionsChanged();
420 static QVector<QgsDataItem *> runCreateChildren(
QgsDataItem *item );
423 bool mDeferredDelete;
424 QFutureWatcher< QVector <QgsDataItem *> > *mFutureWatcher;
429 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDataItem::Capabilities )
457 QgsLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri,
LayerType layerType, const QString &providerKey );
461 bool equal( const QgsDataItem *other ) override;
463 bool hasDragEnabled()
const override {
return true; }
473 QString
uri()
const {
return mUri; }
494 virtual QString
comments()
const {
return QString(); }
500 static QString layerTypeAsString(
LayerType layerType );
506 static QString iconName(
LayerType layerType );
522 static QIcon iconPoint();
523 static QIcon iconLine();
524 static QIcon iconPolygon();
525 static QIcon iconTable();
526 static QIcon iconRaster();
527 static QIcon iconDefault();
529 static QIcon iconMesh();
549 static QIcon iconDir();
550 static QIcon iconDataCollection();
558 static QIcon openDirIcon();
564 static QIcon homeDirIcon();
602 QIcon
icon()
override;
606 static bool hiddenPath(
const QString &path );
608 QList<QAction *>
actions( QWidget *parent )
override;
613 void directoryChanged();
620 QFileSystemWatcher *mFileSystemWatcher =
nullptr;
676 void mousePressEvent( QMouseEvent *event )
override;
679 void showHideColumn();
708 void addDirectory(
const QString &directory,
const QString &name = QString() );
719 void renameFavorite(
const QString &path,
const QString &name );
722 static QIcon iconFavorites();
724 QVariant
sortKey()
const override;
727 QVector<QgsDataItem *>
createChildren(
const QString &favDir,
const QString &name );
745 QgsZipItem(
QgsDataItem *parent,
const QString &name,
const QString &filePath,
const QString &path );
748 QStringList getZipFileList();
751 static QVector<dataItem_t *> sDataItemPtr
SIP_SKIP;
765 static QgsDataItem *itemFromPath(
QgsDataItem *parent,
const QString &filePath,
const QString &name,
const QString &path ) SIP_FACTORY
SIP_PYNAME( itemFromFilePath );
767 static QIcon iconZip();
788 QgsProjectHomeItem(
QgsDataItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
790 QIcon
icon()
override;
791 QVariant
sortKey()
const override;
793 QList<QAction *>
actions( QWidget *parent )
override;
809 QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
811 bool rename(
const QString &name )
override;
821 #endif // QGSDATAITEM_H A Collection: logical collection of layers or subcollections, e.g.
QStringList mSupportFormats
The list of supported formats.
virtual void childrenCreated()
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.
virtual Capabilities capabilities2() const
Returns the capabilities for the data item.
QgsDataItem * parent() const
Gets item parent.
QIcon icon() const
Gets the icons representation in the current frame.
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
QVector< QgsDataItem * > children() const
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).
virtual QgsMimeDataUtils::Uri mimeUri() const
Returns mime URI for the data item.
QStringList mSupportedCRS
The list of supported CRS.
LayerType
Types of layers that can be added to a map.
virtual void setCapabilities(Capabilities capabilities)
Sets the capabilities for the data item.
virtual bool hasDragEnabled() const
Returns true if the item may be dragged.
Children not yet created.
Creating children in separate thread (populating or refreshing)
Data item that can be used to report problems (e.g.
QString providerKey() const
Returns provider key.
A directory: contains subdirectories and layers.
static QStringList sProviderNames
Base class for all items in the model.
virtual QVariant sortKey() const
Returns the sorting key for the item.
Capabilities mCapabilities
virtual void setState(State state)
Set item state.
QString uri() const
Returns layer uri or empty string if layer cannot be created.
Contains various Favorites directories.
QStringList supportedCrs() const
Returns the supported CRS.
virtual QString comments() const
Returns comments of the layer.
virtual QString layerName() const
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...
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.
QStringList supportedFormats() const
Returns the supported formats.
QVector< QgsDataItem * > mChildren
bool hasDragEnabled() const override
Returns true if the item may be dragged.
Represents a favorite item.
void setIconName(const QString &iconName)
static QString vsiPrefix(const QString &uri)
QMap< QString, QIcon > mIconMap