@@ -47,8 +47,35 @@ QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table
47
47
}
48
48
}
49
49
50
- // insert composer maps into combo
51
- mLayerComboBox ->blockSignals ( true );
50
+ refreshMapComboBox ();
51
+
52
+ updateGuiElements ();
53
+ on_mComposerMapComboBox_activated ( mComposerMapComboBox ->currentIndex () );
54
+
55
+ if ( mComposerTable )
56
+ {
57
+ QObject::connect ( mComposerTable , SIGNAL ( maximumNumerOfFeaturesChanged ( int ) ), this , SLOT ( setMaximumNumberOfFeatures ( int ) ) );
58
+ QObject::connect ( mComposerTable , SIGNAL ( itemChanged ), this , SLOT ( updateGuiElements () ) );
59
+ }
60
+ }
61
+
62
+ QgsComposerTableWidget::~QgsComposerTableWidget ()
63
+ {
64
+
65
+ }
66
+
67
+ void QgsComposerTableWidget::showEvent ( QShowEvent* event )
68
+ {
69
+ refreshMapComboBox ();
70
+ }
71
+
72
+ void QgsComposerTableWidget::refreshMapComboBox ()
73
+ {
74
+ // save the current entry in case it is still present after refresh
75
+ QString saveCurrentComboText = mComposerMapComboBox ->currentText ();
76
+
77
+ mComposerMapComboBox ->blockSignals ( true );
78
+ mComposerMapComboBox ->clear ();
52
79
if ( mComposerTable )
53
80
{
54
81
const QgsComposition* tableComposition = mComposerTable ->composition ();
@@ -63,21 +90,18 @@ QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table
63
90
}
64
91
}
65
92
}
66
- mLayerComboBox ->blockSignals ( false );
93
+ mComposerMapComboBox ->blockSignals ( false );
67
94
68
- updateGuiElements ();
69
- on_mComposerMapComboBox_activated ( mComposerMapComboBox ->currentIndex () );
70
-
71
- if ( mComposerTable )
95
+ if ( mComposerMapComboBox ->findText ( saveCurrentComboText ) == -1 )
72
96
{
73
- QObject::connect ( mComposerTable , SIGNAL ( maximumNumerOfFeaturesChanged ( int ) ), this , SLOT ( setMaximumNumberOfFeatures ( int ) ) );
74
- QObject::connect ( mComposerTable , SIGNAL ( itemChanged ), this , SLOT ( updateGuiElements () ) );
97
+ // the former entry is no longer present. Inform the scalebar about the changed composer map
98
+ on_mComposerMapComboBox_activated ( mComposerMapComboBox ->currentIndex () );
99
+ }
100
+ else
101
+ {
102
+ // the former entry is still present. Make it the current entry again
103
+ mComposerMapComboBox ->setCurrentIndex ( mComposerMapComboBox ->findText ( saveCurrentComboText ) );
75
104
}
76
- }
77
-
78
- QgsComposerTableWidget::~QgsComposerTableWidget ()
79
- {
80
-
81
105
}
82
106
83
107
void QgsComposerTableWidget::on_mLayerComboBox_currentIndexChanged ( int index )
0 commit comments