27 |
27 |
#include <QComboBox>
|
28 |
28 |
#include <QLineEdit>
|
29 |
29 |
#include <QDockWidget>
|
|
30 |
#include <QPushButton>
|
30 |
31 |
|
31 |
32 |
|
32 |
33 |
class QgsSnappingDock : public QDockWidget
|
... | ... | |
63 |
64 |
else
|
64 |
65 |
{
|
65 |
66 |
connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( apply() ) );
|
|
67 |
connect( mButtonBox->button(QDialogButtonBox::Apply), SIGNAL( clicked() ), this, SLOT( apply() ) );
|
66 |
68 |
}
|
67 |
|
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( update() ) );
|
68 |
|
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( update() ) );
|
|
69 |
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer * ) ), this, SLOT( connectUpdate( QgsMapLayer *) ) );
|
69 |
70 |
|
70 |
71 |
update();
|
71 |
72 |
|
... | ... | |
106 |
107 |
QSettings myQsettings;
|
107 |
108 |
bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool();
|
108 |
109 |
|
109 |
|
double defaultSnapppingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
|
110 |
|
int defaultSnapppingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt();
|
|
110 |
double defaultSnappingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
|
|
111 |
int defaultSnappingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt();
|
111 |
112 |
QString defaultSnappingString = myQsettings.value( "/qgis/digitizing/default_snap_mode", "to vertex" ).toString();
|
112 |
113 |
|
113 |
114 |
int defaultSnappingStringIdx = 0;
|
... | ... | |
133 |
134 |
|
134 |
135 |
mLayerTreeWidget->clear();
|
135 |
136 |
|
136 |
|
for ( int i = 0; i < mMapCanvas->layerCount(); ++i )
|
|
137 |
QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
|
|
138 |
int a = mapLayers.count();
|
|
139 |
QMap< QString, QgsMapLayer *>::iterator it;
|
|
140 |
for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it )
|
137 |
141 |
{
|
138 |
|
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->layer( i ) );
|
|
142 |
QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( it.value() );
|
139 |
143 |
if ( !currentVectorLayer )
|
140 |
144 |
continue;
|
141 |
145 |
|
... | ... | |
160 |
164 |
QLineEdit *leTolerance = new QLineEdit( mLayerTreeWidget );
|
161 |
165 |
QDoubleValidator *validator = new QDoubleValidator( leTolerance );
|
162 |
166 |
leTolerance->setValidator( validator );
|
163 |
|
leTolerance->setText( QString::number( defaultSnapppingTolerance, 'f' ) );
|
|
167 |
leTolerance->setText( QString::number( defaultSnappingTolerance, 'f' ) );
|
164 |
168 |
|
165 |
169 |
mLayerTreeWidget->setItemWidget( item, 3, leTolerance );
|
166 |
170 |
|
... | ... | |
168 |
172 |
QComboBox *cbxUnits = new QComboBox( mLayerTreeWidget );
|
169 |
173 |
cbxUnits->insertItem( 0, tr( "map units" ) );
|
170 |
174 |
cbxUnits->insertItem( 1, tr( "pixels" ) );
|
171 |
|
cbxUnits->setCurrentIndex( defaultSnapppingUnit );
|
|
175 |
cbxUnits->setCurrentIndex( defaultSnappingUnit );
|
172 |
176 |
mLayerTreeWidget->setItemWidget( item, 4, cbxUnits );
|
173 |
177 |
|
174 |
178 |
int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() );
|
... | ... | |
262 |
266 |
else
|
263 |
267 |
QDialog::show();
|
264 |
268 |
}
|
|
269 |
|
|
270 |
|
|
271 |
void QgsSnappingDialog::connectUpdate(QgsMapLayer * theMapLayer)
|
|
272 |
{
|
|
273 |
connect( theMapLayer,SIGNAL( destroyed() ),this,SLOT( update() ) );
|
|
274 |
update();
|
|
275 |
}
|