Skip to content

Commit

Permalink
Fix the "Change Label" map tool after labeling refactoring
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wonder-sk committed Sep 30, 2015
1 parent 1c877f1 commit bc9b715
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -9401,7 +9401,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( it.value() );
if ( !vlayer || !vlayer->isEditable() ||
( !vlayer->diagramsEnabled() && vlayer->customProperty( "labeling" ).toString() != QString( "pal" ) ) )
( !vlayer->diagramsEnabled() && !vlayer->labelsEnabled() ) )
continue;

int colX, colY, colShow, colAng;
Expand Down
7 changes: 6 additions & 1 deletion src/core/qgsmaprenderercustompainterjob.cpp
Expand Up @@ -168,7 +168,12 @@ bool QgsMapRendererCustomPainterJob::isActive() const

QgsLabelingResults* QgsMapRendererCustomPainterJob::takeLabelingResults()
{
return mLabelingEngine ? mLabelingEngine->takeResults() : 0;
if ( mLabelingEngine )
return mLabelingEngine->takeResults();
else if ( mLabelingEngineV2 )
return mLabelingEngineV2->takeResults();
else
return 0;
}


Expand Down
7 changes: 6 additions & 1 deletion src/core/qgsmaprendererparalleljob.cpp
Expand Up @@ -163,7 +163,12 @@ bool QgsMapRendererParallelJob::isActive() const

QgsLabelingResults* QgsMapRendererParallelJob::takeLabelingResults()
{
return mLabelingEngine ? mLabelingEngine->takeResults() : 0;
if ( mLabelingEngine )
return mLabelingEngine->takeResults();
else if ( mLabelingEngineV2 )
return mLabelingEngineV2->takeResults();
else
return 0;
}

QImage QgsMapRendererParallelJob::renderedImage()
Expand Down
11 changes: 10 additions & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -668,7 +668,16 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected()

bool QgsVectorLayer::labelsEnabled() const
{
return customProperty( "labeling/enabled", QVariant( false ) ).toBool();
if ( !mLabeling )
return false;

// for simple labeling the mode can be "no labels" - so we need to check
// in properties whether we are really enabled or not
if ( mLabeling->type() == "simple" )
return customProperty( "labeling/enabled", QVariant( false ) ).toBool();

// for other labeling implementations we always assume that labeling is enabled
return true;
}

bool QgsVectorLayer::diagramsEnabled() const
Expand Down

0 comments on commit bc9b715

Please sign in to comment.