1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/browser/qgsdataitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsDataItem : QObject
{
%Docstring(signature="appended")
Base class for all items in the model.
Parent/children hierarchy is not based on QObject.
%End
%TypeHeaderCode
#include "qgsdataitem.h"
#include "qgslayeritem.h"
#include "qgsdirectoryitem.h"
#include "qgsfavoritesitem.h"
#include "qgszipitem.h"
#include "qgsdatacollectionitem.h"
#include "qgsprojectitem.h"
%End
%ConvertToSubClassCode
if ( qobject_cast<QgsLayerItem *>( sipCpp ) )
sipType = sipType_QgsLayerItem;
else if ( qobject_cast<QgsErrorItem *>( sipCpp ) )
sipType = sipType_QgsErrorItem;
else if ( qobject_cast<QgsDirectoryItem *>( sipCpp ) )
sipType = sipType_QgsDirectoryItem;
else if ( qobject_cast<QgsFavoritesItem *>( sipCpp ) )
sipType = sipType_QgsFavoritesItem;
else if ( qobject_cast<QgsZipItem *>( sipCpp ) )
sipType = sipType_QgsZipItem;
else if ( qobject_cast<QgsDataCollectionItem *>( sipCpp ) )
sipType = sipType_QgsDataCollectionItem;
else if ( qobject_cast<QgsProjectItem *>( sipCpp ) )
sipType = sipType_QgsProjectItem;
else
sipType = 0;
%End
public:
QgsDataItem( Qgis::BrowserItemType type, QgsDataItem *parent /TransferThis/, const QString &name, const QString &path, const QString &providerKey = QString() );
%Docstring
Constructor for QgsDataItem, with the specified ``parent`` item.
The ``name`` argument specifies the text to show in the model for the
item. A translated string should be used wherever appropriate.
The ``path`` argument gives the item path in the browser tree. The
``path`` string can take any form, but QgsDataItem items pointing to
different logical locations should always use a different item ``path``.
The optional ``providerKey`` string (added in QGIS 3.12) can be used to
specify the key for the :py:class:`QgsDataItemProvider` that created
this item.
%End
~QgsDataItem();
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsDataItem: \"%1\" %2>" ).arg( sipCpp->name(), sipCpp->path() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
bool hasChildren();
virtual bool layerCollection() const;
%Docstring
Returns ``True`` if the data item is a collection of layers The default
implementation returns ``False``, subclasses must implement this method
if their children are layers.
.. versionadded:: 3.14
%End
int rowCount();
virtual QVector<QgsDataItem *> createChildren() /TransferBack/;
%Docstring
Create children. Children are not expected to have parent set.
.. warning::
This method MUST BE THREAD SAFE.
%End
%VirtualCatcherCode
PyObject *sipResObj = sipCallMethod( 0, sipMethod, "" );
// H = Convert a Python object to a mapped type instance.
// 5 = 1 (disallows the conversion of Py_None to NULL) + 4 (returns a copy of the C/C++ instance)
sipIsErr = !sipResObj || sipParseResult( 0, sipMethod, sipResObj, "H5", sipType_QVector_0101QgsDataItem, &sipRes ) < 0;
if ( !sipIsErr )
{
for ( QgsDataItem *item : sipRes )
{
PyObject *pyItem = sipGetPyObject( item, sipType_QgsDataItem );
if ( pyItem != NULL )
{
// pyItem is given an extra reference which is removed when the C++ instance’s destructor is called.
sipTransferTo( pyItem, Py_None );
}
}
}
if ( sipResObj != NULL )
{
Py_DECREF( sipResObj );
}
%End
Qgis::BrowserItemState state() const;
virtual void setState( Qgis::BrowserItemState state );
%Docstring
Set item state. It also take care about starting/stopping loading icon
animation.
:param state:
%End
virtual void addChildItem( QgsDataItem *child /Transfer/, bool refresh = false );
%Docstring
Inserts a new child item. The child will be inserted at a position using
an alphabetical order based on mName.
:param child: child item to insert. Ownership is transferred, and item
parent will be set and relevant connections made.
:param refresh: set to ``True`` to refresh populated item, emitting
relevant signals to the model
.. seealso:: :py:func:`deleteChildItem`
%End
virtual void deleteChildItem( QgsDataItem *child );
%Docstring
Removes and deletes a child item, emitting relevant signals to the
model.
:param child: child to remove. Item must exist as a current child.
.. seealso:: :py:func:`addChildItem`
%End
virtual QgsDataItem *removeChildItem( QgsDataItem *child ) /TransferBack/;
%Docstring
Removes a child item and returns it without deleting it. Emits relevant
signals to model as required.
:param child: child to remove
:return: pointer to the removed item or ``None`` if no such item was
found
%End
virtual bool equal( const QgsDataItem *other );
%Docstring
Returns ``True`` if this item is equal to another item (by testing item
type and path).
%End
virtual QWidget *paramWidget() /Factory,Deprecated/;
%Docstring
Returns source widget from data item for
:py:class:`QgsBrowserPropertiesWidget`
Use :py:func:`QgsDataItemGuiProvider.createParamWidget()` instead
.. deprecated:: 3.10
%End
virtual QList<QAction *> actions( QWidget *parent );
%Docstring
Returns the list of actions available for this item. This is usually
used for the popup menu on right-clicking the item. Subclasses should
override this to provide actions.
Subclasses should ensure that ownership of created actions is correctly
handled by parenting them to the specified parent widget.
%End
virtual QList<QMenu *> menus( QWidget *parent );
%Docstring
Returns the list of menus available for this item. This is usually used
for the popup menu on right-clicking the item. Subclasses should
override this to provide actions. Subclasses should ensure that
ownership of created menus is correctly handled by parenting them to the
specified parent widget.
:param parent: a parent widget of the menu
:return: list of menus
%End
virtual bool acceptDrop() /Deprecated/;
%Docstring
Returns whether the item accepts drag and dropped layers - e.g. for
importing a dataset to a provider. Subclasses should override this and
:py:func:`~QgsDataItem.handleDrop` to accept dropped layers.
.. seealso:: :py:func:`handleDrop`
.. seealso:: :py:func:`QgsDataItemGuiProvider.handleDrop`
.. deprecated:: 3.10
%End
virtual bool handleDrop( const QMimeData * /*data*/, Qt::DropAction /*action*/ ) /Deprecated/;
%Docstring
Attempts to process the mime data dropped on this item. Subclasses must
override this and :py:func:`~QgsDataItem.acceptDrop` if they accept
dropped layers.
.. seealso:: :py:func:`acceptDrop`
.. seealso:: :py:func:`QgsDataItemGuiProvider.handleDrop`
.. deprecated:: 3.10
%End
virtual bool handleDoubleClick();
%Docstring
Called when a user double clicks on the item. Subclasses should return
``True`` if they have implemented a double-click handler and do not want
the default double-click behavior for items.
%End
virtual bool hasDragEnabled() const;
%Docstring
Returns ``True`` if the item may be dragged. Default implementation
returns ``False``. A draggable item has to implement
:py:func:`~QgsDataItem.mimeUris` that will be used to pass data.
.. seealso:: :py:func:`mimeUris`
%End
virtual QgsMimeDataUtils::Uri mimeUri() const /Deprecated/;
%Docstring
Returns mime URI for the data item. Items that return valid URI will be
returned in mime data when dragging a selection from browser model.
.. seealso:: :py:func:`hasDragEnabled`
.. deprecated:: 3.18
Use :py:func:`~QgsDataItem.mimeUris` instead.
%End
virtual QgsMimeDataUtils::UriList mimeUris() const;
%Docstring
Returns mime URIs for the data item, most data providers will only
return a single URI but some data collection items (e.g. GPKG, OGR) may
report multiple URIs (e.g. for vector and raster layer types).
Items that return valid URI will be returned in mime data when dragging
a selection from browser model.
.. versionadded:: 3.18
%End
virtual bool setCrs( const QgsCoordinateReferenceSystem &crs ) /Deprecated/;
%Docstring
Writes the selected crs into data source. The original data source will
be modified when calling this method.
.. deprecated:: 3.6
This method is no longer used by QGIS and will be removed in QGIS 4.0.
%End
virtual bool rename( const QString &name ) /Deprecated/;
%Docstring
Sets a new ``name`` for the item, and returns ``True`` if the item was
successfully renamed.
Items which implement this method should return the QgsDataItem.Rename
capability.
The default implementation does nothing.
Use :py:class:`QgsDataItemGuiProvider`:
.. versionadded:: 3.4
.. deprecated:: 3.10
%End
virtual Qgis::BrowserItemCapabilities capabilities2() const;
%Docstring
Returns the capabilities for the data item.
.. seealso:: :py:func:`setCapabilities`
%End
virtual void setCapabilities( Qgis::BrowserItemCapabilities capabilities ) /PyName=setCapabilitiesV2/;
%Docstring
Sets the capabilities for the data item.
.. seealso:: :py:func:`capabilities2`
%End
void setCapabilities( int capabilities ) /Deprecated/;
%Docstring
.. deprecated:: 3.40
Use setCapabilitiesV2 instead.
%End
static int findItem( QVector<QgsDataItem *> items, QgsDataItem *item );
Qgis::BrowserItemType type() const;
QgsDataItem *parent() const;
%Docstring
Gets item parent. QgsDataItem maintains its own items hierarchy, it does
not use QObject hierarchy.
%End
void setParent( QgsDataItem *parent );
%Docstring
Set item parent and connect / disconnect parent to / from item signals.
It does not add itself to parents children (mChildren)
%End
QVector<QgsDataItem *> children() const;
virtual QIcon icon();
QString name() const;
%Docstring
Returns the name of the item (the displayed text for the item).
.. seealso:: :py:func:`setName`
%End
void setName( const QString &name );
%Docstring
Sets the ``name`` of the item (the displayed text for the item).
.. seealso:: :py:func:`name`
%End
QString path() const;
void setPath( const QString &path );
QString providerKey() const;
%Docstring
Returns the provider key that created this item (e.g. "PostGIS")
If key has a prefix "special:", it marks that the item was not created
with a provider, but manually. For example "special:Favorites",
"special:Home"
.. versionadded:: 3.12
%End
void setProviderKey( const QString &value );
%Docstring
Sets the provider key that created this item (e.g. "PostGIS")
If key has a prefix "special:", it marks that the item was not created
with a provider, but manually. For example "special:Favorites"
.. versionadded:: 3.12
%End
static QString pathComponent( const QString &component );
%Docstring
Create path component replacing path separators
%End
virtual QVariant sortKey() const;
%Docstring
Returns the sorting key for the item. By default
:py:func:`~QgsDataItem.name` is returned, but
:py:func:`~QgsDataItem.setSortKey` can be used to set a custom sort key
for the item.
Alternatively subclasses can override this method to return a custom
sort key.
.. seealso:: :py:func:`setSortKey`
%End
void setSortKey( const QVariant &key );
%Docstring
Sets a custom sorting ``key`` for the item.
.. seealso:: :py:func:`sortKey`
%End
void setIcon( const QIcon &icon );
void setIconName( const QString &iconName );
void setToolTip( const QString &msg );
QString toolTip() const;
static void deleteLater( QVector<QgsDataItem *> &items );
void moveToThread( QThread *targetThread );
%Docstring
Move object and all its descendants to thread
%End
virtual QgsAbstractDatabaseProviderConnection *databaseConnection() const /Factory/;
%Docstring
For data items that represent a DB connection or one of its children,
this method returns a connection. All other data items will return NULL.
Ownership of the returned objects is transferred to the caller.
.. versionadded:: 3.16
%End
protected:
virtual void populate( const QVector<QgsDataItem *> &children );
virtual void refresh( const QVector<QgsDataItem *> &children );
%Docstring
Refresh the items from a specified list of child items.
%End
bool deferredDelete();
%Docstring
The item is scheduled to be deleted. E.g. if
:py:func:`~QgsDataItem.deleteLater` is called when item is in Populating
state (:py:func:`~QgsDataItem.createChildren` running in another
thread), the :py:func:`~QgsDataItem.deferredDelete` returns ``True`` and
item will be deleted once Populating finished. Items with slow
:py:func:`~QgsDataItem.reateChildren` (for example network or database
based) may check during :py:func:`~QgsDataItem.createChildren` if
:py:func:`~QgsDataItem.deferredDelete` returns ``True`` and return from
:py:func:`~QgsDataItem.createChildren` immediately because result will
be useless.
%End
public slots:
virtual void deleteLater();
%Docstring
Safely delete the item:
- disconnects parent
- unsets parent (but does not remove itself)
- deletes all its descendants recursively
- waits until Populating state (:py:func:`~QgsDataItem.createChildren`
in thread) finished without blocking main thread
- calls QObject.deleteLater()
%End
virtual void populate( bool foreground = false );
virtual void depopulate();
%Docstring
Remove children recursively and set as not populated. This is used when
refreshing collapsed items.
%End
virtual void refresh();
virtual void refreshConnections( const QString &providerKey = QString() );
%Docstring
Causes a data item provider to refresh all registered connections.
If ``providerKey`` is specified then only the matching provider will be
refreshed. Otherwise, all providers will be refreshed (which is
potentially very expensive!).
%End
virtual void childrenCreated();
signals:
void beginInsertItems( QgsDataItem *parent, int first, int last );
%Docstring
Emitted before child items are added to this data item.
This signal *must* be followed by
:py:func:`~QgsDataItem.endInsertItems`.
:param parent: the parent item having children added, will always be
this object
:param first: index of first child item to be added
:param last: index last child item, after the addition has occurred
.. seealso:: :py:func:`endInsertItems`
%End
void endInsertItems();
%Docstring
Emitted after child items have been added to this data item.
This signal will always be preceded by
:py:func:`~QgsDataItem.beginInsertItems`.
.. seealso:: :py:func:`beginInsertItems`
%End
void beginRemoveItems( QgsDataItem *parent, int first, int last );
%Docstring
Emitted before child items are removed from this data item.
This signal *must* be followed by
:py:func:`~QgsDataItem.endRemoveItems`.
:param parent: the parent item having children removed, will always be
this object
:param first: index of first child item to be removed
:param last: index of the last child item to be removed
.. seealso:: :py:func:`endRemoveItems`
%End
void endRemoveItems();
%Docstring
Emitted after child items have been removed from this data item.
This signal will always be preceded by
:py:func:`~QgsDataItem.beginRemoveItems`.
.. seealso:: :py:func:`beginRemoveItems`
%End
void dataChanged( QgsDataItem *item );
%Docstring
Emitted when data changes for an ``item``.
%End
void stateChanged( QgsDataItem *item, Qgis::BrowserItemState oldState );
%Docstring
Emitted when an item's state is changed.
%End
void connectionsChanged( const QString &providerKey = QString() );
%Docstring
Emitted when the connections of the provider with the specified
``providerKey`` have changed.
This signal is normally forwarded to the app in order to refresh the
connection item in the provider dialogs and to refresh the connection
items in the other open browsers.
%End
protected slots:
void updateIcon();
%Docstring
Will request a repaint of this icon.
%End
};
class QgsErrorItem : QgsDataItem
{
%Docstring(signature="appended")
Data item that can be used to report problems (e.g. network error)
%End
%TypeHeaderCode
#include "qgsdataitem.h"
%End
public:
QgsErrorItem( QgsDataItem *parent, const QString &error, const QString &path );
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsErrorItem: \"%1\" %2>" ).arg( sipCpp->name(), sipCpp->path() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/browser/qgsdataitem.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|