Skip to content
Permalink
Browse files

[composer] Show status bar text with current atlas feature

  • Loading branch information
nyalldawson committed Jan 1, 2014
1 parent 61ad9e9 commit 3362579175676e1e38e14b66489f00fb9deaec37
@@ -365,12 +365,15 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
mStatusCursorPageLabel = new QLabel( mStatusBar );
mStatusCursorPageLabel->setMinimumWidth( 100 );
mStatusCompositionLabel = new QLabel( mStatusBar );
mStatusCompositionLabel->setMinimumWidth( 350 );
mStatusAtlasLabel = new QLabel( mStatusBar );

mStatusBar->addWidget( mStatusCursorXLabel );
mStatusBar->addWidget( mStatusCursorYLabel );
mStatusBar->addWidget( mStatusCursorPageLabel );
mStatusBar->addWidget( mStatusZoomCombo );
mStatusBar->addWidget( mStatusCompositionLabel );
mStatusBar->addWidget( mStatusAtlasLabel );

//create composer view and layout with rulers
mView = 0;
@@ -604,6 +607,9 @@ void QgsComposer::connectSlots()
connect( mView, SIGNAL( zoomLevelChanged() ), this, SLOT( updateStatusZoom() ) );
//listen out to status bar updates from the composition
connect( mComposition, SIGNAL( statusMsgChanged( QString ) ), this, SLOT( updateStatusCompositionMsg( QString ) ) );
//listen out to status bar updates from the atlas
QgsAtlasComposition* atlasMap = &mComposition->atlasComposition();
connect( atlasMap, SIGNAL( statusMsgChanged( QString ) ), this, SLOT( updateStatusAtlasMsg( QString ) ) );
}

void QgsComposer::open( void )
@@ -733,6 +739,11 @@ void QgsComposer::updateStatusCompositionMsg( QString message )
mStatusCompositionLabel->setText( message );
}

void QgsComposer::updateStatusAtlasMsg( QString message )
{
mStatusAtlasLabel->setText( message );
}

void QgsComposer::showItemOptions( QgsComposerItem* item )
{
QWidget* currentWidget = mItemDock->widget();
@@ -786,6 +797,7 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
mActionAtlasPreview->blockSignals( true );
mActionAtlasPreview->setChecked( false );
mActionAtlasPreview->blockSignals( false );
mStatusAtlasLabel->setText( QString() );
return;
}

@@ -800,6 +812,10 @@ void QgsComposer::on_mActionAtlasPreview_triggered( bool checked )
{
atlasMap->firstFeature();
}
else
{
mStatusAtlasLabel->setText( QString() );
}

}

@@ -396,6 +396,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! Updates status bar composition message
void updateStatusCompositionMsg( QString message );

//! Updates status bar atlas message
void updateStatusAtlasMsg( QString message );

private:

/**Establishes the signal slot connection for the class*/
@@ -447,6 +450,8 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
QList<double> mStatusZoomLevelsList;
/**Label in status bar which shows messages from the composition*/
QLabel* mStatusCompositionLabel;
/**Label in status bar which shows atlas details*/
QLabel* mStatusAtlasLabel;

//! Pointer to composer view
QgsComposerView *mView;
@@ -181,7 +181,7 @@ void QgsAtlasComposition::updateFeatures()
}

QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mFeatureIds.size() ) );

//jump to first feature if currently using an atlas preview
//need to do this in case filtering/layer change has altered matching features
if ( mComposition->atlasPreviewEnabled() )
@@ -290,6 +290,12 @@ void QgsAtlasComposition::prepareForFeature( int featureI )
return;
}

if ( mFeatureIds.size() == 0 )
{
emit statusMsgChanged( tr( "No matching atlas features" ) );
return;
}

// retrieve the next feature, based on its id
mCoverageLayer->getFeatures( QgsFeatureRequest().setFilterFid( mFeatureIds[ featureI ] ) ).nextFeature( mCurrentFeature );

@@ -384,6 +390,8 @@ void QgsAtlasComposition::prepareForFeature( int featureI )

// set the new extent (and render)
mComposerMap->setNewAtlasFeatureExtent( new_extent );

emit statusMsgChanged( QString( tr( "Atlas feature %1 of %2" ) ).arg( featureI + 1 ).arg( mFeatureIds.size() ) );
}

const QString& QgsAtlasComposition::currentFilename() const
@@ -114,6 +114,9 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
/** emitted when atlas is enabled or disabled */
void toggled( bool );

/**Is emitted when the atlas has an updated status bar message for the composer window*/
void statusMsgChanged( QString message );

private:
QgsComposition* mComposition;

0 comments on commit 3362579

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