25#include <QFutureWatcher>
30using namespace Qt::StringLiterals;
60 if ( qobject_cast<QgsLayerItem *>( sipCpp ) )
61 sipType = sipType_QgsLayerItem;
62 else if ( qobject_cast<QgsErrorItem *>( sipCpp ) )
63 sipType = sipType_QgsErrorItem;
64 else if ( qobject_cast<QgsDirectoryItem *>( sipCpp ) )
65 sipType = sipType_QgsDirectoryItem;
66 else if ( qobject_cast<QgsFavoritesItem *>( sipCpp ) )
67 sipType = sipType_QgsFavoritesItem;
68 else if ( qobject_cast<QgsZipItem *>( sipCpp ) )
69 sipType = sipType_QgsZipItem;
70 else if ( qobject_cast<QgsDataCollectionItem *>( sipCpp ) )
71 sipType = sipType_QgsDataCollectionItem;
72 else if ( qobject_cast<QgsProjectItem *>( sipCpp ) )
73 sipType = sipType_QgsProjectItem;
99 SIP_PYOBJECT __repr__();
101 QString str = u
"<QgsDataItem: \"%1\" %2>"_s.arg( sipCpp->name(), sipCpp->path() );
102 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
130 PyObject *sipResObj = sipCallMethod( 0, sipMethod,
"" );
133 sipIsErr = !sipResObj || sipParseResult( 0, sipMethod, sipResObj,
"H5", sipType_QVector_0101QgsDataItem, &sipRes ) < 0;
138 PyObject *pyItem = sipGetPyObject( item, sipType_QgsDataItem );
139 if ( pyItem != NULL )
142 sipTransferTo( pyItem, Py_None );
146 if ( sipResObj != NULL )
148 Py_DECREF( sipResObj );
223 virtual QList<QAction *> actions( QWidget *parent );
232 virtual QList<QMenu *> menus( QWidget *parent );
245#pragma clang diagnostic push
246#pragma clang diagnostic ignored "-Woverloaded-virtual"
259#pragma clang diagnostic pop
267 virtual bool handleDoubleClick();
315 Q_DECL_DEPRECATED virtual
bool rename( const QString &name )
SIP_DEPRECATED;
336 Q_DECL_DEPRECATED
void setCapabilities(
int capabilities )
SIP_DEPRECATED;
341 static int findItem( QVector<QgsDataItem *> items,
QgsDataItem *item );
354 result.reserve( items.size() );
357 if ( T *matchedItem = qobject_cast< T * >( item ) )
358 result << matchedItem;
392 virtual QIcon icon();
406 void setName(
const QString &name );
419 QString providerKey()
const;
429 void setProviderKey(
const QString &value );
432 static QString pathComponent(
const QString &component );
443 virtual QVariant sortKey()
const;
449 void setSortKey(
const QVariant &key );
462 static void deleteLater( QVector<QgsDataItem *> &items );
465 void moveToThread( QThread *targetThread );
540 virtual void populate(
bool foreground =
false );
631 static QVector<QgsDataItem *> runCreateChildren(
QgsDataItem *item );
634 bool mDeferredDelete =
false;
635 std::unique_ptr<QFutureWatcher<QVector<QgsDataItem *> >> mFutureWatcher;
653 SIP_PYOBJECT __repr__();
655 QString str = u
"<QgsErrorItem: \"%1\" %2>"_s.arg( sipCpp->name(), sipCpp->path() );
656 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
Provides global constants and enumerations for use throughout the application.
BrowserItemState
Browser item states.
@ NotPopulated
Children not yet created.
@ NoCapabilities
Item has no capabilities.
BrowserItemType
Browser item types.
QFlags< BrowserItemCapability > BrowserItemCapabilities
Browser item capabilities.
Provides common functionality for database based connections.
Animated icon is keeping an animation running if there are listeners connected to frameChanged.
Represents a coordinate reference system (CRS).
Base class for all items in the model.
void stateChanged(QgsDataItem *item, Qgis::BrowserItemState oldState)
Emitted when an item's state is changed.
bool hasChildren() const
Returns whether this item has children.
Qgis::BrowserItemType mType
int rowCount() const
Returns the number of rows of this item.
virtual void deleteChildItem(QgsDataItem *child)
Removes and deletes a child item, emitting relevant signals to the model.
QVector< QgsDataItem * > mChildren
int mCreatorAncestorDepth
Creator ancestor depth.
Qgis::BrowserItemState mState
void setToolTip(const QString &msg)
virtual Q_DECL_DEPRECATED bool handleDrop(const QMimeData *, Qt::DropAction)
Attempts to process the mime data dropped on this item.
virtual void refresh(const QVector< QgsDataItem * > &children)
Refresh the items from a specified list of child items.
void dataChanged(QgsDataItem *item)
Emitted when data changes for an item.
int creatorAncestorDepth() const
Returns the hierarchical depth of the item's original creator/source.
static void deleteLater(QVector< QgsDataItem * > &items)
void endRemoveItems()
Emitted after child items have been removed from this data item.
virtual bool layerCollection() const
Returns true if the data item is a collection of layers The default implementation returns false,...
QVector< QgsDataItem * > children() const
void beginRemoveItems(QgsDataItem *parent, int first, int last)
Emitted before child items are removed from this data item.
virtual Q_DECL_DEPRECATED bool acceptDrop()
Returns whether the item accepts drag and dropped layers - e.g.
Qgis::BrowserItemCapabilities mCapabilities
Qgis::BrowserItemType type() const
QgsDataItem(Qgis::BrowserItemType type, QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
Constructor for QgsDataItem, with the specified parent item.
virtual QVector< QgsDataItem * > createChildren()
Create children.
QMap< QString, QIcon > mIconMap
Qgis::BrowserItemState state() const
virtual void childrenCreated()
virtual QgsDataItem * removeChildItem(QgsDataItem *child)
Removes a child item and returns it without deleting it.
virtual bool hasDragEnabled() const
Returns true if the item may be dragged.
QVariant mSortKey
Custom sort key. If invalid, name() will be used for sorting instead.
void updateIcon()
Will request a repaint of this icon.
void connectionsChanged(const QString &providerKey=QString())
Emitted when the connections of the provider with the specified providerKey have changed.
QString name() const
Returns the name of the item (the displayed text for the item).
virtual void setState(Qgis::BrowserItemState state)
Set item state.
void beginInsertItems(QgsDataItem *parent, int first, int last)
Emitted before child items are added to this data item.
virtual void refreshConnections(const QString &providerKey=QString())
Causes a data item provider to refresh all registered connections.
virtual void setCapabilities(Qgis::BrowserItemCapabilities capabilities)
Sets the capabilities for the data item.
virtual void addChildItem(QgsDataItem *child, bool refresh=false)
Inserts a new child item.
QgsDataItem * parent() const
Gets item parent.
virtual Q_DECL_DEPRECATED QWidget * paramWidget()
Returns source widget from data item for QgsBrowserPropertiesWidget.
void setIcon(const QIcon &icon)
void setIconName(const QString &iconName)
void setPath(const QString &path)
QString providerKey() const
Returns the provider key that created this item (e.g.
void endInsertItems()
Emitted after child items have been added to this data item.
virtual Qgis::BrowserItemCapabilities capabilities2() const
Returns the capabilities for the data item.
virtual void populate(const QVector< QgsDataItem * > &children)
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
virtual void depopulate()
Remove children recursively and set as not populated. This is used when refreshing collapsed items.
bool deferredDelete() const
Returns true if the item is scheduled to be deleted.
static QList< T * > filteredItems(const QList< QgsDataItem * > &items)
Returns a filtered list of data items which match the template type.
QgsErrorItem(QgsDataItem *parent, const QString &error, const QString &path)
Contains utility functions for working with MIME data.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_VIRTUAL_CATCHER_CODE(code)
QgsDataItem * dataItem_t(QString, QgsDataItem *)