~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to src/qgsdlgvectorlayerproperties.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve Halasz
  • Date: 2005-11-05 16:04:45 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051105160445-l0g4isz5bc9yehet
Tags: 0.7.4-1
* New upstream release
* Build GRASS support in qgis-plugin-grass package (Closes: #248649)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *   (at your option) any later version.                                   *
16
16
 *                                                                         *
17
17
 ***************************************************************************/
18
 
 /* $Id: qgsdlgvectorlayerproperties.cpp,v 1.40.2.4 2004/12/10 03:54:23 gsherman Exp $ */
 
18
 /* $Id: qgsdlgvectorlayerproperties.cpp,v 1.54.2.10 2005/10/10 20:05:09 gsherman Exp $ */
19
19
#include <qstring.h>
20
20
#include <qlineedit.h>
21
21
#include <qtextedit.h>
33
33
#include <qwidget.h>
34
34
#include <qgroupbox.h>
35
35
#include <qwhatsthis.h>
36
 
 
 
36
#include <qregexp.h>
 
37
#include <qtabwidget.h>
37
38
 
38
39
#include "qgis.h"
39
40
#include "qgsrect.h"
68
69
#ifdef HAVE_POSTGRESQL
69
70
#include "qgspgquerybuilder.h"
70
71
#endif
71
 
 
72
 
QgsDlgVectorLayerProperties::QgsDlgVectorLayerProperties(QgsVectorLayer * lyr, QWidget * parent, const char *name, bool modal):QgsDlgVectorLayerPropertiesBase(parent, name, modal), layer(lyr), rendererDirty(false), bufferDialog(layer->rendererDialog()),
73
 
bufferRenderer(layer->
74
 
               renderer())
 
72
#include "qgslayerprojectionselector.h"
 
73
#include <qapplication.h>
 
74
 
 
75
 
 
76
QgsDlgVectorLayerProperties::QgsDlgVectorLayerProperties(QgsVectorLayer * lyr, 
 
77
                                                         QWidget * parent, 
 
78
                                                         const char *name, 
 
79
                                                         bool modal)
 
80
    : QgsDlgVectorLayerPropertiesBase(parent, name, modal), 
 
81
      layer(lyr), 
 
82
      rendererDirty(false), 
 
83
      bufferDialog(layer->rendererDialog()),
 
84
      bufferRenderer(layer->renderer())
75
85
{
76
 
 
77
 
  // populate the general information
78
 
  QString source = layer->source();
79
 
  source = source.left(source.find("password"));
80
 
  lblSource->setText(source);
81
 
  txtDisplayName->setText(layer->name());
82
 
  // set whats this stuff
83
 
  QWhatsThis::add(lblSource, tr("The source of the data (path name or database connection information)"));
84
 
  QWhatsThis::add(pbnQueryBuilder, tr("This button opens the PostgreSQL query builder and allows you to create a subset of features to display on the map canvas rather than displaying all features in the layer"));
85
 
  QWhatsThis::add(txtSubsetSQL, tr("The query used to limit the features in the layer is shown here. This is currently only supported for PostgreSQL layers. To enter or modify the query, click on the Query Builder button"));
86
 
  QWhatsThis::add(lblGeometryType, tr("Geometry type of the features in this layer"));
87
 
  QWhatsThis::add(lblFeatureCount, tr("The number of features in this layer"));
88
 
  // display type and feature count
89
 
  lblGeometryType->setText(QGis::qgisVectorGeometryType[layer->vectorType()]);
90
 
  //we are dealing with a pg layer here so that we can enable the sql box
91
 
  QgsVectorDataProvider *dp = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
92
 
  //see if we are dealing with a pg layer here
93
 
  if(layer->providerType() == "postgres")
94
 
  {
95
 
    grpSubset->setEnabled(true);
96
 
    txtSubsetSQL->setText(layer->subsetString());
97
 
    // if the user is allowed to type an adhoc query, the app will crash if the query
98
 
    // is bad. For this reason, the sql box is disabled and the query must be built
99
 
    // using the query builder, either by typing it in by hand or using the buttons, etc
100
 
    // on the builder. If the ability to enter a query directly into the box is required,
101
 
    // a mechanism to check it must be implemented.
102
 
    txtSubsetSQL->setEnabled(false); 
103
 
    pbnQueryBuilder->setEnabled(true);
104
 
  }
105
 
  else
106
 
  {
107
 
    grpSubset->setEnabled(false);
108
 
  }
109
 
  QString numFeatures;
110
 
  numFeatures = numFeatures.setNum(layer->featureCount());
111
 
  lblFeatureCount->setText(numFeatures);
112
 
  QgsRect *extent = dp->extent();
113
 
  QString ll;
114
 
  //QTextOStream (&ll) << extent->xMin() << ", " << extent->yMin();
115
 
  lblLowerLeft->setText(ll.sprintf("%16f, %16f", extent->xMin(), extent->yMin()));
116
 
  QString ur;
117
 
//  QTextOStream (&ur) << extent->xMax() << ", " << extent->yMax();
118
 
  lblUpperRight->setText(ur.sprintf("%16f, %16f", extent->xMax(), extent->yMax()));
119
 
  std::vector<QgsField> fields = dp->fields();
120
 
  // populate the table and the display field drop-down with the field
121
 
  // information
122
 
 
123
 
  for (int i = 0; i < fields.size(); i++)
124
 
  {
125
 
    QgsField fld = fields[i];
126
 
    QListViewItem *lvi = new QListViewItem(listViewFields, fld.name(),
127
 
                                           fld.type(), QString("%1").arg(fld.length()),
128
 
                                           QString("%1").arg(fld.precision()));
129
 
    displayFieldComboBox->insertItem( fld.name() );
130
 
  }
131
 
 
132
 
  // set up the scale based layer visibility stuff....
133
 
  chkUseScaleDependentRendering->setChecked(lyr->scaleBasedVisibility());
134
 
  spinMinimumScale->setValue(lyr->minScale());
135
 
  spinMaximumScale->setValue(lyr->maxScale());
136
 
 
137
 
  // symbology initialization
138
 
  legendtypecombobox->insertItem(tr("Single Symbol"));
139
 
  legendtypecombobox->insertItem(tr("Graduated Symbol"));
140
 
  legendtypecombobox->insertItem(tr("Continuous Color"));
141
 
  legendtypecombobox->insertItem(tr("Unique Value"));
142
 
  if( layer->vectorType()==QGis::Point )
143
 
  {
144
 
      legendtypecombobox->insertItem(tr("Single Marker"));
145
 
      legendtypecombobox->insertItem(tr("Graduated Marker"));
146
 
      legendtypecombobox->insertItem(tr("Unique Value Marker"));
147
 
  }
148
 
 
 
86
  // Create the Label dialog tab
149
87
  QVBoxLayout *layout = new QVBoxLayout( labelOptionsFrame );
150
 
  labelDialog = new QgsLabelDialog ( layer->label(),labelOptionsFrame);
 
88
  labelDialog = new QgsLabelDialog ( layer->label(), labelOptionsFrame);
151
89
  layout->addWidget( labelDialog );
152
90
 
153
 
  QGridLayout *actionLayout = new QGridLayout( actionOptionsFrame );
154
 
  actionDialog = new QgsAttributeActionDialog ( layer->actions(), fields,
 
91
  // Create the Actions dialog tab
 
92
  QgsVectorDataProvider *dp = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
 
93
  QVBoxLayout *actionLayout = new QVBoxLayout( actionOptionsFrame );
 
94
  std::vector<QgsField> fields = dp->fields();
 
95
  actionDialog = new QgsAttributeActionDialog ( layer->actions(), fields, 
155
96
                                                actionOptionsFrame );
156
 
  actionLayout->addWidget( actionDialog,0,0 );
157
 
 
158
 
  QObject::connect(legendtypecombobox, SIGNAL(activated(const QString &)), this, SLOT(alterLayerDialog(const QString &)));
159
 
 
160
 
  //insert the renderer dialog of the vector layer into the widget stack
161
 
  widgetStackRenderers->addWidget(bufferDialog);
162
 
  widgetStackRenderers->raiseWidget(bufferDialog);
163
 
 
164
 
}
 
97
  actionLayout->addWidget( actionDialog );
 
98
 
 
99
  reset();
 
100
  pbnOK->setFocus();
 
101
  if(layer->getDataProvider())//enable spatial index button group if supported by provider
 
102
  {
 
103
      int capabilities=layer->getDataProvider()->capabilities();
 
104
      if(capabilities&QgsVectorDataProvider::CreateSpatialIndex)
 
105
      {
 
106
          indexGroupBox->setEnabled(true);
 
107
      }
 
108
  }
 
109
 
 
110
  if ( layer->coordinateTransform() )
 
111
  {
 
112
      leSpatialRefSys->setText(layer->coordinateTransform()->sourceSRS().proj4String());
 
113
  }
 
114
 
 
115
} // QgsDlgVectorLayerProperties ctor
165
116
 
166
117
QgsDlgVectorLayerProperties::~QgsDlgVectorLayerProperties()
167
118
{
264
215
 
265
216
void QgsDlgVectorLayerProperties::setLegendType(QString type)
266
217
{
267
 
  legendtypecombobox->setCurrentText(tr(type));
 
218
  legendtypecombobox->setCurrentText(type);
268
219
}
269
220
 
270
221
void QgsDlgVectorLayerProperties::setDisplayField(QString name)
272
223
  displayFieldComboBox->setCurrentText(name);
273
224
}
274
225
 
 
226
//! @note in raster props, this metho d is called sync()
275
227
void QgsDlgVectorLayerProperties::reset( void )
276
228
{
277
 
    actionDialog->init();
278
 
    labelDialog->init();
279
 
    labelCheckBox->setChecked(layer->labelOn());
280
 
}
 
229
  // populate the general information
 
230
  QString source = layer->source();
 
231
  source = source.left(source.find("password"));
 
232
  lblSource->setText(source);
 
233
  txtDisplayName->setText(layer->name());
 
234
  // set whats this stuff
 
235
  QWhatsThis::add(lblSource, tr("The source of the data (path name or database connection information)"));
 
236
  QWhatsThis::add(pbnQueryBuilder, tr("This button opens the PostgreSQL query builder and allows you to create a subset of features to display on the map canvas rather than displaying all features in the layer"));
 
237
  QWhatsThis::add(txtSubsetSQL, tr("The query used to limit the features in the layer is shown here. This is currently only supported for PostgreSQL layers. To enter or modify the query, click on the Query Builder button"));
 
238
 
 
239
  //we are dealing with a pg layer here so that we can enable the sql box
 
240
  QgsVectorDataProvider *dp = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
 
241
  //see if we are dealing with a pg layer here
 
242
  if(layer->providerType() == "postgres")
 
243
  {
 
244
    grpSubset->setEnabled(true);
 
245
    txtSubsetSQL->setText(layer->subsetString());
 
246
    // if the user is allowed to type an adhoc query, the app will crash if the query
 
247
    // is bad. For this reason, the sql box is disabled and the query must be built
 
248
    // using the query builder, either by typing it in by hand or using the buttons, etc
 
249
    // on the builder. If the ability to enter a query directly into the box is required,
 
250
    // a mechanism to check it must be implemented.
 
251
    txtSubsetSQL->setEnabled(false); 
 
252
    pbnQueryBuilder->setEnabled(true);
 
253
  }
 
254
  else
 
255
  {
 
256
    grpSubset->setEnabled(false);
 
257
  }
 
258
 
 
259
  //get field list for display field combo
 
260
  std::vector<QgsField> myFields = dp->fields();
 
261
  for (int i = 0; i < myFields.size(); i++)
 
262
  {
 
263
    QgsField myField = myFields[i];            
 
264
    displayFieldComboBox->insertItem( myField.name() );
 
265
  }   
 
266
 
 
267
  // set up the scale based layer visibility stuff....
 
268
  chkUseScaleDependentRendering->setChecked(layer->scaleBasedVisibility());
 
269
  spinMinimumScale->setValue((int)layer->minScale());
 
270
  spinMaximumScale->setValue((int)layer->maxScale());
 
271
 
 
272
  // symbology initialization
 
273
  if(legendtypecombobox->count()==0)
 
274
    {
 
275
      legendtypecombobox->insertItem(tr("Single Symbol"));
 
276
      if(myFields.size()>0)
 
277
      {
 
278
          legendtypecombobox->insertItem(tr("Graduated Symbol"));
 
279
          legendtypecombobox->insertItem(tr("Continuous Color"));
 
280
          legendtypecombobox->insertItem(tr("Unique Value"));
 
281
      }
 
282
      if( layer->vectorType()==QGis::Point )
 
283
        {
 
284
          legendtypecombobox->insertItem(tr("Single Marker"));
 
285
          if(myFields.size()>0)
 
286
          {
 
287
              legendtypecombobox->insertItem(tr("Graduated Marker"));
 
288
              legendtypecombobox->insertItem(tr("Unique Value Marker"));
 
289
          }
 
290
        }
 
291
    }
 
292
 
 
293
  QObject::connect(legendtypecombobox, SIGNAL(activated(const QString &)), this, SLOT(alterLayerDialog(const QString &)));
 
294
 
 
295
  //insert the renderer dialog of the vector layer into the widget stack
 
296
  widgetStackRenderers->addWidget(bufferDialog);
 
297
  widgetStackRenderers->raiseWidget(bufferDialog);
 
298
 
 
299
  //set the metadata contents
 
300
  teMetadata->setText(getMetadata());
 
301
  actionDialog->init();
 
302
  labelDialog->init();
 
303
  labelCheckBox->setChecked(layer->labelOn());
 
304
 
 
305
} // reset()
 
306
 
 
307
 
281
308
//
282
309
// methods reimplemented from qt designer base class
283
310
//
308
335
      //restore the right name in the combobox
309
336
      if(bufferRenderer)
310
337
      {
311
 
          legendtypecombobox->setCurrentText(tr(bufferRenderer->name()));
 
338
          legendtypecombobox->setCurrentText(bufferRenderer->name());
312
339
      }
313
340
    }
314
 
  reject();
 
341
  //reject();
 
342
  close();
315
343
}
316
344
void QgsDlgVectorLayerProperties::pbnApply_clicked()
317
345
{
403
431
  // create the query builder object using the table name
404
432
  // and postgres connection from the provider
405
433
  QgsPgQueryBuilder *pqb =
406
 
      new QgsPgQueryBuilder(myPGProvider->getURI());
 
434
      new QgsPgQueryBuilder(myPGProvider->getURI(), this);
407
435
       
408
436
  // Set the sql in the query builder to the same in the prop dialog
409
437
  // (in case the user has already changed it)
414
442
    // if the sql is changed, update it in the prop subset text box
415
443
    txtSubsetSQL->setText(pqb->sql());
416
444
    //TODO If the sql is changed in the prop dialog, the layer extent should be recalculated
 
445
 
 
446
    // The datasource for the layer needs to be updated with the new sql since this gets
 
447
    // saved to the project file. This should happen at the map layer level...
 
448
 
417
449
  }
418
450
  // delete the query builder object
419
451
  delete pqb;
420
452
#endif
421
453
}
 
454
 
 
455
void QgsDlgVectorLayerProperties::pbnIndex_clicked()
 
456
{
 
457
    QgsVectorDataProvider* pr=layer->getDataProvider();
 
458
    if(pr)
 
459
    {
 
460
        setCursor(Qt::WaitCursor);
 
461
        bool errval=pr->createSpatialIndex();
 
462
        setCursor(Qt::ArrowCursor);
 
463
        if(errval)
 
464
        {
 
465
            QMessageBox::information(this, tr("Spatial Index"), tr("Creation of spatial index successfull"),QMessageBox::Ok);
 
466
        }
 
467
        else
 
468
        {
 
469
           QMessageBox::information(this, tr("Spatial Index"), tr("Creation of spatial index failed"),QMessageBox::Ok); 
 
470
        }
 
471
    }
 
472
}
 
473
 
 
474
QString QgsDlgVectorLayerProperties::getMetadata()
 
475
{
 
476
  QString myMetadataQString = "<html><body>";
 
477
  myMetadataQString += "<table width=\"100%\">";
 
478
  
 
479
  //-------------
 
480
  
 
481
  myMetadataQString += "<tr><td bgcolor=\"gray\">";
 
482
  myMetadataQString += tr("General:");
 
483
  myMetadataQString += "</td></tr>";
 
484
  //geom type
 
485
  myMetadataQString += "<tr><td bgcolor=\"white\">";
 
486
 
 
487
  QGis::VectorType vectorType = layer->vectorType();
 
488
 
 
489
  if ( vectorType < 0 || vectorType > QGis::Polygon )
 
490
  {
 
491
      QgsDebug( "Invalid vector type" );
 
492
  }
 
493
  else
 
494
  {
 
495
      QString vectorTypeString( QGis::qgisVectorGeometryType[layer->vectorType()] );
 
496
 
 
497
#ifdef QGISDEBUG
 
498
      const char* vectorTypeProbe = vectorTypeString.ascii(); // debugger probe point
 
499
#endif
 
500
 
 
501
      myMetadataQString += tr("Geometry type of the features in this layer : ") + 
 
502
          vectorTypeString;
 
503
      myMetadataQString += "</td></tr>";
 
504
  }
 
505
 
 
506
  //feature count
 
507
  myMetadataQString += "<tr><td bgcolor=\"white\">";
 
508
  myMetadataQString += tr("The number of features in this layer : ") + 
 
509
                       QString::number(layer->featureCount());
 
510
  myMetadataQString += "</td></tr>";
 
511
 
 
512
  //-------------
 
513
 
 
514
  QgsRect myExtent = layer->extent();  
 
515
  myMetadataQString += "<tr><td bgcolor=\"gray\">";
 
516
  myMetadataQString += tr("Extents:");
 
517
  myMetadataQString += "</td></tr>";
 
518
  //extents in layer cs  TODO...maybe make a little nested table to improve layout...
 
519
  myMetadataQString += "<tr><td bgcolor=\"white\">";
 
520
  myMetadataQString += tr("In layer spatial reference system units : ") + 
 
521
                       tr("xMin,yMin ") + 
 
522
                       QString::number(myExtent.xMin()) + 
 
523
                       "," + 
 
524
                       QString::number( myExtent.yMin()) +
 
525
                       tr(" : xMax,yMax ") + 
 
526
                       QString::number(myExtent.xMax()) + 
 
527
                       "," + 
 
528
                       QString::number(myExtent.yMax());
 
529
  myMetadataQString += "</td></tr>";
 
530
 
 
531
  //extents in project cs
 
532
 
 
533
  try
 
534
  {
 
535
    QgsCoordinateTransform * coordinateTransform = layer->coordinateTransform();
 
536
 
 
537
    if ( ! coordinateTransform )
 
538
    {
 
539
        throw QgsCsException( string("unable to get layer coordinate transform object") );
 
540
    }
 
541
 
 
542
    QgsRect myProjectedExtent = coordinateTransform->transformBoundingBox(layer->extent());
 
543
    myMetadataQString += "<tr><td bgcolor=\"white\">";
 
544
    myMetadataQString += tr("In project spatial reference system units : ") + 
 
545
                         tr("xMin,yMin ") + 
 
546
                         QString::number(myProjectedExtent.xMin()) + 
 
547
                         "," + 
 
548
                         QString::number( myProjectedExtent.yMin()) +
 
549
                         tr(" : xMax,yMax ") + 
 
550
                         QString::number(myProjectedExtent.xMax()) + 
 
551
                         "," + 
 
552
                         QString::number(myProjectedExtent.yMax());
 
553
    myMetadataQString += "</td></tr>";
 
554
 
 
555
 
 
556
 
 
557
    // 
 
558
    // Display layer spatial ref system
 
559
    //
 
560
    myMetadataQString += "<tr><td bgcolor=\"gray\">";
 
561
    myMetadataQString += tr("Layer Spatial Reference System:");
 
562
    myMetadataQString += "</td></tr>";  
 
563
    myMetadataQString += "<tr><td bgcolor=\"white\">";
 
564
    myMetadataQString += coordinateTransform->sourceSRS().proj4String().replace(QRegExp("\"")," \"");                       
 
565
    myMetadataQString += "</td></tr>";
 
566
 
 
567
    // 
 
568
    // Display project (output) spatial ref system
 
569
    //  
 
570
    myMetadataQString += "<tr><td bgcolor=\"gray\">";
 
571
    myMetadataQString += tr("Project (Output) Spatial Reference System:");
 
572
    myMetadataQString += "</td></tr>";  
 
573
    myMetadataQString += "<tr><td bgcolor=\"white\">";
 
574
    myMetadataQString += coordinateTransform->destSRS().proj4String().replace(QRegExp("\"")," \"");                       
 
575
    myMetadataQString += "</td></tr>";
 
576
 
 
577
  }
 
578
  catch(QgsCsException &cse)
 
579
  {
 
580
    QgsDebug( cse.what() );
 
581
 
 
582
    myMetadataQString += "<tr><td bgcolor=\"white\">";
 
583
    myMetadataQString += tr("In project spatial reference system units : ");
 
584
    myMetadataQString += " (Invalid transformation of layer extents) ";
 
585
    myMetadataQString += "</td></tr>";
 
586
 
 
587
  }
 
588
 
 
589
      
 
590
  //
 
591
  // Add the info about each field in the attribute table
 
592
  //
 
593
  myMetadataQString += "<tr><td bgcolor=\"gray\">";
 
594
  myMetadataQString += tr("Attribute field info:");
 
595
  myMetadataQString += "</td></tr>";
 
596
  myMetadataQString += "<tr><td bgcolor=\"white\">";
 
597
 
 
598
  // Start a nested table in this trow
 
599
  myMetadataQString += "<table width=\"100%\">";
 
600
  myMetadataQString += "<tr><th bgcolor=\"black\">";
 
601
  myMetadataQString += "<font color=\"white\">" + tr("Field") + "</font>";
 
602
  myMetadataQString += "</th>";
 
603
  myMetadataQString += "<th bgcolor=\"black\">";
 
604
  myMetadataQString += "<font color=\"white\">" + tr("Type") + "</font>";
 
605
  myMetadataQString += "</th>";
 
606
  myMetadataQString += "<th bgcolor=\"black\">";
 
607
  myMetadataQString += "<font color=\"white\">" + tr("Length") + "</font>";
 
608
  myMetadataQString += "</th>";
 
609
  myMetadataQString += "<th bgcolor=\"black\">";
 
610
  myMetadataQString += "<font color=\"white\">" + tr("Precision") + "</font>";
 
611
  myMetadataQString += "</th>";      
 
612
  myMetadataQString += "<tr>";
 
613
 
 
614
  //get info for each field by looping through them
 
615
  QgsVectorDataProvider *myDataProvider = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
 
616
  std::vector<QgsField> myFields = myDataProvider->fields();
 
617
  for (int i = 0; i < myFields.size(); i++)
 
618
  {
 
619
 
 
620
    QgsField myField = myFields[i];
 
621
    
 
622
    myMetadataQString += "<tr><td bgcolor=\"white\">";
 
623
    myMetadataQString += myField.name();
 
624
    myMetadataQString += "</td>";
 
625
    myMetadataQString += "<td bgcolor=\"white\">";
 
626
    myMetadataQString += myField.type();
 
627
    myMetadataQString += "</td>";
 
628
    myMetadataQString += "<td bgcolor=\"white\">";
 
629
    myMetadataQString += QString("%1").arg(myField.length());
 
630
    myMetadataQString += "</td>";
 
631
    myMetadataQString += "<td bgcolor=\"white\">";
 
632
    myMetadataQString += QString("%1").arg(myField.precision());
 
633
    myMetadataQString += "</td></tr>";
 
634
  } 
 
635
 
 
636
  //close field list
 
637
  myMetadataQString += "</table>"; //end of nested table
 
638
  myMetadataQString += "</td></tr>"; //end of stats container table row
 
639
  //
 
640
  // Close the table
 
641
  //
 
642
 
 
643
  myMetadataQString += "</table>";
 
644
  myMetadataQString += "</body></html>";
 
645
  return myMetadataQString;
 
646
 
 
647
}
 
648
 
 
649
 
 
650
 
 
651
void QgsDlgVectorLayerProperties::pbnChangeSpatialRefSys_clicked()
 
652
{
 
653
    
 
654
 
 
655
    QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this);
 
656
    long myDefaultSRS =layer->coordinateTransform()->sourceSRS().srsid();
 
657
    if (myDefaultSRS==0)
 
658
    {
 
659
      myDefaultSRS=QgsProject::instance()->readNumEntry("SpatialRefSys","/ProjectSRSID",GEOSRS_ID);
 
660
    }
 
661
    mySelector->setSelectedSRSID(myDefaultSRS);
 
662
    if(mySelector->exec())
 
663
    {
 
664
      layer->coordinateTransform()->sourceSRS().createFromSrsId(mySelector->getCurrentSRSID());
 
665
      layer->coordinateTransform()->initialise();
 
666
    }
 
667
    else
 
668
    {
 
669
      QApplication::restoreOverrideCursor();
 
670
    }
 
671
    delete mySelector;
 
672
    leSpatialRefSys->setText(layer->coordinateTransform()->sourceSRS().proj4String());
 
673
}