Skip to content

Commit bc9b715

Browse files
committed
Fix the "Change Label" map tool after labeling refactoring
The support for rule-based labeling is not there yet (only simple labeling) This code has been funded by Tuscany Region (Italy) - SITA (CIG: 63526840AE) and commissioned to Gis3W s.a.s.
1 parent 1c877f1 commit bc9b715

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

src/app/qgisapp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9401,7 +9401,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
94019401
{
94029402
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( it.value() );
94039403
if ( !vlayer || !vlayer->isEditable() ||
9404-
( !vlayer->diagramsEnabled() && vlayer->customProperty( "labeling" ).toString() != QString( "pal" ) ) )
9404+
( !vlayer->diagramsEnabled() && !vlayer->labelsEnabled() ) )
94059405
continue;
94069406

94079407
int colX, colY, colShow, colAng;

src/core/qgsmaprenderercustompainterjob.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,12 @@ bool QgsMapRendererCustomPainterJob::isActive() const
168168

169169
QgsLabelingResults* QgsMapRendererCustomPainterJob::takeLabelingResults()
170170
{
171-
return mLabelingEngine ? mLabelingEngine->takeResults() : 0;
171+
if ( mLabelingEngine )
172+
return mLabelingEngine->takeResults();
173+
else if ( mLabelingEngineV2 )
174+
return mLabelingEngineV2->takeResults();
175+
else
176+
return 0;
172177
}
173178

174179

src/core/qgsmaprendererparalleljob.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@ bool QgsMapRendererParallelJob::isActive() const
163163

164164
QgsLabelingResults* QgsMapRendererParallelJob::takeLabelingResults()
165165
{
166-
return mLabelingEngine ? mLabelingEngine->takeResults() : 0;
166+
if ( mLabelingEngine )
167+
return mLabelingEngine->takeResults();
168+
else if ( mLabelingEngineV2 )
169+
return mLabelingEngineV2->takeResults();
170+
else
171+
return 0;
167172
}
168173

169174
QImage QgsMapRendererParallelJob::renderedImage()

src/core/qgsvectorlayer.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,16 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected()
668668

669669
bool QgsVectorLayer::labelsEnabled() const
670670
{
671-
return customProperty( "labeling/enabled", QVariant( false ) ).toBool();
671+
if ( !mLabeling )
672+
return false;
673+
674+
// for simple labeling the mode can be "no labels" - so we need to check
675+
// in properties whether we are really enabled or not
676+
if ( mLabeling->type() == "simple" )
677+
return customProperty( "labeling/enabled", QVariant( false ) ).toBool();
678+
679+
// for other labeling implementations we always assume that labeling is enabled
680+
return true;
672681
}
673682

674683
bool QgsVectorLayer::diagramsEnabled() const

0 commit comments

Comments
 (0)