Skip to content

Commit

Permalink
Refresh map list in composer table widget in showEvent. Ticket #4496
Browse files Browse the repository at this point in the history
  • Loading branch information
marco committed Nov 5, 2011
1 parent eb48501 commit 8a98069
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
52 changes: 38 additions & 14 deletions src/app/composer/qgscomposertablewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,35 @@ QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table
}
}

//insert composer maps into combo
mLayerComboBox->blockSignals( true );
refreshMapComboBox();

updateGuiElements();
on_mComposerMapComboBox_activated( mComposerMapComboBox->currentIndex() );

if ( mComposerTable )
{
QObject::connect( mComposerTable, SIGNAL( maximumNumerOfFeaturesChanged( int ) ), this, SLOT( setMaximumNumberOfFeatures( int ) ) );
QObject::connect( mComposerTable, SIGNAL( itemChanged ), this, SLOT( updateGuiElements() ) );
}
}

QgsComposerTableWidget::~QgsComposerTableWidget()
{

}

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

void QgsComposerTableWidget::refreshMapComboBox()
{
//save the current entry in case it is still present after refresh
QString saveCurrentComboText = mComposerMapComboBox->currentText();

mComposerMapComboBox->blockSignals( true );
mComposerMapComboBox->clear();
if ( mComposerTable )
{
const QgsComposition* tableComposition = mComposerTable->composition();
Expand All @@ -63,21 +90,18 @@ QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table
}
}
}
mLayerComboBox->blockSignals( false );
mComposerMapComboBox->blockSignals( false );

updateGuiElements();
on_mComposerMapComboBox_activated( mComposerMapComboBox->currentIndex() );

if ( mComposerTable )
if ( mComposerMapComboBox->findText( saveCurrentComboText ) == -1 )
{
QObject::connect( mComposerTable, SIGNAL( maximumNumerOfFeaturesChanged( int ) ), this, SLOT( setMaximumNumberOfFeatures( int ) ) );
QObject::connect( mComposerTable, SIGNAL( itemChanged ), this, SLOT( updateGuiElements() ) );
//the former entry is no longer present. Inform the scalebar about the changed composer map
on_mComposerMapComboBox_activated( mComposerMapComboBox->currentIndex() );
}
else
{
//the former entry is still present. Make it the current entry again
mComposerMapComboBox->setCurrentIndex( mComposerMapComboBox->findText( saveCurrentComboText ) );
}
}

QgsComposerTableWidget::~QgsComposerTableWidget()
{

}

void QgsComposerTableWidget::on_mLayerComboBox_currentIndexChanged( int index )
Expand Down
4 changes: 4 additions & 0 deletions src/app/composer/qgscomposertablewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ class QgsComposerTableWidget: public QWidget, private Ui::QgsComposerTableWidget
QgsComposerTableWidget( QgsComposerAttributeTable* table );
~QgsComposerTableWidget();

protected:
void showEvent( QShowEvent * event );

private:
QgsComposerAttributeTable* mComposerTable;

/**Blocks / unblocks the signals of all GUI elements*/
void blockAllSignals( bool b );
void refreshMapComboBox();

private slots:
void on_mLayerComboBox_currentIndexChanged( int index );
Expand Down

0 comments on commit 8a98069

Please sign in to comment.