Skip to content
Permalink
Browse files

[composer] Add a basic test suite for QgsComposerModel

  • Loading branch information
nyalldawson committed Sep 29, 2014
1 parent 6fb7ba2 commit 1c03067504c0444fcf0344facee3a4bcd16b5962
@@ -61,10 +61,12 @@ QgsComposerLabel::QgsComposerLabel( QgsComposition *composition ):
setExpressionContext( mComposition->atlasComposition().currentFeature(), mComposition->atlasComposition().coverageLayer() );
}

//connect to atlas feature changes
//to update the expression context
connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshExpressionContext() ) );

if ( mComposition )
{
//connect to atlas feature changes
//to update the expression context
connect( &mComposition->atlasComposition(), SIGNAL( featureChanged( QgsFeature* ) ), this, SLOT( refreshExpressionContext() ) );
}
}

QgsComposerLabel::~QgsComposerLabel()
@@ -693,6 +693,11 @@ void QgsComposerModel::updateItemSelectStatus( QgsComposerItem *item )

bool QgsComposerModel::reorderItemUp( QgsComposerItem *item )
{
if ( !item )
{
return false;
}

if ( mItemsInScene.first() == item )
{
//item is already topmost item present in scene, nothing to do
@@ -738,6 +743,11 @@ bool QgsComposerModel::reorderItemUp( QgsComposerItem *item )

bool QgsComposerModel::reorderItemDown( QgsComposerItem *item )
{
if ( !item )
{
return false;
}

if ( mItemsInScene.last() == item )
{
//item is already lowest item present in scene, nothing to do
@@ -783,6 +793,11 @@ bool QgsComposerModel::reorderItemDown( QgsComposerItem *item )

bool QgsComposerModel::reorderItemToTop( QgsComposerItem *item )
{
if ( !item || !mItemsInScene.contains( item ) )
{
return false;
}

if ( mItemsInScene.first() == item )
{
//item is already topmost item present in scene, nothing to do
@@ -814,6 +829,11 @@ bool QgsComposerModel::reorderItemToTop( QgsComposerItem *item )

bool QgsComposerModel::reorderItemToBottom( QgsComposerItem *item )
{
if ( !item || !mItemsInScene.contains( item ) )
{
return false;
}

if ( mItemsInScene.last() == item )
{
//item is already lowest item present in scene, nothing to do
@@ -237,6 +237,14 @@ class CORE_EXPORT QgsComposerModel: public QAbstractItemModel
*/
void setSelected( const QModelIndex &index );

protected:

/**Maintains z-Order of items. Starts with item at position 1 (position 0 is always paper item)*/
QList<QgsComposerItem*> mItemZList;

/**Cached list of items from mItemZList which are currently in the scene*/
QList<QgsComposerItem*> mItemsInScene;

private:

enum Columns
@@ -249,12 +257,6 @@ class CORE_EXPORT QgsComposerModel: public QAbstractItemModel
/**Parent composition*/
QgsComposition* mComposition;

/**Maintains z-Order of items. Starts with item at position 1 (position 0 is always paper item)*/
QList<QgsComposerItem*> mItemZList;

/**Cached list of items from mItemZList which are currently in the scene*/
QList<QgsComposerItem*> mItemsInScene;

/**Returns the QgsComposerItem corresponding to a QModelIndex, if possible
* @param index QModelIndex for item
* @returns item corresponding to index
@@ -283,6 +285,8 @@ class CORE_EXPORT QgsComposerModel: public QAbstractItemModel
* @see refreshItemsInScene
*/
void rebuildSceneItemList();

friend class TestQgsComposerModel;
};

#endif //QGSCOMPOSERMODEL
@@ -108,6 +108,7 @@ ADD_QGIS_TEST(dataitemtest testqgsdataitem.cpp)
ADD_QGIS_TEST(composerobject testqgscomposerobject.cpp)
ADD_QGIS_TEST(composerutils testqgscomposerutils.cpp)
ADD_QGIS_TEST(compositiontest testqgscomposition.cpp)
ADD_QGIS_TEST(composermodel testqgscomposermodel.cpp)
ADD_QGIS_TEST(composermultiframetest testqgscomposermultiframe.cpp)
ADD_QGIS_TEST(composerpapertest testqgscomposerpaper.cpp)
ADD_QGIS_TEST(composermaptest testqgscomposermap.cpp)

0 comments on commit 1c03067

Please sign in to comment.
You can’t perform that action at this time.