@@ -62,24 +62,44 @@ void QgsMapToolChangeLabelProperties::canvasReleaseEvent( QMouseEvent *e )
62
62
}
63
63
64
64
QgsLabelPropertyDialog d ( mCurrentLabelPos .layerID , mCurrentLabelPos .featureId , mCurrentLabelPos .labelFont , labeltext, 0 );
65
+
66
+ connect ( &d, SIGNAL ( applied () ), this , SLOT ( dialogPropertiesApplied () ) );
65
67
if ( d.exec () == QDialog::Accepted )
66
68
{
67
- const QgsAttributeMap& changes = d.changedProperties ();
68
- if ( changes.size () > 0 )
69
- {
70
- vlayer->beginEditCommand ( tr ( " Changed properties for label" ) + QString ( " '%1'" ).arg ( currentLabelText ( 24 ) ) );
71
-
72
- QgsAttributeMap::const_iterator changeIt = changes.constBegin ();
73
- for ( ; changeIt != changes.constEnd (); ++changeIt )
74
- {
75
- vlayer->changeAttributeValue ( mCurrentLabelPos .featureId , changeIt.key (), changeIt.value () );
76
- }
77
-
78
- vlayer->endEditCommand ();
79
- mCanvas ->refresh ();
80
- }
69
+ applyChanges ( d.changedProperties () );
81
70
}
71
+
82
72
deleteRubberBands ();
83
73
}
84
74
}
85
75
76
+ void QgsMapToolChangeLabelProperties::applyChanges ( const QgsAttributeMap& changes )
77
+ {
78
+ QgsVectorLayer* vlayer = currentLayer ();
79
+ if ( !vlayer )
80
+ return ;
81
+
82
+ if ( changes.size () > 0 )
83
+ {
84
+ vlayer->beginEditCommand ( tr ( " Changed properties for label" ) + QString ( " '%1'" ).arg ( currentLabelText ( 24 ) ) );
85
+
86
+ QgsAttributeMap::const_iterator changeIt = changes.constBegin ();
87
+ for ( ; changeIt != changes.constEnd (); ++changeIt )
88
+ {
89
+ vlayer->changeAttributeValue ( mCurrentLabelPos .featureId , changeIt.key (), changeIt.value () );
90
+ }
91
+
92
+ vlayer->endEditCommand ();
93
+ mCanvas ->refresh ();
94
+ }
95
+ }
96
+
97
+ void QgsMapToolChangeLabelProperties::dialogPropertiesApplied ()
98
+ {
99
+ QgsLabelPropertyDialog* dlg = qobject_cast<QgsLabelPropertyDialog*>( sender () );
100
+ if ( !dlg )
101
+ return ;
102
+
103
+ applyChanges ( dlg->changedProperties () );
104
+ }
105
+
0 commit comments