select_tools_update.diff
src/app/qgisapp.cpp (working copy) | ||
---|---|---|
873 | 873 |
mActionZoomOut->setStatusTip( tr( "Zoom Out" ) ); |
874 | 874 |
connect( mActionZoomOut, SIGNAL( triggered() ), this, SLOT( zoomOut() ) ); |
875 | 875 | |
876 |
mActionSelect = new QAction( getThemeIcon( "mActionSelect.png" ), tr( "Select Features" ) , this ); |
|
876 |
QString singleSelectOptTip( tr( ", hold ctrl to add/subtract current selection" ) ); |
|
877 | ||
878 |
mActionSelect = new QAction( getThemeIcon( "mActionSelect.png" ), tr( "Select single feature" ) , this ); |
|
877 | 879 |
shortcuts->registerAction( mActionSelect ); |
878 |
mActionSelect->setStatusTip( tr( "Select Features" ) );
|
|
880 |
mActionSelect->setStatusTip( tr( "Select single features" ) + singleSelectOptTip );
|
|
879 | 881 |
connect( mActionSelect, SIGNAL( triggered() ), this, SLOT( select() ) ); |
880 | 882 |
mActionSelect->setEnabled( false ); |
881 | 883 | |
884 |
QString selectOptionTip( tr( ", hold shift to select by containment" ) + singleSelectOptTip ); |
|
885 |
|
|
882 | 886 |
mActionSelectRectangle = new QAction( getThemeIcon( "mActionSelectRectangle.png" ), tr( "Select features by rectangle" ), this ); |
883 | 887 |
shortcuts->registerAction( mActionSelectRectangle ); |
884 |
mActionSelectRectangle->setStatusTip( tr( "Select features by rectangle" ) ); |
|
888 |
mActionSelectRectangle->setStatusTip( tr( "Select features by rectangle" ) + selectOptionTip );
|
|
885 | 889 |
connect( mActionSelectRectangle, SIGNAL( triggered() ), this, SLOT( selectByRectangle() ) ); |
886 | 890 |
mActionSelectRectangle->setEnabled( false ); |
887 | 891 | |
888 | 892 |
mActionSelectPolygon = new QAction( getThemeIcon( "mActionSelectPolygon.png" ), tr( "Select features by polygon" ), this ); |
889 | 893 |
shortcuts->registerAction( mActionSelectPolygon ); |
890 |
mActionSelectPolygon->setStatusTip( tr( "Select features by polygon" ) ); |
|
894 |
mActionSelectPolygon->setStatusTip( tr( "Select features by polygon" ) + selectOptionTip );
|
|
891 | 895 |
connect( mActionSelectPolygon, SIGNAL( triggered() ), this, SLOT( selectByPolygon() ) ); |
892 | 896 |
mActionSelectPolygon->setEnabled( false ); |
893 | 897 | |
894 | 898 |
mActionSelectFreehand = new QAction( getThemeIcon( "mActionSelectFreehand.png" ), tr( "Select features by freehand" ), this ); |
895 | 899 |
shortcuts->registerAction( mActionSelectFreehand ); |
896 |
mActionSelectFreehand->setStatusTip( tr( "Select features by freehand" ) ); |
|
900 |
mActionSelectFreehand->setStatusTip( tr( "Select features by freehand" ) + selectOptionTip );
|
|
897 | 901 |
connect( mActionSelectFreehand, SIGNAL( triggered() ), this, SLOT( selectByFreehand() ) ); |
898 | 902 |
mActionSelectFreehand->setEnabled( false ); |
899 | 903 | |
900 | 904 |
mActionSelectRadius = new QAction( getThemeIcon( "mActionSelectRadius.png" ), tr( "Select features by radius" ), this ); |
901 | 905 |
shortcuts->registerAction( mActionSelectRadius ); |
902 |
mActionSelectRadius->setStatusTip( tr( "Select features by radius" ) ); |
|
906 |
mActionSelectRadius->setStatusTip( tr( "Select features by radius" ) + selectOptionTip);
|
|
903 | 907 |
connect( mActionSelectRadius, SIGNAL( triggered() ), this, SLOT( selectByRadius() ) ); |
904 | 908 |
mActionSelectRadius->setEnabled( false ); |
905 | 909 |
src/app/qgsmaptoolselect.cpp (working copy) | ||
---|---|---|
46 | 46 |
QgsMapToolSelectUtils::expandSelectRectangle( selectRect, vlayer, e->pos() ); |
47 | 47 |
QgsMapToolSelectUtils::setRubberBand( mCanvas, selectRect, &rubberBand ); |
48 | 48 |
QgsGeometry* selectGeom = rubberBand.asGeometry(); |
49 |
bool addSelection = e->modifiers() & Qt::ControlModifier ? true : false; |
|
50 |
bool substractSelection = e->modifiers() & Qt::ShiftModifier ? true : false; |
|
51 |
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, false, addSelection, substractSelection, true ); |
|
49 |
bool doDifference = e->modifiers() & Qt::ControlModifier ? true : false; |
|
50 |
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, selectGeom, false, doDifference, true ); |
|
52 | 51 |
delete selectGeom; |
53 | 52 |
rubberBand.reset( true ); |
54 | 53 |
} |
src/app/qgsmaptoolselectutils.cpp (working copy) | ||
---|---|---|
81 | 81 |
void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas, |
82 | 82 |
QgsGeometry* selectGeometry, |
83 | 83 |
bool doContains, |
84 |
bool addSelection, |
|
85 |
bool substractSelection, |
|
84 |
bool doDifference, |
|
86 | 85 |
bool singleSelect ) |
87 | 86 |
{ |
88 | 87 |
if( selectGeometry->type() != QGis::Polygon ) |
... | ... | |
124 | 123 |
QgsDebugMsg( "Selection layer: " + vlayer->name() ); |
125 | 124 |
QgsDebugMsg( "Selection polygon: " + selectGeomTrans.exportToWkt() ); |
126 | 125 |
QgsDebugMsg( "doContains: " + QString( doContains ? "T" : "F" ) ); |
127 |
QgsDebugMsg( "addSelection: " + QString( addSelection ? "T" : "F" ) ); |
|
128 |
QgsDebugMsg( "substractSelection: " + QString( substractSelection ? "T" : "F" ) ); |
|
126 |
QgsDebugMsg( "doDifference: " + QString( doDifference ? "T" : "F" ) ); |
|
129 | 127 | |
130 | 128 |
vlayer->select( QgsAttributeList(), selectGeomTrans.boundingBox(), true, true ); |
131 | 129 | |
... | ... | |
161 | 159 |
newSelectedFeatures.insert( closestFeatureId ); |
162 | 160 |
} |
163 | 161 | |
164 |
QgsDebugMsg( "Number of selected features: " + QString::number( newSelectedFeatures.size() ) ); |
|
162 |
QgsDebugMsg( "Number of new selected features: " + QString::number( newSelectedFeatures.size() ) );
|
|
165 | 163 | |
166 | 164 |
QgsFeatureIds layerSelectedFeatures; |
167 |
if( addSelection )
|
|
165 |
if( doDifference )
|
|
168 | 166 |
{ |
169 | 167 |
layerSelectedFeatures = vlayer->selectedFeaturesIds(); |
170 | 168 |
QgsFeatureIds::const_iterator i = newSelectedFeatures.constEnd(); |
171 | 169 |
while( i != newSelectedFeatures.constBegin() ) |
172 | 170 |
{ |
173 | 171 |
--i; |
174 |
layerSelectedFeatures.insert( *i ); |
|
175 |
} |
|
176 |
} |
|
177 |
else if( substractSelection ) |
|
178 |
{ |
|
179 |
layerSelectedFeatures = vlayer->selectedFeaturesIds(); |
|
180 |
QgsFeatureIds::const_iterator i = newSelectedFeatures.constEnd(); |
|
181 |
while( i != newSelectedFeatures.constBegin() ) |
|
182 |
{ |
|
183 |
--i; |
|
184 |
if( layerSelectedFeatures.contains( *i ) ) |
|
172 |
if( layerSelectedFeatures.contains( *i ) ) |
|
185 | 173 |
{ |
186 | 174 |
layerSelectedFeatures.remove( *i ); |
187 | 175 |
} |
176 |
else |
|
177 |
{ |
|
178 |
layerSelectedFeatures.insert( *i ); |
|
179 |
} |
|
188 | 180 |
} |
189 | 181 |
} |
190 | 182 |
else |
... | ... | |
198 | 190 | |
199 | 191 |
void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas, QgsGeometry* selectGeometry, QMouseEvent * e ) |
200 | 192 |
{ |
201 |
bool doContains = e->modifiers() & Qt::AltModifier ? true : false; |
|
202 |
bool addSelection = e->modifiers() & Qt::ControlModifier ? true : false; |
|
203 |
bool substractSelection = e->modifiers() & Qt::ShiftModifier ? true : false; |
|
204 |
setSelectFeatures( canvas, selectGeometry, doContains, addSelection, substractSelection ); |
|
193 |
bool doContains = e->modifiers() & Qt::ShiftModifier ? true : false; |
|
194 |
bool doDifference = e->modifiers() & Qt::ControlModifier ? true : false; |
|
195 |
setSelectFeatures( canvas, selectGeometry, doContains, doDifference ); |
|
205 | 196 |
} |
src/app/qgsmaptoolselectutils.h (working copy) | ||
---|---|---|
40 | 40 |
must be in terms of the canvas coordinate system. |
41 | 41 |
@param doContains Features will only be selected if contained within the |
42 | 42 |
selection rubber band. |
43 |
@param addSelection New selected features will be added to the layer's |
|
44 |
currently selected features. |
|
45 |
@param substractSelection New selected features will be subtracted from |
|
46 |
the layer's currently selected features. |
|
43 |
@param doDifference Take the symmetric difference of the the current selected |
|
44 |
features and the new features found within the provided selectGeometry. |
|
47 | 45 |
@param singleSelect Only selects the closest feature to the selectGeometry. |
48 | 46 |
*/ |
49 | 47 |
void setSelectFeatures( QgsMapCanvas* canvas, |
50 | 48 |
QgsGeometry* selectGeometry, |
51 | 49 |
bool doContains = true, |
52 |
bool addSelection = false, |
|
53 |
bool substractSelection = false, |
|
50 |
bool doDifference = false, |
|
54 | 51 |
bool singleSelect = false ); |
55 | 52 | |
56 | 53 |
/** |