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;
111 virtual bool layerCollection()
const;
118 virtual QVector<QgsDataItem *> createChildren()
SIP_FACTORY;
136 virtual void setState( State state );
151 virtual void deleteChildItem(
QgsDataItem *child );
181 virtual QList<QAction *> actions( QWidget *parent );
191 virtual QList<QMenu *> menus( QWidget *parent );
219 virtual bool handleDoubleClick();
248 Q_DECLARE_FLAGS( Capabilities, Capability )
274 Q_DECL_DEPRECATED
virtual bool rename(
const QString &name )
SIP_DEPRECATED;
290 virtual void setCapabilities( Capabilities capabilities ) { mCapabilities = capabilities; }
295 static int findItem( QVector<QgsDataItem *> items,
QgsDataItem *item );
310 QVector<QgsDataItem *>
children()
const {
return mChildren; }
311 virtual QIcon icon();
318 QString
name()
const {
return mName; }
325 void setName(
const QString &name );
327 QString
path()
const {
return mPath; }
328 void setPath(
const QString &path ) { mPath = path; }
338 QString providerKey()
const;
348 void setProviderKey(
const QString &value );
351 static QString pathComponent(
const QString &component );
363 virtual QVariant sortKey()
const;
370 void setSortKey(
const QVariant &key );
376 void setIcon(
const QIcon &icon ) { mIcon = icon; }
377 void setIconName(
const QString &iconName ) { mIconName = iconName; }
383 static void deleteLater( QVector<QgsDataItem *> &items );
386 void moveToThread( QThread *targetThread );
389 virtual void populate(
const QVector<QgsDataItem *> &children );
394 virtual void refresh(
const QVector<QgsDataItem *> &children );
436 virtual void deleteLater();
440 virtual void populate(
bool foreground =
false );
443 virtual void depopulate();
445 virtual void refresh();
453 virtual void refreshConnections(
const QString &providerKey = QString() );
455 virtual void childrenCreated();
458 void beginInsertItems(
QgsDataItem *parent,
int first,
int last );
459 void endInsertItems();
460 void beginRemoveItems(
QgsDataItem *parent,
int first,
int last );
461 void endRemoveItems();
472 void connectionsChanged(
const QString &providerKey = QString() );
484 static QVector<QgsDataItem *> runCreateChildren(
QgsDataItem *item );
487 bool mDeferredDelete;
488 QFutureWatcher< QVector <QgsDataItem *> > *mFutureWatcher;
493 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsDataItem::Capabilities )
522 QgsLayerItem(
QgsDataItem *parent,
const QString &name,
const QString &path,
const QString &uri, LayerType layerType,
const QString &providerKey );
541 static LayerType typeFromMapLayer(
QgsMapLayer *layer );
544 QString
uri()
const {
return mUri; }
565 virtual QString
comments()
const {
return QString(); }
571 static QString layerTypeAsString( LayerType layerType );
577 static QString iconName( LayerType layerType );
593 QStringList mSupportedCRS;
595 QStringList mSupportFormats;
598 static QIcon iconPoint();
599 static QIcon iconLine();
600 static QIcon iconPolygon();
601 static QIcon iconTable();
602 static QIcon iconRaster();
603 static QIcon iconDefault();
605 static QIcon iconMesh();
607 static QIcon iconVectorTile();
610 virtual QString layerName()
const {
return name(); }
644 static QIcon iconDir();
650 static QIcon iconDataCollection();
658 static QIcon openDirIcon();
664 static QIcon homeDirIcon();
720 QIcon
icon()
override;
722 bool hasDragEnabled()
const override {
return true; }
726 static bool hiddenPath(
const QString &path );
730 void directoryChanged();
737 QFileSystemWatcher *mFileSystemWatcher =
nullptr;
797 void mousePressEvent( QMouseEvent *event )
override;
800 void showHideColumn();
829 void addDirectory(
const QString &directory,
const QString &name = QString() );
840 void renameFavorite(
const QString &path,
const QString &name );
843 static QIcon iconFavorites();
845 QVariant
sortKey()
const override;
848 QVector<QgsDataItem *>
createChildren(
const QString &favDir,
const QString &name );
869 QgsZipItem(
QgsDataItem *parent,
const QString &name,
const QString &filePath,
const QString &path,
const QString &providerKey = QString() );
872 QStringList getZipFileList();
875 static QVector<dataItem_t *> sDataItemPtr
SIP_SKIP;
891 static QIcon iconZip();
912 QgsProjectHomeItem(
QgsDataItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
914 QIcon
icon()
override;
915 QVariant
sortKey()
const override;
931 QgsFavoriteItem(
QgsFavoritesItem *parent,
const QString &name,
const QString &dirPath,
const QString &path );
933 bool rename(
const QString &name )
override;
944 #endif // QGSDATAITEM_H