33
33
#include " qgsrenderer.h"
34
34
#include " qgssnappingdialog.h"
35
35
#include " qgsrasterlayer.h"
36
+ #include " qgsvectorlayer.h"
37
+ #include " qgsvectordataprovider.h"
36
38
#include " qgsscaleutils.h"
37
39
#include " qgsgenericprojectionselector.h"
38
40
#include " qgsstylev2.h"
@@ -298,8 +300,20 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
298
300
}
299
301
300
302
QStringList wfsLayerIdList = QgsProject::instance ()->readListEntry ( " WFSLayers" , " /" );
301
-
302
- twWFSLayers->setColumnCount ( 2 );
303
+ QStringList wfstUpdateLayerIdList = QgsProject::instance ()->readListEntry ( " WFSTLayers" , " Update" );
304
+ QStringList wfstInsertLayerIdList = QgsProject::instance ()->readListEntry ( " WFSTLayers" , " Insert" );
305
+ QStringList wfstDeleteLayerIdList = QgsProject::instance ()->readListEntry ( " WFSTLayers" , " Delete" );
306
+
307
+ QSignalMapper *smPublied = new QSignalMapper (this );
308
+ connect (smPublied, SIGNAL (mapped (int )), this , SLOT (on_cbxWFSPublied_stateChanged (int )));
309
+ QSignalMapper *smUpdate = new QSignalMapper (this );
310
+ connect (smUpdate, SIGNAL (mapped (int )), this , SLOT (on_cbxWFSUpdate_stateChanged (int )));
311
+ QSignalMapper *smInsert = new QSignalMapper (this );
312
+ connect (smInsert, SIGNAL (mapped (int )), this , SLOT (on_cbxWFSInsert_stateChanged (int )));
313
+ QSignalMapper *smDelete = new QSignalMapper (this );
314
+ connect (smDelete, SIGNAL (mapped (int )), this , SLOT (on_cbxWFSDelete_stateChanged (int )));
315
+
316
+ twWFSLayers->setColumnCount ( 5 );
303
317
twWFSLayers->horizontalHeader ()->setVisible ( true );
304
318
twWFSLayers->setRowCount ( mapLayers.size () );
305
319
@@ -319,11 +333,44 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
319
333
twi->setFlags ( twi->flags () & ~Qt::ItemIsEditable );
320
334
twWFSLayers->setItem ( j, 0 , twi );
321
335
322
- QCheckBox *cb = new QCheckBox ();
323
- cb->setChecked ( wfsLayerIdList.contains ( currentLayer->id () ) );
324
- twWFSLayers->setCellWidget ( j, 1 , cb );
325
- j++;
336
+ QCheckBox* cbp = new QCheckBox ();
337
+ cbp->setChecked ( wfsLayerIdList.contains ( currentLayer->id () ) );
338
+ twWFSLayers->setCellWidget ( j, 1 , cbp );
339
+
340
+ smPublied->setMapping (cbp, j);
341
+ connect (cbp, SIGNAL (stateChanged (int )), smPublied, SLOT (map ()));
342
+
343
+ QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( currentLayer );
344
+ QgsVectorDataProvider* provider = vlayer->dataProvider ();
345
+ if ( (provider->capabilities () & QgsVectorDataProvider::ChangeAttributeValues ) && (provider->capabilities () & QgsVectorDataProvider::ChangeGeometries ) )
346
+ {
347
+ QCheckBox* cbu = new QCheckBox ();
348
+ cbu->setChecked ( wfstUpdateLayerIdList.contains ( currentLayer->id () ) );
349
+ twWFSLayers->setCellWidget ( j, 2 , cbu );
350
+
351
+ smUpdate->setMapping (cbu, j);
352
+ connect (cbu, SIGNAL (stateChanged (int )), smUpdate, SLOT (map ()));
353
+ }
354
+ if ( ( provider->capabilities () & QgsVectorDataProvider::AddFeatures ) )
355
+ {
356
+ QCheckBox* cbi = new QCheckBox ();
357
+ cbi->setChecked ( wfstInsertLayerIdList.contains ( currentLayer->id () ) );
358
+ twWFSLayers->setCellWidget ( j, 3 , cbi );
359
+
360
+ smInsert->setMapping (cbi, j);
361
+ connect (cbi, SIGNAL (stateChanged (int )), smInsert, SLOT (map ()));
362
+ }
363
+ if ( ( provider->capabilities () & QgsVectorDataProvider::DeleteFeatures ) )
364
+ {
365
+ QCheckBox* cbd = new QCheckBox ();
366
+ cbd->setChecked ( wfstDeleteLayerIdList.contains ( currentLayer->id () ) );
367
+ twWFSLayers->setCellWidget ( j, 4 , cbd );
368
+
369
+ smDelete->setMapping (cbd, j);
370
+ connect (cbd, SIGNAL (stateChanged (int )), smDelete, SLOT (map ()));
371
+ }
326
372
373
+ j++;
327
374
}
328
375
}
329
376
twWFSLayers->setRowCount ( j );
@@ -610,16 +657,38 @@ void QgsProjectProperties::apply()
610
657
}
611
658
612
659
QStringList wfsLayerList;
660
+ QStringList wfstUpdateLayerList;
661
+ QStringList wfstInsertLayerList;
662
+ QStringList wfstDeleteLayerList;
613
663
for ( int i = 0 ; i < twWFSLayers->rowCount (); i++ )
614
664
{
615
- QCheckBox *cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( i, 1 ) );
665
+ QString id = twWFSLayers->item ( i, 0 )->data ( Qt::UserRole ).toString ();
666
+ QCheckBox* cb;
667
+ cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( i, 1 ) );
616
668
if ( cb && cb->isChecked () )
617
669
{
618
- QString id = twWFSLayers->item ( i, 0 )->data ( Qt::UserRole ).toString ();
619
670
wfsLayerList << id;
620
671
}
672
+ cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( i, 2 ) );
673
+ if ( cb && cb->isChecked () )
674
+ {
675
+ wfstUpdateLayerList << id;
676
+ }
677
+ cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( i, 3 ) );
678
+ if ( cb && cb->isChecked () )
679
+ {
680
+ wfstInsertLayerList << id;
681
+ }
682
+ cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( i, 4 ) );
683
+ if ( cb && cb->isChecked () )
684
+ {
685
+ wfstDeleteLayerList << id;
686
+ }
621
687
}
622
688
QgsProject::instance ()->writeEntry ( " WFSLayers" , " /" , wfsLayerList );
689
+ QgsProject::instance ()->writeEntry ( " WFSTLayers" , " Update" , wfstUpdateLayerList );
690
+ QgsProject::instance ()->writeEntry ( " WFSTLayers" , " Insert" , wfstInsertLayerList );
691
+ QgsProject::instance ()->writeEntry ( " WFSTLayers" , " Delete" , wfstDeleteLayerList );
623
692
624
693
// Default Styles
625
694
QgsProject::instance ()->writeEntry ( " DefaultStyles" , " /Marker" , cboStyleMarker->currentText () );
@@ -691,6 +760,62 @@ void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged( int state )
691
760
}
692
761
}
693
762
763
+ void QgsProjectProperties::on_cbxWFSPublied_stateChanged ( int aIdx )
764
+ {
765
+ QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 1 ) );
766
+ if ( cb && !cb->isChecked () )
767
+ {
768
+ QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 2 ) );
769
+ if ( cbn )
770
+ cbn->setChecked (false );
771
+ }
772
+ }
773
+
774
+ void QgsProjectProperties::on_cbxWFSUpdate_stateChanged ( int aIdx )
775
+ {
776
+ QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 2 ) );
777
+ if ( cb && cb->isChecked () )
778
+ {
779
+ QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 1 ) );
780
+ if ( cbn )
781
+ cbn->setChecked (true );
782
+ }
783
+ else if ( cb && !cb->isChecked () )
784
+ {
785
+ QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 3 ) );
786
+ if ( cbn )
787
+ cbn->setChecked (false );
788
+ }
789
+ }
790
+
791
+ void QgsProjectProperties::on_cbxWFSInsert_stateChanged ( int aIdx )
792
+ {
793
+ QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 3 ) );
794
+ if ( cb && cb->isChecked () )
795
+ {
796
+ QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 2 ) );
797
+ if ( cbn )
798
+ cbn->setChecked (true );
799
+ }
800
+ else if ( cb && !cb->isChecked () )
801
+ {
802
+ QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 4 ) );
803
+ if ( cbn )
804
+ cbn->setChecked (false );
805
+ }
806
+ }
807
+
808
+ void QgsProjectProperties::on_cbxWFSDelete_stateChanged ( int aIdx )
809
+ {
810
+ QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 4 ) );
811
+ if ( cb && cb->isChecked () )
812
+ {
813
+ QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget ( aIdx, 3 ) );
814
+ if ( cbn )
815
+ cbn->setChecked (true );
816
+ }
817
+ }
818
+
694
819
void QgsProjectProperties::setMapUnitsToCurrentProjection ()
695
820
{
696
821
long myCRSID = projectionSelector->selectedCrsId ();
0 commit comments