Skip to content

Commit

Permalink
Hide most of QgsLayoutModel from stable API and remove from bindings
Browse files Browse the repository at this point in the history
We only expose the QAbstractItemModel interface as stable API - the
rest is non-stable and subject to change.
  • Loading branch information
nyalldawson committed Oct 6, 2017
1 parent a66f2cb commit fd0cba3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 153 deletions.
151 changes: 0 additions & 151 deletions python/core/layout/qgslayoutmodel.sip
Expand Up @@ -72,153 +72,6 @@ class QgsLayoutModel: QAbstractItemModel
virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );


void clear();
%Docstring
Clears all items from z-order list and resets the model
%End

int zOrderListSize() const;
%Docstring
Returns the size of the z-order list.
:rtype: int
%End

void rebuildZList();
%Docstring
Rebuilds the z-order list, based on the current stacking of items in the layout.
This method should be called after adding multiple items to the layout.
%End

void addItemAtTop( QgsLayoutItem *item );
%Docstring
Adds an ``item`` to the top of the layout z stack. The item must not already exist in the z-order list.
.. seealso:: reorderItemToTop()
%End

void removeItem( QgsLayoutItem *item );
%Docstring
Removes an ``item`` from the z-order list.
%End

bool reorderItemUp( QgsLayoutItem *item );
%Docstring
Moves an ``item`` up the z-order list.

Returns true if ``item`` was moved. Returns false if ``item`` was not found
in z-order list or was already at the top of the z-order list.

.. seealso:: reorderItemDown()
.. seealso:: reorderItemToTop()
.. seealso:: reorderItemToBottom()
:rtype: bool
%End

bool reorderItemDown( QgsLayoutItem *item );
%Docstring
Moves an ``item`` down the z-order list.

Returns true if ``item`` was moved. Returns false if ``item`` was not found
in z-order list or was already at the bottom of the z-order list.

.. seealso:: reorderItemUp()
.. seealso:: reorderItemToTop()
.. seealso:: reorderItemToBottom()
:rtype: bool
%End

bool reorderItemToTop( QgsLayoutItem *item );
%Docstring
Moves an ``item`` to the top of the z-order list.

Returns true if ``item`` was moved. Returns false if ``item`` was not found
in z-order list or was already at the top of the z-order list.

.. seealso:: reorderItemUp()
.. seealso:: reorderItemDown()
.. seealso:: reorderItemToBottom()
:rtype: bool
%End

bool reorderItemToBottom( QgsLayoutItem *item );
%Docstring
Moves an ``item`` to the bottom of the z-order list.

Returns true if ``item`` was moved. Returns false if ``item`` was not found
in z-order list or was already at the bottom of the z-order list.

.. seealso:: reorderItemUp()
.. seealso:: reorderItemDown()
.. seealso:: reorderItemToTop()
:rtype: bool
%End

QgsLayoutItem *findItemAbove( QgsLayoutItem *item ) const;
%Docstring
Finds the next layout item above an ``item``, where ``item`` is
the item to search above.

If no items were found, a None will be returned.

.. seealso:: findItemBelow()
:rtype: QgsLayoutItem
%End

QgsLayoutItem *findItemBelow( QgsLayoutItem *item ) const;
%Docstring
Finds the next layout item below an ``item``, where ``item``
is the item to search below.

If no items were found, a None will be returned.

.. seealso:: findItemAbove()
:rtype: QgsLayoutItem
%End

QList<QgsLayoutItem *> &zOrderList();
%Docstring
Returns the item z-order list.
:rtype: list of QgsLayoutItem
%End

void setItemRemoved( QgsLayoutItem *item );
%Docstring
Marks an ``item`` as removed from the layout. This must be called whenever an item
is about to be removed from the layout.
%End


void updateItemDisplayName( QgsLayoutItem *item );
%Docstring
Must be called when an ``item``'s display name is modified.

.. seealso:: updateItemLockStatus()
.. seealso:: updateItemVisibility()
.. seealso:: updateItemSelectStatus()
%End

void updateItemLockStatus( QgsLayoutItem *item );
%Docstring
Must be called when an ``item``'s lock status changes.
.. seealso:: updateItemDisplayName()
.. seealso:: updateItemVisibility()
.. seealso:: updateItemSelectStatus()
%End

void updateItemVisibility( QgsLayoutItem *item );
%Docstring
Must be called when an ``item``'s visibility changes.
.. seealso:: updateItemDisplayName()
.. seealso:: updateItemLockStatus()
.. seealso:: updateItemSelectStatus()
%End

void updateItemSelectStatus( QgsLayoutItem *item );
%Docstring
Must be called when an ``item``'s selection status changes.
.. seealso:: updateItemDisplayName()
.. seealso:: updateItemVisibility()
.. seealso:: updateItemLockStatus()
%End

QModelIndex indexForItem( QgsLayoutItem *item, const int column = 0 );
%Docstring
Expand All @@ -228,10 +81,6 @@ class QgsLayoutModel: QAbstractItemModel

public slots:

void setSelected( const QModelIndex &index );
%Docstring
Sets an item as the current selection from a QModelIndex ``index``.
%End

};

Expand Down
8 changes: 6 additions & 2 deletions src/core/layout/qgslayoutmodel.cpp
Expand Up @@ -424,6 +424,7 @@ bool QgsLayoutModel::removeRows( int row, int count, const QModelIndex &parent )
return true;
}

///@cond PRIVATE
void QgsLayoutModel::clear()
{
//totally reset model
Expand Down Expand Up @@ -459,6 +460,7 @@ void QgsLayoutModel::rebuildZList()
mItemZList = sortedList;
rebuildSceneItemList();
}
///@endcond

void QgsLayoutModel::rebuildSceneItemList()
{
Expand Down Expand Up @@ -498,7 +500,7 @@ void QgsLayoutModel::rebuildSceneItemList()
row++;
}
}

///@cond PRIVATE
void QgsLayoutModel::addItemAtTop( QgsLayoutItem *item )
{
beginInsertRows( QModelIndex(), 0, 0 );
Expand Down Expand Up @@ -888,6 +890,7 @@ QList<QgsLayoutItem *> &QgsLayoutModel::zOrderList()
return mItemZList;
}

///@endcond

Qt::ItemFlags QgsLayoutModel::flags( const QModelIndex &index ) const
{
Expand Down Expand Up @@ -927,6 +930,7 @@ QModelIndex QgsLayoutModel::indexForItem( QgsLayoutItem *item, const int column
return index( row, column );
}

///@cond PRIVATE
void QgsLayoutModel::setSelected( const QModelIndex &index )
{
QgsLayoutItem *item = itemFromIndex( index );
Expand All @@ -937,7 +941,7 @@ void QgsLayoutModel::setSelected( const QModelIndex &index )

mLayout->setSelectedItem( item );
}

///@endcond

//
// QgsLayoutProxyModel
Expand Down
10 changes: 10 additions & 0 deletions src/core/layout/qgslayoutmodel.h
Expand Up @@ -83,6 +83,9 @@ class CORE_EXPORT QgsLayoutModel: public QAbstractItemModel
bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;

///@cond PRIVATE
#ifndef SIP_RUN

/**
* Clears all items from z-order list and resets the model
*/
Expand Down Expand Up @@ -231,6 +234,8 @@ class CORE_EXPORT QgsLayoutModel: public QAbstractItemModel
* \see updateItemLockStatus()
*/
void updateItemSelectStatus( QgsLayoutItem *item );
#endif
///@endcond

/**
* Returns the QModelIndex corresponding to a QgsLayoutItem \a item and \a column, if possible.
Expand All @@ -239,10 +244,15 @@ class CORE_EXPORT QgsLayoutModel: public QAbstractItemModel

public slots:

///@cond PRIVATE
#ifndef SIP_RUN

/**
* Sets an item as the current selection from a QModelIndex \a index.
*/
void setSelected( const QModelIndex &index );
#endif
///@endcond

private:

Expand Down

0 comments on commit fd0cba3

Please sign in to comment.