Skip to content
Permalink
Browse files

Refresh map list in composer table widget in showEvent. Ticket #4496

  • Loading branch information
marco
marco committed Nov 5, 2011
1 parent eb48501 commit 8a98069194136c7fd5459971e89935fc2317b9c6
Showing with 42 additions and 14 deletions.
  1. +38 −14 src/app/composer/qgscomposertablewidget.cpp
  2. +4 −0 src/app/composer/qgscomposertablewidget.h
@@ -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();
@@ -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 )
@@ -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 );

0 comments on commit 8a98069

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