QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl ) : QDialog( parent, fl ), mMapCanvas( mapCanvas ) { setupUi( this ); connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) ); /////////////////////////////////////////////////////////// // Properties stored in map canvas's QgsMapRenderer // these ones are propagated to QgsProject by a signal QgsMapRenderer* myRender = mMapCanvas->mapRenderer(); QGis::UnitType myUnit = myRender->mapUnits(); setMapUnits( myUnit ); //see if the user wants on the fly projection enabled bool myProjectionEnabled = myRender->hasCrsTransformEnabled(); cbxProjectionEnabled->setChecked( myProjectionEnabled ); long myCRSID = myRender->destinationSrs().srsid(); QgsDebugMsg( "Read project CRSID: " + QString::number( myCRSID ) ); projectionSelector->setSelectedCrsId( myCRSID ); /////////////////////////////////////////////////////////// // Properties stored in QgsProject title( QgsProject::instance()->title() ); // get the manner in which the number of decimal places in the mouse // position display is set (manual or automatic) bool automaticPrecision = QgsProject::instance()->readBoolEntry( "PositionPrecision", "/Automatic" ); if ( automaticPrecision ) { radAutomatic->setChecked( true ); } else { radManual->setChecked( true ); } int dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" ); spinBoxDP->setValue( dp ); //get the colour selections and set the button colour accordingly int myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 ); int myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 ); int myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 ); QColor myColour = QColor( myRedInt, myGreenInt, myBlueInt ); pbnSelectionColour->setColor( myColour ); //get the colour for map canvas background and set button colour accordingly (default white) myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorRedPart", 255 ); myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorGreenPart", 255 ); myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorBluePart", 255 ); myColour = QColor( myRedInt, myGreenInt, myBlueInt ); pbnCanvasColor->setColor( myColour ); //read the digitizing settings int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 ); if ( topologicalEditing != 0 ) { mEnableTopologicalEditingCheckBox->setCheckState( Qt::Checked ); } else { mEnableTopologicalEditingCheckBox->setCheckState( Qt::Unchecked ); } int avoidPolygonIntersections = QgsProject::instance()->readNumEntry( "Digitizing", "/AvoidPolygonIntersections", 0 ); if ( avoidPolygonIntersections != 0 ) { mAvoidIntersectionsCheckBox->setCheckState( Qt::Checked ); } else { mAvoidIntersectionsCheckBox->setCheckState( Qt::Unchecked ); } bool ok; QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &ok ); QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &ok ); QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", &ok ); QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &ok ); QStringList::const_iterator idIter = layerIdList.constBegin(); QStringList::const_iterator enabledIter = enabledList.constBegin(); QStringList::const_iterator tolIter = toleranceList.constBegin(); QStringList::const_iterator snapToIter = snapToList.constBegin(); QgsMapLayer* currentLayer = 0; //create the new layer entries for ( ; idIter != layerIdList.constEnd(); ++idIter, ++enabledIter, ++tolIter, ++snapToIter ) { currentLayer = QgsMapLayerRegistry::instance()->mapLayer( *idIter ); if ( currentLayer ) { LayerEntry newEntry; newEntry.layerName = currentLayer->name(); if (( *enabledIter ) == "enabled" ) { newEntry.checked = true; } else { newEntry.checked = false; } if (( *snapToIter ) == "to_vertex" ) { newEntry.snapTo = 0; } else if (( *snapToIter ) == "to_segment" ) { newEntry.snapTo = 1; } else //to vertex and segment { newEntry.snapTo = 2; } newEntry.tolerance = tolIter->toDouble(); mSnappingLayerSettings.insert( *idIter, newEntry ); } } }
QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl ) : QDialog( parent, fl ), mMapCanvas( mapCanvas ) { setupUi( this ); connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) ); connect( projectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( setMapUnitsToCurrentProjection() ) ); /////////////////////////////////////////////////////////// // Properties stored in map canvas's QgsMapRenderer // these ones are propagated to QgsProject by a signal QgsMapRenderer* myRender = mMapCanvas->mapRenderer(); QGis::UnitType myUnit = myRender->mapUnits(); setMapUnits( myUnit ); //see if the user wants on the fly projection enabled bool myProjectionEnabled = myRender->hasCrsTransformEnabled(); cbxProjectionEnabled->setChecked( myProjectionEnabled ); btnGrpMapUnits->setEnabled( !myProjectionEnabled ); long myCRSID = myRender->destinationSrs().srsid(); QgsDebugMsg( "Read project CRSID: " + QString::number( myCRSID ) ); projectionSelector->setSelectedCrsId( myCRSID ); /////////////////////////////////////////////////////////// // Properties stored in QgsProject title( QgsProject::instance()->title() ); // get the manner in which the number of decimal places in the mouse // position display is set (manual or automatic) bool automaticPrecision = QgsProject::instance()->readBoolEntry( "PositionPrecision", "/Automatic" ); if ( automaticPrecision ) { radAutomatic->setChecked( true ); spinBoxDP->setDisabled( true ); labelDP->setDisabled( true ); } else { radManual->setChecked( true ); } cbxAbsolutePath->setCurrentIndex( QgsProject::instance()->readBoolEntry( "Paths", "/Absolute", true ) ? 0 : 1 ); int dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" ); spinBoxDP->setValue( dp ); //get the color selections and set the button color accordingly int myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 ); int myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 ); int myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 ); int myAlphaInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorAlphaPart", 255 ); QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt, myAlphaInt ); pbnSelectionColor->setColor( myColor ); //get the color for map canvas background and set button color accordingly (default white) myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorRedPart", 255 ); myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorGreenPart", 255 ); myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorBluePart", 255 ); myColor = QColor( myRedInt, myGreenInt, myBlueInt ); pbnCanvasColor->setColor( myColor ); QgsMapLayer* currentLayer = 0; QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" ); const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); twIdentifyLayers->setColumnCount( 3 ); twIdentifyLayers->horizontalHeader()->setVisible( true ); twIdentifyLayers->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "Layer" ) ) ); twIdentifyLayers->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr( "Type" ) ) ); twIdentifyLayers->setHorizontalHeaderItem( 2, new QTableWidgetItem( tr( "Identifiable" ) ) ); twIdentifyLayers->setRowCount( mapLayers.size() ); twIdentifyLayers->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ); int i = 0; for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++, i++ ) { currentLayer = it.value(); QTableWidgetItem *twi = new QTableWidgetItem( QString::number( i ) ); twIdentifyLayers->setVerticalHeaderItem( i, twi ); twi = new QTableWidgetItem( currentLayer->name() ); twi->setData( Qt::UserRole, it.key() ); twi->setFlags( twi->flags() & ~Qt::ItemIsEditable ); twIdentifyLayers->setItem( i, 0, twi ); QString type; if ( currentLayer->type() == QgsMapLayer::VectorLayer ) { type = tr( "Vector" ); } else if ( currentLayer->type() == QgsMapLayer::RasterLayer ) { QgsRasterLayer *rl = qobject_cast<QgsRasterLayer *>( currentLayer ); if ( rl && rl->providerKey() == "wms" ) { type = tr( "WMS" ); } else { type = tr( "Raster" ); } } twi = new QTableWidgetItem( type ); twi->setFlags( twi->flags() & ~Qt::ItemIsEditable ); twIdentifyLayers->setItem( i, 1, twi ); QCheckBox *cb = new QCheckBox(); cb->setChecked( !noIdentifyLayerIdList.contains( currentLayer->getLayerID() ) ); twIdentifyLayers->setCellWidget( i, 2, cb ); } restoreState(); }