|
| 1 | +/************************************************************************ |
| 2 | + * This file has been generated automatically from * |
| 3 | + * * |
| 4 | + * src/core/layout/qgslayoutmodel.h * |
| 5 | + * * |
| 6 | + * Do not edit manually ! Edit header and run scripts/sipify.pl again * |
| 7 | + ************************************************************************/ |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +class QgsLayoutModel: QAbstractItemModel |
| 16 | +{ |
| 17 | +%Docstring |
| 18 | + |
| 19 | + A model for items attached to a layout. The model also maintains the z-order for the |
| 20 | + layout, and must be notified whenever item stacking changes. |
| 21 | + |
| 22 | + Internally, QgsLayoutModel maintains two lists. One contains a complete list of all items for |
| 23 | + the layout, ordered by their position within the z-order stack. |
| 24 | + |
| 25 | + The second list contains only items which are currently displayed in the layout's scene. |
| 26 | + It is used as a cache of the last known stacking order, so that the model can compare the current |
| 27 | + stacking of items in the layout to the last known state, and emit the corresponding signals |
| 28 | + as required. |
| 29 | + |
| 30 | +.. versionadded:: 3.0 |
| 31 | +%End |
| 32 | + |
| 33 | +%TypeHeaderCode |
| 34 | +#include "qgslayoutmodel.h" |
| 35 | +%End |
| 36 | + public: |
| 37 | + |
| 38 | + enum Columns |
| 39 | + { |
| 40 | + Visibility, |
| 41 | + LockStatus, |
| 42 | + ItemId, |
| 43 | + }; |
| 44 | + |
| 45 | + explicit QgsLayoutModel( QgsLayout *layout, QObject *parent /TransferThis/ = 0 ); |
| 46 | +%Docstring |
| 47 | + Constructor for a QgsLayoutModel attached to the specified ``layout``. |
| 48 | +%End |
| 49 | + |
| 50 | + virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const; |
| 51 | + |
| 52 | + virtual QModelIndex parent( const QModelIndex &index ) const; |
| 53 | + |
| 54 | + virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; |
| 55 | + |
| 56 | + virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; |
| 57 | + |
| 58 | + virtual QVariant data( const QModelIndex &index, int role ) const; |
| 59 | + |
| 60 | + virtual Qt::ItemFlags flags( const QModelIndex &index ) const; |
| 61 | + |
| 62 | + virtual bool setData( const QModelIndex &index, const QVariant &value, int role ); |
| 63 | + |
| 64 | + virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; |
| 65 | + |
| 66 | + virtual Qt::DropActions supportedDropActions() const; |
| 67 | + |
| 68 | + virtual QStringList mimeTypes() const; |
| 69 | + virtual QMimeData *mimeData( const QModelIndexList &indexes ) const; |
| 70 | + virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ); |
| 71 | + |
| 72 | + virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ); |
| 73 | + |
| 74 | + |
| 75 | + void clear(); |
| 76 | +%Docstring |
| 77 | + Clears all items from z-order list and resets the model |
| 78 | +%End |
| 79 | + |
| 80 | + int zOrderListSize() const; |
| 81 | +%Docstring |
| 82 | + Returns the size of the z-order list. |
| 83 | + :rtype: int |
| 84 | +%End |
| 85 | + |
| 86 | + void rebuildZList(); |
| 87 | +%Docstring |
| 88 | + Rebuilds the z-order list, based on the current stacking of items in the layout. |
| 89 | + This method should be called after adding multiple items to the layout. |
| 90 | +%End |
| 91 | + |
| 92 | + void addItemAtTop( QgsLayoutItem *item ); |
| 93 | +%Docstring |
| 94 | + Adds an ``item`` to the top of the layout z stack. The item must not already exist in the z-order list. |
| 95 | +.. seealso:: reorderItemToTop() |
| 96 | +%End |
| 97 | + |
| 98 | + void removeItem( QgsLayoutItem *item ); |
| 99 | +%Docstring |
| 100 | + Removes an ``item`` from the z-order list. |
| 101 | +%End |
| 102 | + |
| 103 | + bool reorderItemUp( QgsLayoutItem *item ); |
| 104 | +%Docstring |
| 105 | + Moves an ``item`` up the z-order list. |
| 106 | + |
| 107 | + Returns true if ``item`` was moved. Returns false if ``item`` was not found |
| 108 | + in z-order list or was already at the top of the z-order list. |
| 109 | + |
| 110 | +.. seealso:: reorderItemDown() |
| 111 | +.. seealso:: reorderItemToTop() |
| 112 | +.. seealso:: reorderItemToBottom() |
| 113 | + :rtype: bool |
| 114 | +%End |
| 115 | + |
| 116 | + bool reorderItemDown( QgsLayoutItem *item ); |
| 117 | +%Docstring |
| 118 | + Moves an ``item`` down the z-order list. |
| 119 | + |
| 120 | + Returns true if ``item`` was moved. Returns false if ``item`` was not found |
| 121 | + in z-order list or was already at the bottom of the z-order list. |
| 122 | + |
| 123 | +.. seealso:: reorderItemUp() |
| 124 | +.. seealso:: reorderItemToTop() |
| 125 | +.. seealso:: reorderItemToBottom() |
| 126 | + :rtype: bool |
| 127 | +%End |
| 128 | + |
| 129 | + bool reorderItemToTop( QgsLayoutItem *item ); |
| 130 | +%Docstring |
| 131 | + Moves an ``item`` to the top of the z-order list. |
| 132 | + |
| 133 | + Returns true if ``item`` was moved. Returns false if ``item`` was not found |
| 134 | + in z-order list or was already at the top of the z-order list. |
| 135 | + |
| 136 | +.. seealso:: reorderItemUp() |
| 137 | +.. seealso:: reorderItemDown() |
| 138 | +.. seealso:: reorderItemToBottom() |
| 139 | + :rtype: bool |
| 140 | +%End |
| 141 | + |
| 142 | + bool reorderItemToBottom( QgsLayoutItem *item ); |
| 143 | +%Docstring |
| 144 | + Moves an ``item`` to the bottom of the z-order list. |
| 145 | + |
| 146 | + Returns true if ``item`` was moved. Returns false if ``item`` was not found |
| 147 | + in z-order list or was already at the bottom of the z-order list. |
| 148 | + |
| 149 | +.. seealso:: reorderItemUp() |
| 150 | +.. seealso:: reorderItemDown() |
| 151 | +.. seealso:: reorderItemToTop() |
| 152 | + :rtype: bool |
| 153 | +%End |
| 154 | + |
| 155 | + QgsLayoutItem *findItemAbove( QgsLayoutItem *item ) const; |
| 156 | +%Docstring |
| 157 | + Finds the next layout item above an ``item``, where ``item`` is |
| 158 | + the item to search above. |
| 159 | + |
| 160 | + If no items were found, a None will be returned. |
| 161 | + |
| 162 | +.. seealso:: findItemBelow() |
| 163 | + :rtype: QgsLayoutItem |
| 164 | +%End |
| 165 | + |
| 166 | + QgsLayoutItem *findItemBelow( QgsLayoutItem *item ) const; |
| 167 | +%Docstring |
| 168 | + Finds the next layout item below an ``item``, where ``item`` |
| 169 | + is the item to search below. |
| 170 | + |
| 171 | + If no items were found, a None will be returned. |
| 172 | + |
| 173 | +.. seealso:: findItemAbove() |
| 174 | + :rtype: QgsLayoutItem |
| 175 | +%End |
| 176 | + |
| 177 | + QList<QgsLayoutItem *> &zOrderList(); |
| 178 | +%Docstring |
| 179 | + Returns the item z-order list. |
| 180 | + :rtype: list of QgsLayoutItem |
| 181 | +%End |
| 182 | + |
| 183 | + void setItemRemoved( QgsLayoutItem *item ); |
| 184 | +%Docstring |
| 185 | + Marks an ``item`` as removed from the layout. This must be called whenever an item |
| 186 | + is about to be removed from the layout. |
| 187 | +%End |
| 188 | + |
| 189 | + |
| 190 | + void updateItemDisplayName( QgsLayoutItem *item ); |
| 191 | +%Docstring |
| 192 | + Must be called when an ``item``'s display name is modified. |
| 193 | + |
| 194 | +.. seealso:: updateItemLockStatus() |
| 195 | +.. seealso:: updateItemVisibility() |
| 196 | +.. seealso:: updateItemSelectStatus() |
| 197 | +%End |
| 198 | + |
| 199 | + void updateItemLockStatus( QgsLayoutItem *item ); |
| 200 | +%Docstring |
| 201 | + Must be called when an ``item``'s lock status changes. |
| 202 | +.. seealso:: updateItemDisplayName() |
| 203 | +.. seealso:: updateItemVisibility() |
| 204 | +.. seealso:: updateItemSelectStatus() |
| 205 | +%End |
| 206 | + |
| 207 | + void updateItemVisibility( QgsLayoutItem *item ); |
| 208 | +%Docstring |
| 209 | + Must be called when an ``item``'s visibility changes. |
| 210 | +.. seealso:: updateItemDisplayName() |
| 211 | +.. seealso:: updateItemLockStatus() |
| 212 | +.. seealso:: updateItemSelectStatus() |
| 213 | +%End |
| 214 | + |
| 215 | + void updateItemSelectStatus( QgsLayoutItem *item ); |
| 216 | +%Docstring |
| 217 | + Must be called when an ``item``'s selection status changes. |
| 218 | +.. seealso:: updateItemDisplayName() |
| 219 | +.. seealso:: updateItemVisibility() |
| 220 | +.. seealso:: updateItemLockStatus() |
| 221 | +%End |
| 222 | + |
| 223 | + QModelIndex indexForItem( QgsLayoutItem *item, const int column = 0 ); |
| 224 | +%Docstring |
| 225 | + Returns the QModelIndex corresponding to a QgsLayoutItem ``item`` and \column, if possible. |
| 226 | + :rtype: QModelIndex |
| 227 | +%End |
| 228 | + |
| 229 | + public slots: |
| 230 | + |
| 231 | + void setSelected( const QModelIndex &index ); |
| 232 | +%Docstring |
| 233 | + Sets an item as the current selection from a QModelIndex ``index``. |
| 234 | +%End |
| 235 | + |
| 236 | +}; |
| 237 | + |
| 238 | + |
| 239 | +class QgsLayoutProxyModel: QSortFilterProxyModel |
| 240 | +{ |
| 241 | +%Docstring |
| 242 | + Allows for filtering a QgsLayoutModel by item type. |
| 243 | +.. versionadded:: 3.0 |
| 244 | +%End |
| 245 | + |
| 246 | +%TypeHeaderCode |
| 247 | +#include "qgslayoutmodel.h" |
| 248 | +%End |
| 249 | + public: |
| 250 | + |
| 251 | + QgsLayoutProxyModel( QgsLayout *layout, QObject *parent /TransferThis/ = 0 ); |
| 252 | +%Docstring |
| 253 | + Constructor for QgsLayoutProxyModelm, attached to the specified ``layout``. |
| 254 | +%End |
| 255 | + |
| 256 | + QgsLayoutItemRegistry::ItemType filterType() const; |
| 257 | +%Docstring |
| 258 | + Returns the current item type filter, or QgsLayoutItemRegistry.LayoutItem if no |
| 259 | + item type filter is set. |
| 260 | +.. seealso:: setFilterType() |
| 261 | + :rtype: QgsLayoutItemRegistry.ItemType |
| 262 | +%End |
| 263 | + |
| 264 | + void setFilterType( QgsLayoutItemRegistry::ItemType filter ); |
| 265 | +%Docstring |
| 266 | + Sets the item type ``filter``. Only matching item types will be shown. |
| 267 | + Set ``filter`` to QgsLayoutItemRegistry.LayoutItem to show all |
| 268 | + item types. |
| 269 | +.. seealso:: filterType() |
| 270 | +%End |
| 271 | + |
| 272 | + void setExceptedItemList( const QList< QgsLayoutItem * > &items ); |
| 273 | +%Docstring |
| 274 | + Sets a list of specific ``items`` to exclude from the model. |
| 275 | +.. seealso:: exceptedItemList() |
| 276 | +%End |
| 277 | + |
| 278 | + QList< QgsLayoutItem * > exceptedItemList() const; |
| 279 | +%Docstring |
| 280 | + Returns the list of specific items excluded from the model. |
| 281 | +.. seealso:: setExceptedItemList() |
| 282 | + :rtype: list of QgsLayoutItem |
| 283 | +%End |
| 284 | + |
| 285 | + QgsLayoutModel *sourceLayerModel() const; |
| 286 | +%Docstring |
| 287 | + Returns the QgsLayoutModel used in this proxy model. |
| 288 | + :rtype: QgsLayoutModel |
| 289 | +%End |
| 290 | + |
| 291 | + QgsLayoutItem *itemFromSourceIndex( const QModelIndex &sourceIndex ) const; |
| 292 | +%Docstring |
| 293 | + Returns the QgsLayoutItem corresponding to an index from the source |
| 294 | + QgsLayoutModel model. |
| 295 | + :rtype: QgsLayoutItem |
| 296 | +%End |
| 297 | + |
| 298 | + protected: |
| 299 | + virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const; |
| 300 | + |
| 301 | + virtual bool lessThan( const QModelIndex &left, const QModelIndex &right ) const; |
| 302 | + |
| 303 | + |
| 304 | +}; |
| 305 | + |
| 306 | + |
| 307 | + |
| 308 | +/************************************************************************ |
| 309 | + * This file has been generated automatically from * |
| 310 | + * * |
| 311 | + * src/core/layout/qgslayoutmodel.h * |
| 312 | + * * |
| 313 | + * Do not edit manually ! Edit header and run scripts/sipify.pl again * |
| 314 | + ************************************************************************/ |
0 commit comments