Skip to content
Permalink
Browse files

Update overview map list

  • Loading branch information
mhugent committed Jul 16, 2012
1 parent beb70d3 commit 9c478c87ff093490d65fa6264e5a885e80bbc4bb
Showing with 60 additions and 19 deletions.
  1. +54 −19 src/app/composer/qgscomposermapwidget.cpp
  2. +6 −0 src/app/composer/qgscomposermapwidget.h
@@ -69,25 +69,6 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap ): QWidg
connect( composerMap, SIGNAL( itemChanged() ), this, SLOT( setGuiElementValues() ) );
}

if ( mComposerMap )
{
//insert available maps into mMapComboBox
mOverviewFrameMapComboBox->addItem( tr( "None" ), -1 );
const QgsComposition* composition = mComposerMap->composition();
if ( composition )
{
QList<const QgsComposerMap*> availableMaps = composition->composerMapItems();
QList<const QgsComposerMap*>::const_iterator mapItemIt = availableMaps.constBegin();
for ( ; mapItemIt != availableMaps.constEnd(); ++mapItemIt )
{
if (( *mapItemIt )->id() != mComposerMap->id() )
{
mOverviewFrameMapComboBox->addItem( tr( "Map %1" ).arg(( *mapItemIt )->id() ), ( *mapItemIt )->id() );
}
}
}
}

updateOverviewSymbolMarker();

updateGuiElements();
@@ -893,6 +874,12 @@ void QgsComposerMapWidget::on_mFrameWidthSpinBox_valueChanged( double d )
}
}

void QgsComposerMapWidget::showEvent( QShowEvent * event )
{
refreshMapComboBox();
QWidget::showEvent( event );
}

void QgsComposerMapWidget::insertAnnotationPositionEntries( QComboBox* c )
{
c->insertItem( 0, tr( "Inside frame" ) );
@@ -999,3 +986,51 @@ void QgsComposerMapWidget::updateOverviewSymbolMarker()
mOverviewFrameStyleButton->setIcon( icon );
}
}

void QgsComposerMapWidget::refreshMapComboBox()
{
if ( !mComposerMap )
{
return;
}

mOverviewFrameMapComboBox->blockSignals( true );

//save the current entry in case it is still present after refresh
QString saveComboText = mOverviewFrameMapComboBox->currentText();

mOverviewFrameMapComboBox->clear();
mOverviewFrameMapComboBox->addItem( tr( "None" ), -1 );
const QgsComposition* composition = mComposerMap->composition();
if ( !composition )
{
return;
}

QList<const QgsComposerMap*> availableMaps = composition->composerMapItems();
QList<const QgsComposerMap*>::const_iterator mapItemIt = availableMaps.constBegin();
for ( ; mapItemIt != availableMaps.constEnd(); ++mapItemIt )
{
if (( *mapItemIt )->id() != mComposerMap->id() )
{
mOverviewFrameMapComboBox->addItem( tr( "Map %1" ).arg(( *mapItemIt )->id() ), ( *mapItemIt )->id() );
}
}


if ( !saveComboText.isEmpty() )
{
int saveTextIndex = mOverviewFrameMapComboBox->findText( saveComboText );
if ( saveTextIndex == -1 )
{
//entry is no longer present
mOverviewFrameMapComboBox->setCurrentIndex( mOverviewFrameMapComboBox->findText( tr( "None" ) ) );
}
else
{
mOverviewFrameMapComboBox->setCurrentIndex( saveTextIndex );
}
}

mOverviewFrameMapComboBox->blockSignals( false );
}
@@ -81,6 +81,9 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
void on_mFrameStyleComboBox_currentIndexChanged( const QString& text );
void on_mFrameWidthSpinBox_valueChanged( double d );

protected:
void showEvent( QShowEvent * event );

private slots:

/**Sets the GUI elements to the values of mPicture*/
@@ -108,6 +111,9 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
void initAnnotationDirectionBox( QComboBox* c, QgsComposerMap::GridAnnotationDirection dir );

void updateOverviewSymbolMarker();

/**Updates the map combo box with the current composer map ids*/
void refreshMapComboBox();
};

#endif

0 comments on commit 9c478c8

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