@@ -258,7 +258,6 @@ void QgsMapToolPinLabels::pinUnpinLabels( const QgsRectangle& ext, QMouseEvent *
258258
259259 bool doUnpin = e->modifiers () & Qt::ShiftModifier ? true : false ;
260260 bool toggleUnpinOrPin = e->modifiers () & Qt::ControlModifier ? true : false ;
261- bool doHide = ( doUnpin && toggleUnpinOrPin );
262261
263262 // get list of all drawn labels from all layers within, or touching, chosen extent
264263 bool labelChanged = false ;
@@ -315,7 +314,7 @@ void QgsMapToolPinLabels::pinUnpinLabels( const QgsRectangle& ext, QMouseEvent *
315314 QString labelStringID = QString ( " %0|%1" ).arg ( mCurrentLabelPos .layerID , QString::number ( mCurrentLabelPos .featureId ) );
316315
317316 // unpin label
318- if ( mCurrentLabelPos .isPinned && !doHide && ( doUnpin || toggleUnpinOrPin ) )
317+ if ( mCurrentLabelPos .isPinned && ( doUnpin || toggleUnpinOrPin ) )
319318 {
320319 // unpin previously pinned label (set attribute table fields to NULL)
321320 if ( pinUnpinLabel ( vlayer, mCurrentLabelPos , false ) )
@@ -329,7 +328,7 @@ void QgsMapToolPinLabels::pinUnpinLabels( const QgsRectangle& ext, QMouseEvent *
329328 }
330329
331330 // pin label
332- if ( !mCurrentLabelPos .isPinned && !doHide && ( !doUnpin || toggleUnpinOrPin ) )
331+ if ( !mCurrentLabelPos .isPinned && ( !doUnpin || toggleUnpinOrPin ) )
333332 {
334333 // pin label's location, and optionally rotation, to attribute table
335334 if ( pinUnpinLabel ( vlayer, mCurrentLabelPos , true ) )
@@ -341,20 +340,6 @@ void QgsMapToolPinLabels::pinUnpinLabels( const QgsRectangle& ext, QMouseEvent *
341340 QgsDebugMsg ( QString ( " Pin failed for layer, label: %0, %1" ).arg ( labellyr, labeltxt ) );
342341 }
343342 }
344-
345- // hide label
346- if ( doHide )
347- {
348- // write 0 font size to attribute table
349- if ( hideLabel ( vlayer, mCurrentLabelPos ) )
350- {
351- labelChanged = true ;
352- }
353- else
354- {
355- QgsDebugMsg ( QString ( " Hide failed for layer, label: %0, %1" ).arg ( labellyr, labeltxt ) );
356- }
357- }
358343 }
359344
360345 if ( labelChanged )
@@ -477,42 +462,3 @@ bool QgsMapToolPinLabels::pinUnpinLabel( QgsVectorLayer* vlayer,
477462 }
478463 return true ;
479464}
480-
481- bool QgsMapToolPinLabels::hideLabel ( QgsVectorLayer* vlayer,
482- const QgsLabelPosition& labelpos )
483- {
484- // skip diagrams
485- if ( labelpos.isDiagram )
486- {
487- QgsDebugMsg ( QString ( " Label is diagram, skipping" ) );
488- return false ;
489- }
490- // verify attribute table has proper fields setup
491- bool sizeColOk;
492- int sizeCol;
493-
494- QVariant sizeColumn = vlayer->customProperty ( " labeling/dataDefinedProperty0" );
495- if ( !sizeColumn.isValid () )
496- {
497- QgsDebugMsg ( QString ( " Size column not set" ) );
498- return false ;
499- }
500- sizeCol = sizeColumn.toInt ( &sizeColOk );
501- if ( !sizeColOk )
502- {
503- QgsDebugMsg ( QString ( " Size column not convertible to integer" ) );
504- return false ;
505- }
506-
507- // edit attribute table
508- int fid = labelpos.featureId ;
509-
510- vlayer->beginEditCommand ( tr ( " Label hidden" ) );
511- if ( !vlayer->changeAttributeValue ( fid, sizeCol, 0 , false ) )
512- {
513- QgsDebugMsg ( QString ( " Failed write to attribute table" ) );
514- return false ;
515- }
516- vlayer->endEditCommand ();
517- return true ;
518- }
0 commit comments