qgis_qml_version.diff

Tim Sutton, 2007-11-30 09:36 AM

Download (137 KB)

View differences:

src/app/qgssinglesymboldialog.h (working copy)
58 58
    void apply( QgsSymbol *sy);
59 59
    /**emits the signal settingsChanged()*/
60 60
    void resendSettingsChanged();
61
    /**changes the texture selection button to enabled or
62
     * disabled depending if the texture entry in the combo 
63
     */
64
    void fillStyleChanged( int theIndex );
61 65

  
62 66
protected slots:
63 67
    void selectOutlineColor();
64 68
    void selectFillColor();
65
	void selectTextureImage();
66

  
69
    void selectTextureImage();
70
    void symbolChanged ( QListWidgetItem * current, QListWidgetItem * previous );
67 71
private:
68 72
    /** Default constructor is private, do not use this */
69 73
    QgsSingleSymbolDialog();
74
    QString mTexturePath;
70 75

  
71
    /** vector of marker names for combo items */
72
    std::vector<QString> mMarkers;
73

  
74 76
signals:
75 77
    void settingsChanged();
76 78
};
src/app/qgsvectorlayerproperties.h (working copy)
63 63
  void on_pbnQueryBuilder_clicked();
64 64
  void on_pbnIndex_clicked();
65 65
  void on_pbnChangeSpatialRefSys_clicked();
66
  void on_pbnLoadDefaultStyle_clicked();
67
  void on_pbnSaveDefaultStyle_clicked();
68
  void on_pbnLoadStyle_clicked();
69
  void on_pbnSaveStyleAs_clicked();
66 70
  
67 71
  signals:
68 72
    
src/app/qgsvectorlayerproperties.cpp (working copy)
17 17
 ***************************************************************************/
18 18
 /* $Id$ */
19 19

  
20
#include "qgsvectorlayerproperties.h"
21 20

  
22 21
#include "qgsattributeactiondialog.h"
23 22
#include "qgscontexthelp.h"
24 23
#include "qgscontinuouscolordialog.h"
25 24
#include "qgscoordinatetransform.h"
26 25
#include "qgsgraduatedsymboldialog.h"
26
#include "qgslabeldialog.h"
27 27
#include "qgslabel.h"
28
#include "qgslabeldialog.h"
29 28
#include "qgslayerprojectionselector.h"
30 29
#include "qgslogger.h"
31 30
#include "qgssinglesymboldialog.h"
32 31
#include "qgsuniquevaluedialog.h"
33 32
#include "qgsvectordataprovider.h"
34 33
#include "qgsvectorlayer.h"
34
#include "qgsvectorlayerproperties.h"
35
#include "qgsconfig.h"
35 36

  
36
#include "qgsconfig.h"
37 37
#ifdef HAVE_POSTGRESQL
38 38
#include "qgspgquerybuilder.h"
39 39
#include "../providers/postgres/qgspostgresprovider.h"
40 40
#endif
41 41

  
42 42
#include <QMessageBox>
43
#include <QDir>
44
#include <QFile>
45
#include <QFileDialog>
46
#include <QFileInfo>
47
#include <QSettings>
43 48

  
44 49
QgsVectorLayerProperties::QgsVectorLayerProperties(QgsVectorLayer * lyr, 
45
                                                         QWidget * parent, 
46
                                                         Qt::WFlags fl)
50
    QWidget * parent, 
51
    Qt::WFlags fl)
47 52
: QDialog(parent, fl),
48
      layer(lyr), 
49
      mRendererDialog(0)
53
  layer(lyr), 
54
  mRendererDialog(0)
50 55
{
51 56
  setupUi(this);
52 57
  connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
......
61 66
  layout->addWidget( labelDialog );
62 67
  labelOptionsFrame->setLayout(layout);
63 68
  connect(labelDialog, SIGNAL(labelSourceSet()), 
64
          this, SLOT(setLabelCheckBox()));
69
      this, SLOT(setLabelCheckBox()));
65 70

  
66 71
  // Create the Actions dialog tab
67 72
  QgsVectorDataProvider *dp = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
......
69 74
  actionLayout->setMargin(0);
70 75
  QgsFieldMap fields = dp->fields();
71 76
  actionDialog = new QgsAttributeActionDialog ( layer->actions(), fields, 
72
                                                actionOptionsFrame );
77
      actionOptionsFrame );
73 78
  actionLayout->addWidget( actionDialog );
74 79

  
75 80
  reset();
76 81
  if(layer->getDataProvider())//enable spatial index button group if supported by provider
77 82
  {
78
      int capabilities=layer->getDataProvider()->capabilities();
79
      if(!(capabilities&QgsVectorDataProvider::CreateSpatialIndex))
80
      {
81
	  indexGroupBox->setEnabled(false);
82
      }
83
    int capabilities=layer->getDataProvider()->capabilities();
84
    if(!(capabilities&QgsVectorDataProvider::CreateSpatialIndex))
85
    {
86
      indexGroupBox->setEnabled(false);
87
    }
83 88
  }
84 89

  
85 90
  leSpatialRefSys->setText(layer->srs().proj4String());
86 91
  leSpatialRefSys->setCursorPosition(0);
87
  
92

  
88 93
  connect(sliderTransparency, SIGNAL(valueChanged(int)), this, SLOT(sliderTransparency_valueChanged(int)));
89 94

  
90 95
} // QgsVectorLayerProperties ctor
......
92 97
QgsVectorLayerProperties::~QgsVectorLayerProperties()
93 98
{
94 99
  disconnect(labelDialog, SIGNAL(labelSourceSet()), 
95
          this, SLOT(setLabelCheckBox()));  
100
      this, SLOT(setLabelCheckBox()));  
96 101
}
97 102
void QgsVectorLayerProperties::sliderTransparency_valueChanged(int theValue)
98 103
{
......
109 114
void QgsVectorLayerProperties::alterLayerDialog(const QString & dialogString)
110 115
{
111 116

  
112
    widgetStackRenderers->removeWidget(mRendererDialog);
113
    delete mRendererDialog;
114
    mRendererDialog=0;
115
    if(dialogString == tr("Single Symbol"))
116
    {
117
	mRendererDialog = new QgsSingleSymbolDialog(layer);
118
    }
119
    else if(dialogString == tr("Graduated Symbol"))
120
    {
121
	mRendererDialog = new QgsGraduatedSymbolDialog(layer);
122
    }
123
    else if(dialogString == tr("Continuous Color"))
124
    {
125
	mRendererDialog = new QgsContinuousColorDialog(layer);
126
    }
127
    else if(dialogString == tr("Unique Value"))
128
    {
129
	mRendererDialog = new QgsUniqueValueDialog(layer);
130
    }
131
    widgetStackRenderers->addWidget(mRendererDialog);
132
    widgetStackRenderers->setCurrentWidget(mRendererDialog);  
117
  widgetStackRenderers->removeWidget(mRendererDialog);
118
  delete mRendererDialog;
119
  mRendererDialog=0;
120
  if(dialogString == tr("Single Symbol"))
121
  {
122
    mRendererDialog = new QgsSingleSymbolDialog(layer);
123
  }
124
  else if(dialogString == tr("Graduated Symbol"))
125
  {
126
    mRendererDialog = new QgsGraduatedSymbolDialog(layer);
127
  }
128
  else if(dialogString == tr("Continuous Color"))
129
  {
130
    mRendererDialog = new QgsContinuousColorDialog(layer);
131
  }
132
  else if(dialogString == tr("Unique Value"))
133
  {
134
    mRendererDialog = new QgsUniqueValueDialog(layer);
135
  }
136
  widgetStackRenderers->addWidget(mRendererDialog);
137
  widgetStackRenderers->setCurrentWidget(mRendererDialog);  
133 138
}
134 139

  
135 140
void QgsVectorLayerProperties::setLegendType(QString type)
......
147 152
{
148 153
  // populate the general information
149 154
  txtDisplayName->setText(layer->name());
150
  pbnQueryBuilder->setWhatsThis(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"));
151
  txtSubsetSQL->setWhatsThis(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"));
155
  pbnQueryBuilder->setWhatsThis(tr("This button opens the PostgreSQL query "
156
        "builder and allows you to create a subset of features to display on "
157
        "the map canvas rather than displaying all features in the layer"));
158
  txtSubsetSQL->setWhatsThis(tr("The query used to limit the features in the "
159
        "layer is shown here. This is currently only supported for PostgreSQL "
160
        "layers. To enter or modify the query, click on the Query Builder button"));
152 161

  
153 162
  //we are dealing with a pg layer here so that we can enable the sql box
154 163
  QgsVectorDataProvider *dp = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
......
184 193

  
185 194
  // symbology initialization
186 195
  if(legendtypecombobox->count()==0)
196
  {
197
    legendtypecombobox->insertItem(tr("Single Symbol"));
198
    if(myFields.size()>0)
187 199
    {
188
      legendtypecombobox->insertItem(tr("Single Symbol"));
189
      if(myFields.size()>0)
190
      {
191
	  legendtypecombobox->insertItem(tr("Graduated Symbol"));
192
	  legendtypecombobox->insertItem(tr("Continuous Color"));
193
	  legendtypecombobox->insertItem(tr("Unique Value"));
194
      }
200
      legendtypecombobox->insertItem(tr("Graduated Symbol"));
201
      legendtypecombobox->insertItem(tr("Continuous Color"));
202
      legendtypecombobox->insertItem(tr("Unique Value"));
195 203
    }
204
  }
196 205

  
197 206
  //find out the type of renderer in the vectorlayer, create a dialog with these settings and add it to the form
198 207
  delete mRendererDialog;
......
200 209
  QString rtype=layer->renderer()->name();
201 210
  if(rtype=="Single Symbol")
202 211
  {
203
      mRendererDialog=new QgsSingleSymbolDialog(layer);
204
      legendtypecombobox->setCurrentIndex(0);
212
    mRendererDialog=new QgsSingleSymbolDialog(layer);
213
    legendtypecombobox->setCurrentIndex(0);
205 214
  }
206 215
  else if(rtype=="Graduated Symbol")
207 216
  {
208
      mRendererDialog=new QgsGraduatedSymbolDialog(layer);
209
      legendtypecombobox->setCurrentIndex(1);
217
    mRendererDialog=new QgsGraduatedSymbolDialog(layer);
218
    legendtypecombobox->setCurrentIndex(1);
210 219
  }
211 220
  else if(rtype=="Continuous Color")
212 221
  {
213
      mRendererDialog=new QgsContinuousColorDialog(layer);
214
      legendtypecombobox->setCurrentIndex(2);
222
    mRendererDialog=new QgsContinuousColorDialog(layer);
223
    legendtypecombobox->setCurrentIndex(2);
215 224
  }
216 225
  else if(rtype == "Unique Value")
217 226
  {
218
      mRendererDialog=new QgsUniqueValueDialog(layer);
219
      legendtypecombobox->setCurrentIndex(3);
227
    mRendererDialog=new QgsUniqueValueDialog(layer);
228
    legendtypecombobox->setCurrentIndex(3);
220 229
  }
221
  
230

  
222 231
  if(mRendererDialog)
223 232
  {
224
      widgetStackRenderers->addWidget(mRendererDialog);
225
      widgetStackRenderers->setCurrentWidget(mRendererDialog);
233
    widgetStackRenderers->addWidget(mRendererDialog);
234
    widgetStackRenderers->setCurrentWidget(mRendererDialog);
226 235
  }
227
  
228 236

  
229
  QObject::connect(legendtypecombobox, SIGNAL(activated(const QString &)), this, SLOT(alterLayerDialog(const QString &)));
230 237

  
238
  QObject::connect(legendtypecombobox, SIGNAL(activated(const QString &)), this, 
239
      SLOT(alterLayerDialog(const QString &)));
240

  
231 241
  // reset fields in label dialog
232 242
  layer->label()->setFields ( layer->getDataProvider()->fields() );
233
  
243

  
234 244
  //set the metadata contents
235 245
  teMetadata->setText(getMetadata());
236 246
  actionDialog->init();
......
259 269
  // Set up sql subset query if applicable
260 270
  //
261 271
#ifdef HAVE_POSTGRESQL
262
  // Tim commented out the next line because dp is not actually used anywhere....
263
  //QgsVectorDataProvider *dp = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
264 272
  //see if we are dealing with a pg layer here
265 273
  if(layer->providerType() == "postgres")
266 274
  {
......
288 296
  layer->setLayerName(displayName());
289 297

  
290 298

  
291
  QgsSingleSymbolDialog *sdialog = dynamic_cast < QgsSingleSymbolDialog * >(widgetStackRenderers->currentWidget());
292
  QgsGraduatedSymbolDialog *gdialog = dynamic_cast < QgsGraduatedSymbolDialog * >(widgetStackRenderers->currentWidget());
293
  QgsContinuousColorDialog *cdialog = dynamic_cast < QgsContinuousColorDialog * >(widgetStackRenderers->currentWidget());
294
  QgsUniqueValueDialog* udialog = dynamic_cast< QgsUniqueValueDialog * >(widgetStackRenderers->currentWidget()); 
299
  QgsSingleSymbolDialog *sdialog = 
300
    dynamic_cast < QgsSingleSymbolDialog * >(widgetStackRenderers->currentWidget());
301
  QgsGraduatedSymbolDialog *gdialog = 
302
    dynamic_cast < QgsGraduatedSymbolDialog * >(widgetStackRenderers->currentWidget());
303
  QgsContinuousColorDialog *cdialog = 
304
    dynamic_cast < QgsContinuousColorDialog * >(widgetStackRenderers->currentWidget());
305
  QgsUniqueValueDialog* udialog = 
306
    dynamic_cast< QgsUniqueValueDialog * >(widgetStackRenderers->currentWidget()); 
295 307

  
296 308
  if (sdialog)
297
    {
298
      sdialog->apply();
299
    } 
309
  {
310
    sdialog->apply();
311
  } 
300 312
  else if (gdialog)
301 313
  {
302
      gdialog->apply();
314
    gdialog->apply();
303 315
  }
304 316
  else if (cdialog)
305
    {
306
      cdialog->apply();
307
    }
317
  {
318
    cdialog->apply();
319
  }
308 320
  else if(udialog)
309 321
  {
310
      udialog->apply();
322
    udialog->apply();
311 323
  }
312 324
  layer->setTransparency(static_cast < unsigned int >(255 - sliderTransparency->value()));
313
  
325

  
314 326
  // update symbology
315 327
  emit refreshLegend(layer->getLayerID(), false);
316
  
328

  
317 329
  layer->triggerRepaint();
318 330

  
319 331
}
......
333 345
  // and postgres connection from the provider
334 346
  QgsDataSourceURI uri(myPGProvider->dataSourceUri());
335 347
  QgsPgQueryBuilder *pqb = new QgsPgQueryBuilder(&uri, this);
336
       
348

  
337 349
  // Set the sql in the query builder to the same in the prop dialog
338 350
  // (in case the user has already changed it)
339 351
  pqb->setSql(txtSubsetSQL->text());
......
355 367

  
356 368
void QgsVectorLayerProperties::on_pbnIndex_clicked()
357 369
{
358
    QgsVectorDataProvider* pr=layer->getDataProvider();
359
    if(pr)
370
  QgsVectorDataProvider* pr=layer->getDataProvider();
371
  if(pr)
372
  {
373
    setCursor(Qt::WaitCursor);
374
    bool errval=pr->createSpatialIndex();
375
    setCursor(Qt::ArrowCursor);
376
    if(errval)
360 377
    {
361
	setCursor(Qt::WaitCursor);
362
	bool errval=pr->createSpatialIndex();
363
	setCursor(Qt::ArrowCursor);
364
	if(errval)
365
	{
366
	    QMessageBox::information(this, tr("Spatial Index"), tr("Creation of spatial index successfull"));
367
	}
368
	else
369
	{
370
           // TODO: Remind the user to use OGR >= 1.2.6 and Shapefile
371
	   QMessageBox::information(this, tr("Spatial Index"), tr("Creation of spatial index failed")); 
372
	}
378
      QMessageBox::information(this, tr("Spatial Index"), 
379
          tr("Creation of spatial index successfull"));
373 380
    }
381
    else
382
    {
383
      // TODO: Remind the user to use OGR >= 1.2.6 and Shapefile
384
      QMessageBox::information(this, tr("Spatial Index"), tr("Creation of spatial index failed")); 
385
    }
386
  }
374 387
}
375 388

  
376 389
QString QgsVectorLayerProperties::getMetadata()
377 390
{
378
  QString myMetadataQString = "<html><body>";
379
  myMetadataQString += "<table width=\"100%\">";
380
  
391
  QString myMetedata = "<html><body>";
392
  myMetedata += "<table width=\"100%\">";
393

  
381 394
  //-------------
382
  
383
  myMetadataQString += "<tr><td bgcolor=\"gray\">";
384
  myMetadataQString += tr("General:");
385
  myMetadataQString += "</td></tr>";
386 395

  
396
  myMetedata += "<tr><td bgcolor=\"gray\">";
397
  myMetedata += tr("General:");
398
  myMetedata += "</td></tr>";
399

  
387 400
  // data comment
388 401
  if (!(layer->dataComment().isEmpty()))
389 402
  {
390
    myMetadataQString += "<tr><td bgcolor=\"white\">";
391
    myMetadataQString += tr("Layer comment: ") + 
392
        layer->dataComment();
393
    myMetadataQString += "</td></tr>";
403
    myMetedata += "<tr><td bgcolor=\"white\">";
404
    myMetedata += tr("Layer comment: ") + 
405
      layer->dataComment();
406
    myMetedata += "</td></tr>";
394 407
  }
395 408

  
396 409
  //storage type
397
  myMetadataQString += "<tr><td bgcolor=\"white\">";
398
  myMetadataQString += tr("Storage type of this layer : ") + 
399
                       layer->storageType();
400
  myMetadataQString += "</td></tr>";
410
  myMetedata += "<tr><td bgcolor=\"white\">";
411
  myMetedata += tr("Storage type of this layer : ") + 
412
    layer->storageType();
413
  myMetedata += "</td></tr>";
401 414

  
402 415
  // data source
403
  myMetadataQString += "<tr><td bgcolor=\"white\">";
404
  myMetadataQString += tr("Source for this layer : ") +
405
                       layer->publicSource();
406
  myMetadataQString += "</td></tr>";
416
  myMetedata += "<tr><td bgcolor=\"white\">";
417
  myMetedata += tr("Source for this layer : ") +
418
    layer->publicSource();
419
  myMetedata += "</td></tr>";
407 420

  
408 421
  //geom type
409 422

  
......
411 424

  
412 425
  if ( vectorType < 0 || vectorType > QGis::Polygon )
413 426
  {
414
      QgsDebugMsg( "Invalid vector type" );
427
    QgsDebugMsg( "Invalid vector type" );
415 428
  }
416 429
  else
417 430
  {
418
      QString vectorTypeString( QGis::qgisVectorGeometryType[layer->vectorType()] );
431
    QString vectorTypeString( QGis::qgisVectorGeometryType[layer->vectorType()] );
419 432

  
420
      myMetadataQString += "<tr><td bgcolor=\"white\">";
421
      myMetadataQString += tr("Geometry type of the features in this layer : ") + 
422
          vectorTypeString;
423
      myMetadataQString += "</td></tr>";
433
    myMetedata += "<tr><td bgcolor=\"white\">";
434
    myMetedata += tr("Geometry type of the features in this layer : ") + 
435
      vectorTypeString;
436
    myMetedata += "</td></tr>";
424 437
  }
425 438

  
426 439

  
427
      //feature count
428
  myMetadataQString += "<tr><td bgcolor=\"white\">";
429
  myMetadataQString += tr("The number of features in this layer : ") + 
430
                       QString::number(layer->featureCount());
431
  myMetadataQString += "</td></tr>";
440
  //feature count
441
  myMetedata += "<tr><td bgcolor=\"white\">";
442
  myMetedata += tr("The number of features in this layer : ") + 
443
    QString::number(layer->featureCount());
444
  myMetedata += "</td></tr>";
432 445
  //capabilities
433
  myMetadataQString += "<tr><td bgcolor=\"white\">";
434
  myMetadataQString += tr("Editing capabilities of this layer : ") + 
435
                       layer->capabilitiesString();
436
  myMetadataQString += "</td></tr>";
446
  myMetedata += "<tr><td bgcolor=\"white\">";
447
  myMetedata += tr("Editing capabilities of this layer : ") + 
448
    layer->capabilitiesString();
449
  myMetedata += "</td></tr>";
437 450

  
438 451
  //-------------
439 452

  
440 453
  QgsRect myExtent = layer->extent();  
441
  myMetadataQString += "<tr><td bgcolor=\"gray\">";
442
  myMetadataQString += tr("Extents:");
443
  myMetadataQString += "</td></tr>";
454
  myMetedata += "<tr><td bgcolor=\"gray\">";
455
  myMetedata += tr("Extents:");
456
  myMetedata += "</td></tr>";
444 457
  //extents in layer cs  TODO...maybe make a little nested table to improve layout...
445
  myMetadataQString += "<tr><td bgcolor=\"white\">";
446
  myMetadataQString += tr("In layer spatial reference system units : ") + 
447
                       tr("xMin,yMin ") + 
448
                       QString::number(myExtent.xMin()) + 
449
                       "," + 
450
                       QString::number( myExtent.yMin()) +
451
                       tr(" : xMax,yMax ") + 
452
                       QString::number(myExtent.xMax()) + 
453
                       "," + 
454
                       QString::number(myExtent.yMax());
455
  myMetadataQString += "</td></tr>";
458
  myMetedata += "<tr><td bgcolor=\"white\">";
459
  myMetedata += tr("In layer spatial reference system units : ") + 
460
    tr("xMin,yMin ") + 
461
    QString::number(myExtent.xMin()) + 
462
    "," + 
463
    QString::number( myExtent.yMin()) +
464
    tr(" : xMax,yMax ") + 
465
    QString::number(myExtent.xMax()) + 
466
    "," + 
467
    QString::number(myExtent.yMax());
468
  myMetedata += "</td></tr>";
456 469

  
457 470
  //extents in project cs
458 471

  
......
461 474
    /*    
462 475
    // TODO: currently disabled, will revisit later [MD]
463 476
    QgsRect myProjectedExtent = coordinateTransform->transformBoundingBox(layer->extent());
464
    myMetadataQString += "<tr><td bgcolor=\"white\">";
465
    myMetadataQString += tr("In project spatial reference system units : ") + 
466
                         tr("xMin,yMin ") + 
467
                         QString::number(myProjectedExtent.xMin()) + 
468
                         "," + 
469
                         QString::number( myProjectedExtent.yMin()) +
470
                         tr(" : xMax,yMax ") + 
471
                         QString::number(myProjectedExtent.xMax()) + 
472
                         "," + 
473
                         QString::number(myProjectedExtent.yMax());
474
    myMetadataQString += "</td></tr>";
477
    myMetedata += "<tr><td bgcolor=\"white\">";
478
    myMetedata += tr("In project spatial reference system units : ") + 
479
    tr("xMin,yMin ") + 
480
    QString::number(myProjectedExtent.xMin()) + 
481
    "," + 
482
    QString::number( myProjectedExtent.yMin()) +
483
    tr(" : xMax,yMax ") + 
484
    QString::number(myProjectedExtent.xMax()) + 
485
    "," + 
486
    QString::number(myProjectedExtent.yMax());
487
    myMetedata += "</td></tr>";
475 488
    */
476 489

  
477 490
    // 
478 491
    // Display layer spatial ref system
479 492
    //
480
    myMetadataQString += "<tr><td bgcolor=\"gray\">";
481
    myMetadataQString += tr("Layer Spatial Reference System:");
482
    myMetadataQString += "</td></tr>";  
483
    myMetadataQString += "<tr><td bgcolor=\"white\">";
484
    myMetadataQString += layer->srs().proj4String().replace(QRegExp("\"")," \"");                       
485
    myMetadataQString += "</td></tr>";
493
    myMetedata += "<tr><td bgcolor=\"gray\">";
494
    myMetedata += tr("Layer Spatial Reference System:");
495
    myMetedata += "</td></tr>";  
496
    myMetedata += "<tr><td bgcolor=\"white\">";
497
    myMetedata += layer->srs().proj4String().replace(QRegExp("\"")," \"");                       
498
    myMetedata += "</td></tr>";
486 499

  
487 500
    // 
488 501
    // Display project (output) spatial ref system
489 502
    //  
490 503
    /*
491 504
    // TODO: disabled for now, will revisit later [MD]
492
    myMetadataQString += "<tr><td bgcolor=\"gray\">";
493
    myMetadataQString += tr("Project (Output) Spatial Reference System:");
494
    myMetadataQString += "</td></tr>";  
495
    myMetadataQString += "<tr><td bgcolor=\"white\">";
496
    myMetadataQString += coordinateTransform->destSRS().proj4String().replace(QRegExp("\"")," \"");                       
497
    myMetadataQString += "</td></tr>";
505
    myMetedata += "<tr><td bgcolor=\"gray\">";
506
    myMetedata += tr("Project (Output) Spatial Reference System:");
507
    myMetedata += "</td></tr>";  
508
    myMetedata += "<tr><td bgcolor=\"white\">";
509
    myMetedata += coordinateTransform->destSRS().proj4String().replace(QRegExp("\"")," \"");                       
510
    myMetedata += "</td></tr>";
498 511
    */
499 512

  
500 513
  }
......
503 516
    UNUSED(cse);
504 517
    QgsDebugMsg( cse.what() );
505 518

  
506
    myMetadataQString += "<tr><td bgcolor=\"white\">";
507
    myMetadataQString += tr("In project spatial reference system units : ");
508
    myMetadataQString += " (Invalid transformation of layer extents) ";
509
    myMetadataQString += "</td></tr>";
519
    myMetedata += "<tr><td bgcolor=\"white\">";
520
    myMetedata += tr("In project spatial reference system units : ");
521
    myMetedata += " (Invalid transformation of layer extents) ";
522
    myMetedata += "</td></tr>";
510 523

  
511 524
  }
512 525

  
513
      
526

  
514 527
  //
515 528
  // Add the info about each field in the attribute table
516 529
  //
517
  myMetadataQString += "<tr><td bgcolor=\"gray\">";
518
  myMetadataQString += tr("Attribute field info:");
519
  myMetadataQString += "</td></tr>";
520
  myMetadataQString += "<tr><td bgcolor=\"white\">";
530
  myMetedata += "<tr><td bgcolor=\"gray\">";
531
  myMetedata += tr("Attribute field info:");
532
  myMetedata += "</td></tr>";
533
  myMetedata += "<tr><td bgcolor=\"white\">";
521 534

  
522 535
  // Start a nested table in this trow
523
  myMetadataQString += "<table width=\"100%\">";
524
  myMetadataQString += "<tr><th bgcolor=\"black\">";
525
  myMetadataQString += "<font color=\"white\">" + tr("Field") + "</font>";
526
  myMetadataQString += "</th>";
527
  myMetadataQString += "<th bgcolor=\"black\">";
528
  myMetadataQString += "<font color=\"white\">" + tr("Type") + "</font>";
529
  myMetadataQString += "</th>";
530
  myMetadataQString += "<th bgcolor=\"black\">";
531
  myMetadataQString += "<font color=\"white\">" + tr("Length") + "</font>";
532
  myMetadataQString += "</th>";
533
  myMetadataQString += "<th bgcolor=\"black\">";
534
  myMetadataQString += "<font color=\"white\">" + tr("Precision") + "</font>";
535
  myMetadataQString += "</th>";      
536
  myMetadataQString += "<th bgcolor=\"black\">";
537
  myMetadataQString += "<font color=\"white\">" + tr("Comment") + "</font>";
538
  myMetadataQString += "</th>";
539
 
536
  myMetedata += "<table width=\"100%\">";
537
  myMetedata += "<tr><th bgcolor=\"black\">";
538
  myMetedata += "<font color=\"white\">" + tr("Field") + "</font>";
539
  myMetedata += "</th>";
540
  myMetedata += "<th bgcolor=\"black\">";
541
  myMetedata += "<font color=\"white\">" + tr("Type") + "</font>";
542
  myMetedata += "</th>";
543
  myMetedata += "<th bgcolor=\"black\">";
544
  myMetedata += "<font color=\"white\">" + tr("Length") + "</font>";
545
  myMetedata += "</th>";
546
  myMetedata += "<th bgcolor=\"black\">";
547
  myMetedata += "<font color=\"white\">" + tr("Precision") + "</font>";
548
  myMetedata += "</th>";      
549
  myMetedata += "<th bgcolor=\"black\">";
550
  myMetedata += "<font color=\"white\">" + tr("Comment") + "</font>";
551
  myMetedata += "</th>";
552

  
540 553
  //get info for each field by looping through them
541 554
  QgsVectorDataProvider *myDataProvider = dynamic_cast<QgsVectorDataProvider *>(layer->getDataProvider());
542 555
  const QgsFieldMap& myFields = myDataProvider->fields();
543 556
  for (QgsFieldMap::const_iterator it = myFields.begin(); it != myFields.end(); ++it)
544 557
  {
545 558
    const QgsField& myField = *it;
546
    
547
    myMetadataQString += "<tr><td bgcolor=\"white\">";
548
    myMetadataQString += myField.name();
549
    myMetadataQString += "</td>";
550
    myMetadataQString += "<td bgcolor=\"white\">";
551
    myMetadataQString += myField.typeName();
552
    myMetadataQString += "</td>";
553
    myMetadataQString += "<td bgcolor=\"white\">";
554
    myMetadataQString += QString("%1").arg(myField.length());
555
    myMetadataQString += "</td>";
556
    myMetadataQString += "<td bgcolor=\"white\">";
557
    myMetadataQString += QString("%1").arg(myField.precision());
558
    myMetadataQString += "</td>";
559
    myMetadataQString += "<td bgcolor=\"white\">";
560
    myMetadataQString += QString("%1").arg(myField.comment());
561
    myMetadataQString += "</td></tr>";
559

  
560
    myMetedata += "<tr><td bgcolor=\"white\">";
561
    myMetedata += myField.name();
562
    myMetedata += "</td>";
563
    myMetedata += "<td bgcolor=\"white\">";
564
    myMetedata += myField.typeName();
565
    myMetedata += "</td>";
566
    myMetedata += "<td bgcolor=\"white\">";
567
    myMetedata += QString("%1").arg(myField.length());
568
    myMetedata += "</td>";
569
    myMetedata += "<td bgcolor=\"white\">";
570
    myMetedata += QString("%1").arg(myField.precision());
571
    myMetedata += "</td>";
572
    myMetedata += "<td bgcolor=\"white\">";
573
    myMetedata += QString("%1").arg(myField.comment());
574
    myMetedata += "</td></tr>";
562 575
  } 
563 576

  
564 577
  //close field list
565
  myMetadataQString += "</table>"; //end of nested table
566
  myMetadataQString += "</td></tr>"; //end of stats container table row
578
  myMetedata += "</table>"; //end of nested table
579
  myMetedata += "</td></tr>"; //end of stats container table row
567 580
  //
568 581
  // Close the table
569 582
  //
570 583

  
571
  myMetadataQString += "</table>";
572
  myMetadataQString += "</body></html>";
573
  return myMetadataQString;
584
  myMetedata += "</table>";
585
  myMetedata += "</body></html>";
586
  return myMetedata;
574 587

  
575 588
}
576 589

  
......
578 591

  
579 592
void QgsVectorLayerProperties::on_pbnChangeSpatialRefSys_clicked()
580 593
{
581
    QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this);
582
    mySelector->setSelectedSRSID(layer->srs().srsid());
583
    if(mySelector->exec())
594
  QgsLayerProjectionSelector * mySelector = new QgsLayerProjectionSelector(this);
595
  mySelector->setSelectedSRSID(layer->srs().srsid());
596
  if(mySelector->exec())
597
  {
598
    QgsSpatialRefSys srs(mySelector->getCurrentSRSID(), QgsSpatialRefSys::QGIS_SRSID);
599
    layer->setSrs(srs);
600
  }
601
  else
602
  {
603
    QApplication::restoreOverrideCursor();
604
  }
605
  delete mySelector;
606

  
607
  leSpatialRefSys->setText(layer->srs().proj4String());
608
  leSpatialRefSys->setCursorPosition(0);
609
}
610

  
611
void QgsVectorLayerProperties::on_pbnLoadDefaultStyle_clicked()
612
{
613
  bool defaultLoadedFlag = false;
614
  QString myMessage = layer->loadDefaultStyle( defaultLoadedFlag );
615
  //reset if the default style was loaded ok only
616
  if ( defaultLoadedFlag )
617
  {
618
    reset ();
619
  }
620
  QMessageBox::information( this, 
621
      tr("Default Style"), 
622
      myMessage
623
      ); 
624
}
625

  
626
void QgsVectorLayerProperties::on_pbnSaveDefaultStyle_clicked()
627
{
628
  // a flag passed by reference
629
  bool defaultSavedFlag = false;
630
  // after calling this the above flag will be set true for success
631
  // or false if the save operation failed
632
  QString myMessage = layer->saveDefaultStyle( defaultSavedFlag );
633
  QMessageBox::information( this, 
634
      tr("Default Style"), 
635
      myMessage
636
      ); 
637
}
638

  
639

  
640
void QgsVectorLayerProperties::on_pbnLoadStyle_clicked()
641
{
642
  QSettings myQSettings;  // where we keep last used filter in persistant state
643
  QString myLastUsedDir = myQSettings.value ( "style/lastStyleDir", "." ).toString();
644

  
645
  //create a file dialog
646
  std::auto_ptr < QFileDialog > myFileDialog
647
    (
648
     new QFileDialog (
649
       this,
650
       QFileDialog::tr ( "Load layer properties from style file (.qml)" ),
651
       myLastUsedDir,
652
       tr ( "QGIS Layer Style File (*.qml)" )
653
       )
654
    );
655
  myFileDialog->setFileMode ( QFileDialog::AnyFile );
656
  myFileDialog->setAcceptMode ( QFileDialog::AcceptOpen );
657

  
658
  //prompt the user for a filename
659
  QString myFileName;
660
  if ( myFileDialog->exec() == QDialog::Accepted )
661
  {
662
    QStringList myFiles = myFileDialog->selectedFiles();
663
    if ( !myFiles.isEmpty() )
584 664
    {
585
      QgsSpatialRefSys srs(mySelector->getCurrentSRSID(), QgsSpatialRefSys::QGIS_SRSID);
586
      layer->setSrs(srs);
665
      myFileName = myFiles[0];
587 666
    }
667
  }
668

  
669
  if ( !myFileName.isEmpty() )
670
  {
671
    if ( myFileDialog->selectedFilter() == tr ( "QGIS Layer Style File (*.qml)" ) )
672
    {
673
      //ensure the user never ommitted the extension from the filename
674
      if ( !myFileName.toUpper().endsWith ( ".QML" ) )
675
      {
676
        myFileName += ".qml";
677
      }
678
      bool defaultLoadedFlag = false;
679
      QString myMessage = layer->loadNamedStyle( myFileName, defaultLoadedFlag );
680
      //reset if the default style was loaded ok only
681
      if ( defaultLoadedFlag )
682
      {
683
        reset ();
684
      }
685
      QMessageBox::information( this, 
686
          tr("Default Style"), 
687
          myMessage
688
          ); 
689
    }
588 690
    else
589 691
    {
590
      QApplication::restoreOverrideCursor();
692
      QMessageBox::warning ( this, tr ( "QGIS" ), tr ( "Unknown style format: " ) +
693
          myFileDialog->selectedFilter() );
694

  
591 695
    }
592
    delete mySelector;
696
    myQSettings.setValue ( "style/lastStyleDir", myFileDialog->directory().absolutePath() );
697
  }
698
}
593 699

  
594
    leSpatialRefSys->setText(layer->srs().proj4String());
595
    leSpatialRefSys->setCursorPosition(0);
700

  
701
void QgsVectorLayerProperties::on_pbnSaveStyleAs_clicked()
702
{
703

  
704
  QSettings myQSettings;  // where we keep last used filter in persistant state
705
  QString myLastUsedDir = myQSettings.value ( "style/lastStyleDir", "." ).toString();
706

  
707
  //create a file dialog
708
  std::auto_ptr < QFileDialog > myFileDialog
709
    (
710
     new QFileDialog (
711
       this,
712
       QFileDialog::tr ( "Save layer properties as style file (.qml)" ),
713
       myLastUsedDir,
714
       tr ( "QGIS Layer Style File (*.qml)" )
715
       )
716
    );
717
  myFileDialog->setFileMode ( QFileDialog::AnyFile );
718
  myFileDialog->setAcceptMode ( QFileDialog::AcceptSave );
719

  
720
  //prompt the user for a filename
721
  QString myOutputFileName;
722
  if ( myFileDialog->exec() == QDialog::Accepted )
723
  {
724
    QStringList myFiles = myFileDialog->selectedFiles();
725
    if ( !myFiles.isEmpty() )
726
    {
727
      myOutputFileName = myFiles[0];
728
    }
729
  }
730

  
731
  if ( !myOutputFileName.isEmpty() )
732
  {
733
    if ( myFileDialog->selectedFilter() == tr ( "QGIS Layer Style File (*.qml)" ) )
734
    {
735
      //ensure the user never ommitted the extension from the filename
736
      if ( !myOutputFileName.toUpper().endsWith ( ".QML" ) )
737
      {
738
        myOutputFileName += ".qml";
739
      }
740
      bool defaultLoadedFlag = false;
741
      QString myMessage = layer->saveNamedStyle( myOutputFileName, defaultLoadedFlag );
742
      //reset if the default style was loaded ok only
743
      if ( defaultLoadedFlag )
744
      {
745
        reset ();
746
      }
747
      QMessageBox::information( this, 
748
          tr("Default Style"), 
749
          myMessage
750
          ); 
751
    }
752
    else
753
    {
754
      QMessageBox::warning ( this, tr ( "QGIS" ), tr ( "Unknown style format: " ) +
755
          myFileDialog->selectedFilter() );
756

  
757
    }
758
    myQSettings.setValue ( "style/lastStyleDir", myFileDialog->directory().absolutePath() );
759
  }
596 760
}
src/app/qgssinglesymboldialog.cpp (working copy)
27 27
#include <QPainter>
28 28
#include <QImage>
29 29
#include <QFileDialog>
30
#include <QListWidgetItem>
30 31

  
31 32

  
32 33
QgsSingleSymbolDialog::QgsSingleSymbolDialog(): QDialog(), mVectorLayer(0)
......
39 40

  
40 41
QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer * layer): QDialog(), mVectorLayer(layer)
41 42
{
42
    setupUi(this);
43
  setupUi(this);
43 44

  
44 45
#ifdef QGISDEBUG
45
    qWarning("constructor QgsSingleSymbolDialog called WITH a layer");
46
  qWarning("constructor QgsSingleSymbolDialog called WITH a layer");
46 47
#endif
47 48

  
48
    //
49
    //set point symbol combo box
50
    //
49
  //
50
  //set point symbol list
51
  //
51 52

  
52
    // If this layer doesn't have points, break out of the following
53
    // two loops after the first iteration. This gives one point
54
    // symbol in the dialog, etc so that other code can rely on such a
55
    // fact, but avoids the long time required to load all of the
56
    // available symbols when they are not needed.
53
  // If this layer doesn't have points, break out of the following
54
  // two loops after the first iteration. This gives one point
55
  // symbol in the dialog, etc so that other code can rely on such a
56
  // fact, but avoids the long time required to load all of the
57
  // available symbols when they are not needed.
57 58

  
58
    QStringList ml = QgsMarkerCatalogue::instance()->list();
59
    mMarkers.clear();
59
  // NOTE BY Tim: I think the note above and the break out in the 
60
  // loops can be removed now with changes I have made to use combo
61
  // boxes for line style and fill style...test and remove if poss.
60 62

  
61
    int size = 18;
62
    QPen pen (QColor(0,0,255));
63
    QBrush brush ( QColor(220,220,220), Qt::SolidPattern );
64 63

  
65
    
66
    for ( QStringList::iterator it = ml.begin(); it != ml.end(); ++it ) 
64
  QPen pen (QColor(0,0,255));
65
  QBrush brush ( QColor(220,220,220), Qt::SolidPattern );
66
  int size = 18;
67
  int myCounter = 0;
68
  QStringList ml = QgsMarkerCatalogue::instance()->list();
69
  for ( QStringList::iterator it = ml.begin(); it != ml.end(); ++it ) 
70
  {
71
    QPixmap myPixmap = QPixmap::fromImage(QgsMarkerCatalogue::instance()->imageMarker ( *it, size, pen, brush ));
72
    QListWidgetItem * mypItem = new QListWidgetItem(lstSymbols);
73
    QIcon myIcon;
74
    myIcon.addPixmap ( myPixmap );
75
    mypItem->setIcon ( myIcon );
76
    mypItem->setText ( "" );
77
    //store the symbol offset in the UserData role for later retrieval
78
    mypItem->setData ( Qt::UserRole, *it);
79
    if (layer->vectorType() != QGis::Point)
67 80
    {
68
      mMarkers.push_back ( *it );
69
      QPixmap pic = QPixmap::fromImage(QgsMarkerCatalogue::instance()->imageMarker ( *it, size, pen, brush ));
70
      mPointSymbolComboBox->insertItem ( pic );
71
      if (layer->vectorType() != QGis::Point)
72
      {
73
        break;
74
      }
81
      break;
75 82
    }
83
    ++myCounter;
84
  }
76 85

  
77
    //
78
    //set outline / line style
79
    //
80
    pbnLineSolid->setPixmap(QgsSymbologyUtils::char2LinePixmap("SolidLine"));
81
    pbnLineDash->setPixmap(QgsSymbologyUtils::char2LinePixmap("DashLine"));
82
    pbnLineDot->setPixmap(QgsSymbologyUtils::char2LinePixmap("DotLine"));
83
    pbnLineDashDot->setPixmap(QgsSymbologyUtils::char2LinePixmap("DashDotLine"));
84
    pbnLineDashDotDot->setPixmap(QgsSymbologyUtils::char2LinePixmap("DashDotDotLine"));
85
    pbnLineNoPen->setPixmap(QgsSymbologyUtils::char2LinePixmap("NoPen"));
86
  //
87
  //set outline / line style
88
  //
89
  cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("SolidLine")),tr("Solid Line"),"SolidLine");
90
  cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("DashLine")),tr("Dash Line"),"DashLine");
91
  cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("DotLine")),tr("Dot Line"),"DotLine");
92
  cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("DashDotLine")),tr("Dash Dot Line"),"DashDotLine");
93
  cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("DashDotDotLine")),tr("Dash Dot Dot Line"),"DashDotDotLine");
94
  cboOutlineStyle->addItem(QIcon(QgsSymbologyUtils::char2LinePixmap("NoPen")),tr("No Pen"),"NoPen");
86 95

  
87
    //
88
    //set pattern button group icons and state
89
    //
90
    solid->setPixmap(QgsSymbologyUtils::char2PatternPixmap("SolidPattern"));
91
    horizontal->setPixmap(QgsSymbologyUtils::char2PatternPixmap("HorPattern"));
92
    vertical->setPixmap(QgsSymbologyUtils::char2PatternPixmap("VerPattern"));
93
    cross->setPixmap(QgsSymbologyUtils::char2PatternPixmap("CrossPattern"));
94
    bdiag->setPixmap(QgsSymbologyUtils::char2PatternPixmap("BDiagPattern"));
95
    fdiag->setPixmap(QgsSymbologyUtils::char2PatternPixmap("FDiagPattern"));
96
    diagcross->setPixmap(QgsSymbologyUtils::char2PatternPixmap("DiagCrossPattern"));
97
    dense1->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense1Pattern"));
98
    dense2->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense2Pattern"));
99
    dense3->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense3Pattern"));
100
    dense4->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense4Pattern"));
101
    dense5->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense5Pattern"));
102
    dense6->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense6Pattern"));
103
    dense7->setPixmap(QgsSymbologyUtils::char2PatternPixmap("Dense7Pattern"));
104
    nopen->setPixmap(QgsSymbologyUtils::char2PatternPixmap("NoBrush"));
105
	texture->setPixmap(QgsSymbologyUtils::char2PatternPixmap("TexturePattern"));
96
  //
97
  //set pattern icons and state
98
  //
99
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("SolidPattern")),tr("Solid Pattern"),"SolidPattern");
100
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("HorPattern")),tr("Hor Pattern"),"HorPattern");
101
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("VerPattern")),tr("Ver Pattern"),"VerPattern");
102
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("CrossPattern")),tr("Cross Pattern"),"CrossPattern");
103
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("BDiagPattern")),tr("BDiag Pattern"),"BDiagPattern");
104
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("FDiagPattern")),tr("FDiag Pattern"),"FDiagPattern");
105
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("DiagCrossPattern")),tr("Diag Cross Pattern"),"DiagCrossPattern");
106
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense1Pattern")),tr("Dense1 Pattern"),"Dense1Pattern");
107
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense2Pattern")),tr("Dense2 Pattern"),"Dense2Pattern");
108
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense3Pattern")),tr("Dense3 Pattern"),"Dense3Pattern");
109
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense4Pattern")),tr("Dense4 Pattern"),"Dense4Pattern");
110
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense5Pattern")),tr("Dense5 Pattern"),"Dense5Pattern");
111
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense6Pattern")),tr("Dense6 Pattern"),"Dense6Pattern");
112
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("Dense7Pattern")),tr("Dense7 Pattern"),"Dense7Pattern");
113
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("NoBrush")),tr("No Brush"),"NoBrush");
114
  cboFillStyle->addItem(QIcon(QgsSymbologyUtils::char2PatternPixmap("TexturePattern")),tr("Texture Pattern"),"TexturePattern");
106 115

  
116
  if (mVectorLayer)
117
  {
118
    const QgsSingleSymbolRenderer *renderer=dynamic_cast<const QgsSingleSymbolRenderer*>(mVectorLayer->renderer());
107 119

  
108
    if (mVectorLayer)
120
    if (renderer)
109 121
    {
110
        const QgsSingleSymbolRenderer *renderer=dynamic_cast<const QgsSingleSymbolRenderer*>(mVectorLayer->renderer());
111

  
112
        if (renderer)
113
        {
114
	      // Set from the existing renderer
115
	      set ( renderer->symbol() );
116
	    }
117
        else
118
        {
119
            // Take values from an example instance
120
            QgsSingleSymbolRenderer exampleRenderer = QgsSingleSymbolRenderer( mVectorLayer->vectorType() );
121
            set ( exampleRenderer.symbol() );
122
        }
123

  
124
        if (mVectorLayer && mVectorLayer->vectorType() == QGis::Line)
125
        {
126
            btnFillColor->setEnabled(false);
127
            grpPattern->setEnabled(false);
128
            mGroupPoint->setEnabled(false);
129
        }
130
	
131
        if (mVectorLayer && mVectorLayer->vectorType() == QGis::Polygon) {
132
            mGroupPoint->setEnabled(false);
133

  
134
        }
135
       
122
      // Set from the existing renderer
123
      set ( renderer->symbol() );
136 124
    }
137 125
    else
138 126
    {
139
        qWarning("Warning, layer is a null pointer in QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer)");
127
      // Take values from an example instance
128
      QgsSingleSymbolRenderer exampleRenderer = QgsSingleSymbolRenderer( mVectorLayer->vectorType() );
129
      set ( exampleRenderer.symbol() );
140 130
    }
141 131

  
142
     //do the signal/slot connections
143
    QObject::connect(btnOutlineColor, SIGNAL(clicked()), this, SLOT(selectOutlineColor()));
144
    //QObject::connect(stylebutton, SIGNAL(clicked()), this, SLOT(selectOutlineStyle()));
145
    QObject::connect(btnFillColor, SIGNAL(clicked()), this, SLOT(selectFillColor()));
146
    QObject::connect(outlinewidthspinbox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged()));
147
    QObject::connect(mLabelEdit, SIGNAL(textChanged(const QString&)), this, SLOT(resendSettingsChanged()));
148
    QObject::connect(mPointSymbolComboBox, SIGNAL(activated(int)), this, SLOT(resendSettingsChanged()));
149
    QObject::connect(mPointSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged()));
132
    if (mVectorLayer && mVectorLayer->vectorType() == QGis::Line)
133
    {
134
      btnFillColor->setEnabled(false);
135
      cboFillStyle->setEnabled(false);
136
      mGroupPoint->setEnabled(false);
137
      mGroupPoint->setVisible(false);
138
    }
150 139

  
151
    //connect fill style and line style buttons
152
    QObject::connect(pbnLineSolid, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
153
    QObject::connect(pbnLineDot, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
154
    QObject::connect(pbnLineDashDot, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
155
    QObject::connect(pbnLineDash, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
156
    QObject::connect(pbnLineDashDotDot, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
157
    QObject::connect(pbnLineNoPen, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
158
    QObject::connect(solid, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
159
    QObject::connect(fdiag, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
160
    QObject::connect(dense4, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
161
    QObject::connect(horizontal, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
162
    QObject::connect(bdiag, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
163
    QObject::connect(diagcross, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
164
    QObject::connect(dense5, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
165
    QObject::connect(vertical, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
166
    QObject::connect(dense1, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
167
    QObject::connect(dense3, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
168
    QObject::connect(dense6, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
169
    QObject::connect(cross, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
170
    QObject::connect(dense2, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
171
    QObject::connect(dense7, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
172
    QObject::connect(nopen, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
173
    QObject::connect(texture, SIGNAL(clicked()), this, SLOT(resendSettingsChanged()));
174
	QObject::connect(textureSelect, SIGNAL(clicked()), this, SLOT(selectTextureImage()));
140
    if (mVectorLayer && mVectorLayer->vectorType() == QGis::Polygon) 
141
    {
142
      mGroupPoint->setEnabled(false);
143
      mGroupPoint->setVisible(false);
144
    }
145

  
146
  }
147
  else
148
  {
149
    qWarning("Warning, layer is a null pointer in "
150
        "QgsSingleSymbolDialog::QgsSingleSymbolDialog(QgsVectorLayer)");
151
  }
152

  
153
  //do the signal/slot connections
154
  connect(btnOutlineColor, SIGNAL(clicked()), this, SLOT(selectOutlineColor()));
155
  connect(btnFillColor, SIGNAL(clicked()), this, SLOT(selectFillColor()));
156
  connect(outlinewidthspinbox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged()));
157
  connect(mLabelEdit, SIGNAL(textChanged(const QString&)), this, SLOT(resendSettingsChanged()));
158
  connect (lstSymbols,SIGNAL(currentItemChanged ( QListWidgetItem * , QListWidgetItem * )),
159
        this, SLOT (symbolChanged (QListWidgetItem * , QListWidgetItem * )));
160
  connect(mPointSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(resendSettingsChanged()));
161
  connect(cboOutlineStyle, SIGNAL(
162
        currentIndexChanged ( const QString & )), this, SLOT(resendSettingsChanged()));
163
  connect(cboFillStyle, SIGNAL(
164
        currentIndexChanged ( const QString & )), this, SLOT(resendSettingsChanged()));
165
  //need this to deal with when texture fill is selected or deselected
166
  connect(cboFillStyle, SIGNAL(
167
        currentIndexChanged ( int )), this, SLOT(fillStyleChanged(int)));
168
  connect(toolSelectTexture, SIGNAL(clicked()), this, SLOT(selectTextureImage()));
175 169
}
176 170

  
177 171
QgsSingleSymbolDialog::~QgsSingleSymbolDialog()
......
190 184
        emit settingsChanged();
191 185
    }
192 186
    
193
    setActiveWindow();
187
    activateWindow();
194 188
}
195 189

  
196 190
void QgsSingleSymbolDialog::selectFillColor()
......
202 196
        emit settingsChanged();
203 197
    }
204 198

  
205
    setActiveWindow();
199
    activateWindow();
206 200
}
207 201

  
208 202
//should this method have a different name?
209 203
void QgsSingleSymbolDialog::selectTextureImage()
210 204
{
211 205
  QString fileName = QFileDialog::getOpenFileName(this, "Open File",
212
                                                textureFilePath->text(),
213
                                                "Images (*.png *.xpm *.jpg)"); //should we allow other types of images?
206
           mTexturePath,
207
           "Images (*.png *.xpm *.jpg)"); //should we allow other types of images?
214 208

  
215
  if(fileName.isNull() == false){ //only process the string if the user clicked OK
216
    textureFilePath->setText(fileName);
217
    texture->setOn(true); //set the fill style to custom texture
218
    texture->setPixmap(QPixmap(fileName)); //Change the button to show the selected image
209
  if(fileName.isNull() == false)
210
  { //only process the string if the user clicked OK
211
    mTexturePath = fileName;
219 212
    resendSettingsChanged();
220 213
  }
221 214
}
......
230 223
    //
231 224
    // Apply point symbol
232 225
    // 
233
    sy->setNamedPointSymbol( mMarkers[mPointSymbolComboBox->currentItem()] ) ;
226
    if ( lstSymbols->currentItem() )
227
    {
228
      sy->setNamedPointSymbol( lstSymbols->currentItem()->data(Qt::UserRole).toString() ) ;
229
    }
234 230
    sy->setPointSize ( mPointSizeSpinBox->value() );
235 231
    
236 232
    //
237 233
    // Apply the line style
238 234
    //
239
    if  (pbnLineNoPen->isOn())
240
        (sy->setLineStyle(Qt::NoPen));
241
    else if  (pbnLineDash->isOn())
242
        (sy->setLineStyle(Qt::DashLine));
243
    else if  (pbnLineDot->isOn())
244
        (sy->setLineStyle(Qt::DotLine)) ;
245
    else if  (pbnLineDashDot->isOn())
246
        (sy->setLineStyle(Qt::DashDotLine));
247
    else if  (pbnLineDashDotDot->isOn())
248
        (sy->setLineStyle(Qt::DashDotDotLine)) ;
249
    else
250
        (sy->setLineStyle(Qt::SolidLine)); //default to solid
235
    QString myLineStyle = 
236
      cboOutlineStyle->itemData(cboOutlineStyle->currentIndex(),Qt::UserRole).toString();
237
     sy->setLineStyle(QgsSymbologyUtils::qString2PenStyle(myLineStyle));
251 238

  
252

  
253 239
    //
254 240
    // Apply the pattern
255 241
    //
256 242

  
257 243
    //Store the file path, and set the brush to TexturePattern.  If we have a different button selected,
258 244
    // the below code will override it, but leave the file path alone.
259
    sy->setCustomTexture(textureFilePath->text());
245
   
246
    sy->setCustomTexture(mTexturePath);
260 247

  
261
    if (solid->isOn())
262
    {
263
        sy->setFillStyle(Qt::SolidPattern);
264
    }
265
    else if (fdiag->isOn())
266
    {
267
        sy->setFillStyle(Qt::FDiagPattern);
268
    }
269
    else if (dense4->isOn())
270
    {
271
        sy->setFillStyle(Qt::Dense4Pattern);
272
    }
273
    else if (horizontal->isOn())
274
    {
275
        sy->setFillStyle(Qt::HorPattern);
276
    }
277
    else if (dense5->isOn())
278
    {
279
        sy->setFillStyle(Qt::Dense5Pattern);
280
    }
281
    else if (diagcross->isOn())
282
    {
283
        sy->setFillStyle(Qt::DiagCrossPattern);
284
    }
285
    else if (dense1->isOn())
286
    {
287
        sy->setFillStyle(Qt::Dense1Pattern);
288
    }
289
    else if (dense6->isOn())
290
    {
291
        sy->setFillStyle(Qt::Dense6Pattern);
292
    }
293
    else if (vertical->isOn())
294
    {
295
        sy->setFillStyle(Qt::VerPattern);
296
    }
297
    else if (dense7->isOn())
298
    {
299
        sy->setFillStyle(Qt::Dense7Pattern);
300
    }
301
    else if (cross->isOn())
302
    {
303
        sy->setFillStyle(Qt::CrossPattern);
304
    }
305
    else if (dense2->isOn())
306
    {
307
        sy->setFillStyle(Qt::Dense2Pattern);
308
    }
309
    else if (bdiag->isOn())
310
    {
311
        sy->setFillStyle(Qt::BDiagPattern);
312
    }
313
    else if (dense3->isOn())
314
    {
315
        sy->setFillStyle(Qt::Dense3Pattern);
316
    }
317
    else if (nopen->isOn())
318
    {
319
        sy->setFillStyle(Qt::NoBrush);
320
    }
321
    else if (texture->isOn())
322
    {
323
      //we already set the brush to TexturePattern up above, so don't do anything here
324
    }
248
    QString myFillStyle = 
249
      cboFillStyle->itemData(cboFillStyle->currentIndex(),Qt::UserRole).toString();
250
    sy->setFillStyle(QgsSymbologyUtils::qString2BrushStyle(myFillStyle));
325 251

  
326
    //apply the label
327 252
    sy->setLabel(mLabelEdit->text());
328 253
}
329 254

  
......
343 268

  
344 269
  mLabelEdit->setText(sy->label());
345 270

  
346
	// Set point symbol
347
  for ( uint i = 0; i < mMarkers.size(); i++ ) {
348
	    if ( mMarkers[i] ==  sy->pointSymbolName() ) {
349
	        mPointSymbolComboBox->setCurrentItem ( i );
350
		break;
351
	    }
352
	}
353
	mPointSizeSpinBox->setValue ( sy->pointSize() );
354
	
355
	outlinewidthspinbox->setValue(sy->pen().width());
271
  // Set point symbol
272
  QString mySymbolName = sy->pointSymbolName();
273
  for ( int i = 0; i < lstSymbols->count(); ++i )
274
  {
275
    if (lstSymbols->item(i)->data( Qt::UserRole ).toString() == (mySymbolName))
276
    {
277
      lstSymbols->setCurrentItem ( lstSymbols->item(i) );
278
      lstSymbols->item(i)->setBackground( QBrush ( Qt::cyan ) );
279
      break;
280
    }
281
  }
282
  mPointSizeSpinBox->setValue ( sy->pointSize() );
356 283

  
357
	//set line width 1 as minimum to avoid confusion between line width 0 and no pen line style
358
	// ... but, drawLine is not correct with width > 0 -> until solved set to 0
359
	outlinewidthspinbox->setMinValue(0);
284
  outlinewidthspinbox->setValue(sy->pen().width());
360 285

  
361
    btnFillColor->setColor( sy->brush().color() );
286
  //set line width 1 as minimum to avoid confusion between line width 0 and no pen line style
287
  // ... but, drawLine is not correct with width > 0 -> until solved set to 0
288
  outlinewidthspinbox->setMinValue(0);
362 289

  
363
    btnOutlineColor->setColor( sy->pen().color() );
290
  btnFillColor->setColor( sy->brush().color() );
364 291

  
365
	//stylebutton->setName(QgsSymbologyUtils::penStyle2Char(sy->pen().style()));
366
	//stylebutton->setPixmap(QgsSymbologyUtils::char2LinePixmap(stylebutton->name()));
367
	//load the icons stored in QgsSymbologyUtils.cpp (to avoid redundancy)
292
  btnOutlineColor->setColor( sy->pen().color() );
368 293

  
369
	QPen myPen = sy->pen();
294
  //load the icons stored in QgsSymbologyUtils.cpp (to avoid redundancy)
370 295

  
371
	switch ( myPen.style() )
372
	{
373
	    case Qt::NoPen :
374
		pbnLineNoPen->setOn(true);
375
		break;
376
	    case Qt::DashLine :
377
		pbnLineDash->setOn(true);
378
		break;
379
	    case Qt::DotLine :
380
		pbnLineDot->setOn(true);
381
		break;
382
	    case Qt::DashDotLine :
383
		pbnLineDashDot->setOn(true);
384
		break;
385
	    case Qt::DashDotDotLine :
386
		pbnLineDashDotDot->setOn(true);
387
		break;
388
	    default :
389
		pbnLineSolid->setOn(true); // default to solid
390
		break;
391
	}
392

  
393
	QBrush myBrush = sy->brush();
394

  
395
	switch ( myBrush.style() )
396
	{
397
	    case Qt::SolidPattern :
398
		solid->setOn(true);
399
		break;
400
	    case Qt::HorPattern :
401
		horizontal->setOn(true);
402
		break;
403
	    case Qt::VerPattern :
404
		vertical->setOn(true);
405
		break;
406
	    case  Qt::CrossPattern :
407
		cross->setOn(true);
408
		break;
409
	    case Qt::BDiagPattern :
410
		bdiag->setOn(true);
411
		break;
412
	    case Qt::FDiagPattern :
413
		fdiag->setOn(true);
414
		break;
415
	    case Qt::DiagCrossPattern :
416
		diagcross->setOn(true);
417
		break;
418
	    case Qt::Dense1Pattern :
419
		dense1->setOn(true);
420
		break;
421
	    case Qt::Dense2Pattern :
422
		dense2->setOn(true);
423
		break;
424
	    case Qt::Dense3Pattern :
425
		dense3->setOn(true);
426
		break;
427
	    case Qt::Dense4Pattern :
428
		dense4->setOn(true);
429
		break;
430
	    case Qt::Dense5Pattern :
431
		dense5->setOn(true);
432
		break;
433
	    case Qt::Dense6Pattern :
434
		dense6->setOn(true);
435
		break;
436
	    case Qt::Dense7Pattern :
437
		dense7->setOn(true);
438
		break;
439
	    case Qt::NoBrush :
440
		nopen->setOn(true);
441
		break;
442
		case Qt::TexturePattern :
443
		texture->setOn(true);
444
		break;
445
	    default :
446
		solid->setOn(true);
447
		break;
448
	}
449
    textureFilePath->setText(sy->customTexture()); //get and show the file path, even if we aren't using it.
450
    if(sy->customTexture().size() > 0)//if the file path isn't empty, show the image on the button
296
  //
297
  // Set the line style combo
298
  //
299
  
300
  QPen myPen = sy->pen();
301
  QString myLineStyle = QgsSymbologyUtils::penStyle2QString(myPen.style());
302
  for ( int i = 0; i < cboOutlineStyle->count(); ++i )
303
  {
304
    if (cboOutlineStyle->itemData(i, Qt::UserRole ).toString() == myLineStyle)
451 305
    {
452
      texture->setPixmap(QPixmap(sy->customTexture())); //show the current texture image
306
      cboOutlineStyle->setCurrentIndex( i );
307
      break;
453 308
    }
454
	else
309
  }
310

  
311
  //
312
  // Set the brush combo
313
  //
314
  
315
  QBrush myBrush = sy->brush();
316
  QString myFillStyle =  QgsSymbologyUtils::brushStyle2QString(myBrush.style());
317
  for ( int i = 0; i < cboFillStyle->count(); ++i )
318
  {
319
    if (cboFillStyle->itemData(i, Qt::UserRole ).toString() == myFillStyle)
455 320
    {
456
      texture->setPixmap(QgsSymbologyUtils::char2PatternPixmap("TexturePattern")); //show the default question mark
321
      cboFillStyle->setCurrentIndex( i );
322
      break;
457 323
    }
324
  }
325
  
326
  //get and show the file path, even if we aren't using it.
327
  mTexturePath = sy->customTexture(); 
328
  //if the file path isn't empty, show the image on the button
329
  if(sy->customTexture().size() > 0)
330
  {
331
    //show the current texture image
332
   // texture->setPixmap(QPixmap(sy->customTexture())); 
333
  }
334
  else
335
  {
336
    //show the default question mark
337
    //texture->setPixmap(QgsSymbologyUtils::char2PatternPixmap("TexturePattern")); 
338
  }
458 339
}
459 340

  
460 341
void QgsSingleSymbolDialog::setOutlineColor(QColor& c)
......
464 345

  
465 346
void QgsSingleSymbolDialog::setOutlineStyle(Qt::PenStyle pstyle)
466 347
{
467
    // XXX use switch() instead
468
    if (pstyle==Qt::NoPen)
469
        (pbnLineNoPen->setOn(true));
470
    else if (pstyle==Qt::DashLine)
471
        (pbnLineDash->setOn(true));
472
    else if (pstyle==Qt::DotLine)
473
        (pbnLineDot->setOn(true));
474
    else if (pstyle==Qt::DashDotLine)
475
        (pbnLineDashDot->setOn(true));
476
    else if (pstyle==Qt::DashDotDotLine)
477
        (pbnLineDashDotDot->setOn(true));
478
    else
479
        (pbnLineSolid->setOn(true)); //default to solid
348
  QString myLineStyle = QgsSymbologyUtils::penStyle2QString(pstyle);
349
  for ( int i = 0; i < cboOutlineStyle->count(); ++i )
350
  {
351
    if (cboOutlineStyle->itemData(i, Qt::UserRole ).toString() == myLineStyle)
352
    {
353
      cboOutlineStyle->setCurrentIndex( i );
354
      break;
355
    }
356
  }
480 357
}
481 358

  
... This diff was truncated because it exceeds the maximum size that can be displayed.