Skip to content

Commit ad6c964

Browse files
committed
Remove hide label function from pin/unpin label tool
- More informative tool tips for labeling tools
1 parent 3dd05e6 commit ad6c964

File tree

3 files changed

+16
-62
lines changed

3 files changed

+16
-62
lines changed

src/app/qgsmaptoolpinlabels.cpp

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
}

src/app/qgsmaptoolpinlabels.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ class QgsMapToolPinLabels: public QgsMapToolLabel
9595
bool pinUnpinLabel( QgsVectorLayer* vlayer,
9696
const QgsLabelPosition& labelpos,
9797
bool pin );
98-
99-
//! Hide chosen label by setting font size to 0
100-
bool hideLabel( QgsVectorLayer* vlayer, const QgsLabelPosition& labelpos );
10198
};
10299

103100
#endif // QGSMAPTOOLPINLABELS_H

src/ui/qgisapp.ui

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,9 @@
10871087
<property name="text">
10881088
<string>Labeling</string>
10891089
</property>
1090+
<property name="toolTip">
1091+
<string>Layer Labeling Options</string>
1092+
</property>
10901093
</action>
10911094
<action name="mActionNewVectorLayer">
10921095
<property name="icon">
@@ -1475,6 +1478,9 @@
14751478
<property name="text">
14761479
<string>Move Label</string>
14771480
</property>
1481+
<property name="toolTip">
1482+
<string>Move Label</string>
1483+
</property>
14781484
</action>
14791485
<action name="mActionRotateLabel">
14801486
<property name="checkable">
@@ -1487,6 +1493,10 @@
14871493
<property name="text">
14881494
<string>Rotate Label</string>
14891495
</property>
1496+
<property name="toolTip">
1497+
<string>Rotate Label
1498+
Ctl (Cmd) increments by 15 deg.</string>
1499+
</property>
14901500
</action>
14911501
<action name="mActionChangeLabelProperties">
14921502
<property name="checkable">
@@ -1722,8 +1732,8 @@
17221732
<property name="toolTip">
17231733
<string>Pin/Unpin Labels
17241734
Click or marquee on label to pin
1725-
Hold Shift to unpin
1726-
Hold Ctl (Cmd) to toggle pin/unpin state</string>
1735+
Shift unpins, Ctl (Cmd) toggles state
1736+
Acts on all editable layers</string>
17271737
</property>
17281738
</action>
17291739
<action name="mActionShowPinnedLabels">
@@ -1791,7 +1801,8 @@ Hold Ctl (Cmd) to toggle pin/unpin state</string>
17911801
<property name="toolTip">
17921802
<string>Show/Hide Labels
17931803
Click or marquee on feature to show label
1794-
Hold Shift+click or marquee on label to hide it</string>
1804+
Shift+click or marquee on label to hide it
1805+
Acts on currently active editable layer</string>
17951806
</property>
17961807
</action>
17971808
</widget>

0 commit comments

Comments
 (0)