16#include "moc_qgsbrowserguimodel.cpp"
46 if ( !index.isValid() )
47 return Qt::ItemFlags();
55 return Qt::ItemFlags();
59 const bool legacyAcceptDrop = ptr->
acceptDrop();
62 if ( legacyAcceptDrop )
64 flags |= Qt::ItemIsDropEnabled;
72 QVariant cachedProperty = ptr->property(
"_qgs_accept_drop_cached" );
74 bool refreshAcceptDrop =
true;
75 if ( cachedProperty.isValid() )
80 refreshAcceptDrop =
false;
82 flags |= Qt::ItemIsDropEnabled;
86 if ( refreshAcceptDrop )
91 if ( provider->acceptDrop( ptr, createDataItemContext() ) )
93 flags |= Qt::ItemIsDropEnabled;
99 cached.
acceptDrop = ( flags & Qt::ItemIsDropEnabled ) != 0;
102 var.setValue( cached );
103 ptr->setProperty(
"_qgs_accept_drop_cached", var );
119 const bool legacyAcceptDrop = destItem->
acceptDrop();
123 if ( legacyAcceptDrop )
135 if ( provider->handleDrop( destItem, createDataItemContext(),
data, action ) )
165 if ( provider->rename( item, value.toString(), createDataItemContext() ) )
172 return item->
rename( value.toString() );
@ Rename
Item can be renamed.
@ ItemRepresentsFile
Item's path() directly represents a file on disk.
A model for showing available data sources and other items in a structured tree.
QgsBrowserGuiModel(QObject *parent=nullptr)
Constructor for QgsBrowserGuiModel, with the specified parent object.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
void setMapCanvas(QgsMapCanvas *canvas)
Sets the associated map canvas that will be passed in QgsDataItemGuiContext to data items.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void setMessageBar(QgsMessageBar *bar)
Sets message bar that will be passed in QgsDataItemGuiContext to data items.
A model for showing available data sources and other items in a structured tree.
QgsDataItem * dataItem(const QModelIndex &idx) const
Returns the data item at the specified index, or nullptr if no item exists at the index.
Qt::ItemFlags flags(const QModelIndex &index) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QModelIndex parent(const QModelIndex &index) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Encapsulates the context in which a QgsDataItem is shown within the application GUI.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the data item.
void setMessageBar(QgsMessageBar *bar)
Sets the associated message bar.
QList< QgsDataItemGuiProvider * > providers() const
Returns the list of available providers.
Abstract base class for providers which affect how QgsDataItem items behave within the application GU...
Base class for all items in the model.
virtual Q_DECL_DEPRECATED bool handleDrop(const QMimeData *, Qt::DropAction)
Attempts to process the mime data dropped on this item.
virtual Q_DECL_DEPRECATED bool acceptDrop()
Returns whether the item accepts drag and dropped layers - e.g.
virtual Q_DECL_DEPRECATED bool rename(const QString &name)
Sets a new name for the item, and returns true if the item was successfully renamed.
virtual Qgis::BrowserItemCapabilities capabilities2() const
Returns the capabilities for the data item.
static QgsDataItemGuiProviderRegistry * dataItemGuiProviderRegistry()
Returns the global data item GUI provider registry, used for tracking providers which affect the brow...
Map canvas is a class for displaying all GIS data types on a canvas.
A bar for displaying non-blocking messages to the user.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
#define QgsDebugMsgLevel(str, level)