Skip to content

Commit e9f4bbc

Browse files
committedSep 17, 2014
[composer] Fix update of gui controls when table and HTML properties
change (sponsored by City of Uster, Switzerland)
1 parent 2d24b32 commit e9f4bbc

7 files changed

+40
-9
lines changed
 

‎src/app/composer/qgscomposerattributetablewidget.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAtt
6060

6161
if ( mComposerTable )
6262
{
63-
QObject::connect( mComposerTable, SIGNAL( maximumNumberOfFeaturesChanged( int ) ), this, SLOT( setMaximumNumberOfFeatures( int ) ) );
64-
QObject::connect( mComposerTable, SIGNAL( itemChanged() ), this, SLOT( updateGuiElements() ) );
63+
QObject::connect( mComposerTable, SIGNAL( changed() ), this, SLOT( updateGuiElements() ) );
6564
}
6665
}
6766

‎src/app/composer/qgscomposertablewidget.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ QgsComposerTableWidget::QgsComposerTableWidget( QgsComposerAttributeTable* table
5555

5656
if ( mComposerTable )
5757
{
58-
QObject::connect( mComposerTable, SIGNAL( maximumNumberOfFeaturesChanged( int ) ), this, SLOT( setMaximumNumberOfFeatures( int ) ) );
5958
QObject::connect( mComposerTable, SIGNAL( itemChanged() ), this, SLOT( updateGuiElements() ) );
6059
}
6160
}

‎src/core/composer/qgscomposerattributetable.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,6 @@ class CORE_EXPORT QgsComposerAttributeTable: public QgsComposerTable
281281
/**Checks if this vector layer will be removed (and sets mVectorLayer to 0 if yes) */
282282
void removeLayer( QString layerId );
283283

284-
signals:
285-
/**This signal is emitted if the maximum number of feature changes (interactively)*/
286-
void maximumNumberOfFeaturesChanged( int n );
287284
};
288285

289286
#endif // QGSCOMPOSERATTRIBUTETABLE_H

‎src/core/composer/qgscomposerattributetablev2.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ void QgsComposerAttributeTableV2::setVectorLayer( QgsVectorLayer* layer )
157157

158158
//listen for modifications to layer and refresh table when they occur
159159
QObject::connect( mVectorLayer, SIGNAL( layerModified() ), this, SLOT( refreshAttributes() ) );
160+
161+
emit changed();
160162
}
161163

162164
void QgsComposerAttributeTableV2::resetColumns()
@@ -202,6 +204,7 @@ void QgsComposerAttributeTableV2::setComposerMap( const QgsComposerMap* map )
202204
QObject::connect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( refreshAttributes() ) );
203205
}
204206
refreshAttributes();
207+
emit changed();
205208
}
206209

207210
void QgsComposerAttributeTableV2::setMaximumNumberOfFeatures( int features )
@@ -213,6 +216,7 @@ void QgsComposerAttributeTableV2::setMaximumNumberOfFeatures( int features )
213216

214217
mMaximumNumberOfFeatures = features;
215218
refreshAttributes();
219+
emit changed();
216220
}
217221

218222
void QgsComposerAttributeTableV2::setDisplayOnlyVisibleFeatures( bool visibleOnly )
@@ -224,6 +228,7 @@ void QgsComposerAttributeTableV2::setDisplayOnlyVisibleFeatures( bool visibleOnl
224228

225229
mShowOnlyVisibleFeatures = visibleOnly;
226230
refreshAttributes();
231+
emit changed();
227232
}
228233

229234
void QgsComposerAttributeTableV2::setFilterFeatures( bool filter )
@@ -235,6 +240,7 @@ void QgsComposerAttributeTableV2::setFilterFeatures( bool filter )
235240

236241
mFilterFeatures = filter;
237242
refreshAttributes();
243+
emit changed();
238244
}
239245

240246
void QgsComposerAttributeTableV2::setFeatureFilter( const QString& expression )
@@ -246,6 +252,7 @@ void QgsComposerAttributeTableV2::setFeatureFilter( const QString& expression )
246252

247253
mFeatureFilter = expression;
248254
refreshAttributes();
255+
emit changed();
249256
}
250257

251258
void QgsComposerAttributeTableV2::setDisplayAttributes( const QSet<int>& attr, bool refresh )

‎src/core/composer/qgscomposerattributetablev2.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,6 @@ class CORE_EXPORT QgsComposerAttributeTableV2: public QgsComposerTableV2
228228
/**Checks if this vector layer will be removed (and sets mVectorLayer to 0 if yes) */
229229
void removeLayer( QString layerId );
230230

231-
signals:
232-
/**This signal is emitted if the maximum number of feature changes (interactively)*/
233-
void maximumNumberOfFeaturesChanged( int n );
234231
};
235232

236233
#endif // QGSCOMPOSERATTRIBUTETABLEV2_H

‎src/core/composer/qgscomposerhtml.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,23 @@ void QgsComposerHtml::setUrl( const QUrl& url )
9696

9797
mUrl = url;
9898
loadHtml();
99+
emit changed();
99100
}
100101

101102
void QgsComposerHtml::setHtml( const QString html )
102103
{
103104
mHtml = html;
105+
//TODO - this signal should be emitted, but without changing the signal which sets the html
106+
//to an equivalent of editingFinished it causes a lot of problems. Need to investigate
107+
//ways of doing this using QScintilla widgets.
108+
//emit changed();
104109
}
105110

106111
void QgsComposerHtml::setEvaluateExpressions( bool evaluateExpressions )
107112
{
108113
mEvaluateExpressions = evaluateExpressions;
109114
loadHtml();
115+
emit changed();
110116
}
111117

112118
void QgsComposerHtml::loadHtml()
@@ -400,6 +406,10 @@ void QgsComposerHtml::setMaxBreakDistance( double maxBreakDistance )
400406
void QgsComposerHtml::setUserStylesheet( const QString stylesheet )
401407
{
402408
mUserStylesheet = stylesheet;
409+
//TODO - this signal should be emitted, but without changing the signal which sets the css
410+
//to an equivalent of editingFinished it causes a lot of problems. Need to investigate
411+
//ways of doing this using QScintilla widgets.
412+
//emit changed();
403413
}
404414

405415
void QgsComposerHtml::setUserStylesheetEnabled( const bool stylesheetEnabled )
@@ -408,6 +418,7 @@ void QgsComposerHtml::setUserStylesheetEnabled( const bool stylesheetEnabled )
408418
{
409419
mEnableUserStylesheet = stylesheetEnabled;
410420
loadHtml();
421+
emit changed();
411422
}
412423
}
413424

‎src/core/composer/qgscomposertablev2.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ bool QgsComposerTableV2::writeXML( QDomElement& elem, QDomDocument & doc, bool i
6161
elem.setAttribute( "headerFont", mHeaderFont.toString() );
6262
elem.setAttribute( "headerFontColor", QgsSymbolLayerV2Utils::encodeColor( mHeaderFontColor ) );
6363
elem.setAttribute( "headerHAlignment", QString::number(( int )mHeaderHAlignment ) );
64+
elem.setAttribute( "headerMode", QString::number(( int )mHeaderMode ) );
6465
elem.setAttribute( "contentFont", mContentFont.toString() );
6566
elem.setAttribute( "contentFontColor", QgsSymbolLayerV2Utils::encodeColor( mContentFontColor ) );
6667
elem.setAttribute( "gridStrokeWidth", QString::number( mGridStrokeWidth ) );
@@ -288,8 +289,11 @@ void QgsComposerTableV2::setCellMargin( const double margin )
288289
}
289290

290291
mCellMargin = margin;
292+
291293
//since spacing has changed, we need to recalculate the table size
292294
adjustFrameToSize();
295+
296+
emit changed();
293297
}
294298

295299
void QgsComposerTableV2::setHeaderFont( const QFont &font )
@@ -302,6 +306,8 @@ void QgsComposerTableV2::setHeaderFont( const QFont &font )
302306
mHeaderFont = font;
303307
//since font attributes have changed, we need to recalculate the table size
304308
adjustFrameToSize();
309+
310+
emit changed();
305311
}
306312

307313
void QgsComposerTableV2::setHeaderFontColor( const QColor &color )
@@ -313,6 +319,8 @@ void QgsComposerTableV2::setHeaderFontColor( const QColor &color )
313319

314320
mHeaderFontColor = color;
315321
repaint();
322+
323+
emit changed();
316324
}
317325

318326
void QgsComposerTableV2::setHeaderHAlignment( const QgsComposerTableV2::HeaderHAlignment alignment )
@@ -324,6 +332,8 @@ void QgsComposerTableV2::setHeaderHAlignment( const QgsComposerTableV2::HeaderHA
324332

325333
mHeaderHAlignment = alignment;
326334
repaint();
335+
336+
emit changed();
327337
}
328338

329339
void QgsComposerTableV2::setHeaderMode( const QgsComposerTableV2::HeaderMode mode )
@@ -336,6 +346,7 @@ void QgsComposerTableV2::setHeaderMode( const QgsComposerTableV2::HeaderMode mod
336346
mHeaderMode = mode;
337347
adjustFrameToSize();
338348

349+
emit changed();
339350
}
340351

341352
void QgsComposerTableV2::setContentFont( const QFont &font )
@@ -348,6 +359,8 @@ void QgsComposerTableV2::setContentFont( const QFont &font )
348359
mContentFont = font;
349360
//since font attributes have changed, we need to recalculate the table size
350361
adjustFrameToSize();
362+
363+
emit changed();
351364
}
352365

353366
void QgsComposerTableV2::setContentFontColor( const QColor &color )
@@ -359,6 +372,8 @@ void QgsComposerTableV2::setContentFontColor( const QColor &color )
359372

360373
mContentFontColor = color;
361374
repaint();
375+
376+
emit changed();
362377
}
363378

364379
void QgsComposerTableV2::setShowGrid( const bool showGrid )
@@ -371,6 +386,8 @@ void QgsComposerTableV2::setShowGrid( const bool showGrid )
371386
mShowGrid = showGrid;
372387
//since grid spacing has changed, we need to recalculate the table size
373388
adjustFrameToSize();
389+
390+
emit changed();
374391
}
375392

376393
void QgsComposerTableV2::setGridStrokeWidth( const double width )
@@ -383,6 +400,8 @@ void QgsComposerTableV2::setGridStrokeWidth( const double width )
383400
mGridStrokeWidth = width;
384401
//since grid spacing has changed, we need to recalculate the table size
385402
adjustFrameToSize();
403+
404+
emit changed();
386405
}
387406

388407
void QgsComposerTableV2::setGridColor( const QColor &color )
@@ -394,6 +413,8 @@ void QgsComposerTableV2::setGridColor( const QColor &color )
394413

395414
mGridColor = color;
396415
repaint();
416+
417+
emit changed();
397418
}
398419

399420
void QgsComposerTableV2::setColumns( QgsComposerTableColumns columns )

0 commit comments

Comments
 (0)
Please sign in to comment.