QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsstylev2managerdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsstylev2managerdialog.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 
18 #include "qgsstylev2.h"
19 #include "qgssymbolv2.h"
20 #include "qgssymbollayerv2utils.h"
21 #include "qgsvectorcolorrampv2.h"
22 
30 
31 #include <QFile>
32 #include <QFileDialog>
33 #include <QInputDialog>
34 #include <QMessageBox>
35 #include <QSettings>
36 #include <QStandardItemModel>
37 #include <QAction>
38 #include <QMenu>
39 
40 #include "qgsapplication.h"
41 #include "qgslogger.h"
42 
43 
45  : QDialog( parent ), mStyle( style ), mModified( false )
46 {
47  setupUi( this );
48 #ifdef Q_WS_MAC
49  setWindowModality( Qt::WindowModal );
50 #endif
51 
52  QSettings settings;
53  restoreGeometry( settings.value( "/Windows/StyleV2Manager/geometry" ).toByteArray() );
54  mSplitter->setSizes( QList<int>() << 170 << 540 );
55  mSplitter->restoreState( settings.value( "/Windows/StyleV2Manager/splitter" ).toByteArray() );
56 
57  tabItemType->setDocumentMode( true );
58  searchBox->setPlaceholderText( tr( "Type here to filter symbols..." ) );
59 
60  // setup icons
61  btnAddItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyAdd.png" ) ) );
62  btnEditItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyEdit.png" ) ) );
63  btnRemoveItem->setIcon( QIcon( QgsApplication::iconPath( "symbologyRemove.png" ) ) );
64  btnShare->setIcon( QIcon( QgsApplication::iconPath( "user.png" ) ) );
65 
66  connect( this, SIGNAL( finished( int ) ), this, SLOT( onFinished() ) );
67 
68  connect( listItems, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( editItem() ) );
69 
70  connect( btnAddItem, SIGNAL( clicked() ), this, SLOT( addItem() ) );
71  connect( btnEditItem, SIGNAL( clicked() ), this, SLOT( editItem() ) );
72  connect( btnRemoveItem, SIGNAL( clicked() ), this, SLOT( removeItem() ) );
73 
74  QMenu *shareMenu = new QMenu( tr( "Share Menu" ), this );
75  QAction *exportAction = shareMenu->addAction( tr( "Export" ) );
76  QAction *importAction = shareMenu->addAction( tr( "Import" ) );
77  connect( exportAction, SIGNAL( triggered() ), this, SLOT( exportItems() ) );
78  connect( importAction, SIGNAL( triggered() ), this, SLOT( importItems() ) );
79  btnShare->setMenu( shareMenu );
80 
81  // Set editing mode off by default
82  mGrouppingMode = false;
83 
84  QStandardItemModel* model = new QStandardItemModel( listItems );
85  listItems->setModel( model );
86  listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
87 
88  connect( model, SIGNAL( itemChanged( QStandardItem* ) ), this, SLOT( itemChanged( QStandardItem* ) ) );
89  connect( listItems->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ),
90  this, SLOT( symbolSelected( const QModelIndex& ) ) );
91 
92  populateTypes();
93 
94  QStandardItemModel* groupModel = new QStandardItemModel( groupTree );
95  groupTree->setModel( groupModel );
96  groupTree->setHeaderHidden( true );
98  connect( groupTree->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ),
99  this, SLOT( groupChanged( const QModelIndex& ) ) );
100  connect( groupModel, SIGNAL( itemChanged( QStandardItem* ) ),
101  this, SLOT( groupRenamed( QStandardItem* ) ) );
102 
103  QMenu *groupMenu = new QMenu( tr( "Group Actions" ), this );
104  QAction *groupSymbols = groupMenu->addAction( tr( "Group Symbols" ) );
105  QAction *editSmartgroup = groupMenu->addAction( tr( "Edit Smart Group" ) );
106  btnManageGroups->setMenu( groupMenu );
107  connect( groupSymbols, SIGNAL( triggered() ), this, SLOT( groupSymbolsAction() ) );
108  connect( editSmartgroup, SIGNAL( triggered() ), this, SLOT( editSmartgroupAction() ) );
109 
110  connect( btnAddGroup, SIGNAL( clicked() ), this, SLOT( addGroup() ) );
111  connect( btnRemoveGroup, SIGNAL( clicked() ), this, SLOT( removeGroup() ) );
112 
114 
115  connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) );
116  tagsLineEdit->installEventFilter( this );
117 
118  // Context menu for groupTree
119  groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
120  connect( groupTree, SIGNAL( customContextMenuRequested( const QPoint& ) ),
121  this, SLOT( grouptreeContextMenu( const QPoint& ) ) );
122 
123  // Context menu for listItems
124  listItems->setContextMenuPolicy( Qt::CustomContextMenu );
125  connect( listItems, SIGNAL( customContextMenuRequested( const QPoint& ) ),
126  this, SLOT( listitemsContextMenu( const QPoint& ) ) );
127 
128 }
129 
131 {
132  if ( mModified )
133  {
134  mStyle->save();
135  }
136 
137  QSettings settings;
138  settings.setValue( "/Windows/StyleV2Manager/geometry", saveGeometry() );
139  settings.setValue( "/Windows/StyleV2Manager/splitter", mSplitter->saveState() );
140 }
141 
143 {
144 #if 0
145  // save current selection index in types combo
146  int current = ( tabItemType->count() > 0 ? tabItemType->currentIndex() : 0 );
147 
148 // no counting of style items
149  int markerCount = 0, lineCount = 0, fillCount = 0;
150 
151  QStringList symbolNames = mStyle->symbolNames();
152  for ( int i = 0; i < symbolNames.count(); ++i )
153  {
154  switch ( mStyle->symbolRef( symbolNames[i] )->type() )
155  {
156  case QgsSymbolV2::Marker:
157  markerCount++;
158  break;
159  case QgsSymbolV2::Line:
160  lineCount++;
161  break;
162  case QgsSymbolV2::Fill:
163  fillCount++;
164  break;
165  default: Q_ASSERT( 0 && "unknown symbol type" );
166  break;
167  }
168  }
169 
170  cboItemType->clear();
171  cboItemType->addItem( tr( "Marker symbol (%1)" ).arg( markerCount ), QVariant( QgsSymbolV2::Marker ) );
172  cboItemType->addItem( tr( "Line symbol (%1)" ).arg( lineCount ), QVariant( QgsSymbolV2::Line ) );
173  cboItemType->addItem( tr( "Fill symbol (%1)" ).arg( fillCount ), QVariant( QgsSymbolV2::Fill ) );
174 
175  cboItemType->addItem( tr( "Color ramp (%1)" ).arg( mStyle->colorRampCount() ), QVariant( 3 ) );
176 
177  // update current index to previous selection
178  cboItemType->setCurrentIndex( current );
179 #endif
180 }
181 
183 {
184  // when in Color Ramp tab, add menu to add item button
185  if ( currentItemType() == 3 )
186  {
187  QStringList rampTypes;
188  rampTypes << tr( "Gradient" ) << tr( "Random" ) << tr( "ColorBrewer" );
189  rampTypes << tr( "cpt-city" ); // todo, only for rasters?
190  QMenu* menu = new QMenu( btnAddItem );
191  foreach ( QString rampType, rampTypes )
192  {
193  menu->addAction( rampType );
194  }
195  btnAddItem->setMenu( menu );
196  connect( menu, SIGNAL( triggered( QAction* ) ),
197  this, SLOT( addColorRamp( QAction* ) ) );
198  }
199  else
200  {
201  if ( btnAddItem->menu() )
202  {
203  disconnect( btnAddItem->menu(), SIGNAL( triggered( QAction* ) ),
204  this, SLOT( addColorRamp( QAction* ) ) );
205  btnAddItem->setMenu( 0 );
206  }
207  }
208 
209  // set icon and grid size, depending on type
210  if ( currentItemType() == 1 || currentItemType() == 3 )
211  {
212  listItems->setIconSize( QSize( 75, 50 ) );
213  listItems->setGridSize( QSize( 100, 80 ) );
214  }
215  else
216  {
217  listItems->setIconSize( QSize( 50, 50 ) );
218  listItems->setGridSize( QSize( 75, 80 ) );
219  }
220 
221  populateList();
222 }
223 
225 {
226  if ( currentItemType() > 3 )
227  {
228  Q_ASSERT( 0 && "not implemented" );
229  return;
230  }
231  groupChanged( groupTree->selectionModel()->currentIndex() );
232 }
233 
234 void QgsStyleV2ManagerDialog::populateSymbols( QStringList symbolNames, bool check )
235 {
236  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
237  model->clear();
238 
239  int type = currentItemType();
240 
241  for ( int i = 0; i < symbolNames.count(); ++i )
242  {
243  QString name = symbolNames[i];
244  QgsSymbolV2* symbol = mStyle->symbol( name );
245  if ( symbol->type() == type )
246  {
247  QStandardItem* item = new QStandardItem( name );
248  QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( symbol, listItems->iconSize() );
249  item->setIcon( icon );
250  item->setData( name ); // used to find out original name when user edited the name
251  item->setCheckable( check );
252  item->setToolTip( name );
253  // add to model
254  model->appendRow( item );
255  }
256  delete symbol;
257  }
258 }
259 
260 
261 void QgsStyleV2ManagerDialog::populateColorRamps( QStringList colorRamps, bool check )
262 {
263  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
264  model->clear();
265 
266  for ( int i = 0; i < colorRamps.count(); ++i )
267  {
268  QString name = colorRamps[i];
269  QgsVectorColorRampV2* ramp = mStyle->colorRamp( name );
270 
271  QStandardItem* item = new QStandardItem( name );
272  QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon( ramp, listItems->iconSize() );
273  item->setIcon( icon );
274  item->setData( name ); // used to find out original name when user edited the name
275  item->setCheckable( check );
276  item->setToolTip( name );
277  model->appendRow( item );
278  delete ramp;
279  }
280 }
281 
283 {
284  switch ( tabItemType->currentIndex() )
285  {
286  case 0: return QgsSymbolV2::Marker;
287  case 1: return QgsSymbolV2::Line;
288  case 2: return QgsSymbolV2::Fill;
289  case 3: return 3;
290  default: return 0;
291  }
292 }
293 
295 {
296  QModelIndex index = listItems->selectionModel()->currentIndex();
297  if ( !index.isValid() )
298  return QString();
299  return index.model()->data( index, 0 ).toString();
300 }
301 
303 {
304  bool changed = false;
305  if ( currentItemType() < 3 )
306  {
307  changed = addSymbol();
308  }
309  else if ( currentItemType() == 3 )
310  {
311  changed = addColorRamp();
312  }
313  else
314  {
315  Q_ASSERT( 0 && "not implemented" );
316  }
317 
318  if ( changed )
319  {
320  populateList();
321  populateTypes();
322  }
323 }
324 
326 {
327  // create new symbol with current type
328  QgsSymbolV2* symbol;
329  QString name = tr( "new symbol" );
330  switch ( currentItemType() )
331  {
332  case QgsSymbolV2::Marker:
333  symbol = new QgsMarkerSymbolV2();
334  name = tr( "new marker" );
335  break;
336  case QgsSymbolV2::Line:
337  symbol = new QgsLineSymbolV2();
338  name = tr( "new line" );
339  break;
340  case QgsSymbolV2::Fill:
341  symbol = new QgsFillSymbolV2();
342  name = tr( "new fill symbol" );
343  break;
344  default:
345  Q_ASSERT( 0 && "unknown symbol type" );
346  return false;
347  }
348 
349  // get symbol design
350  // NOTE : Set the parent widget as "this" to notify the Symbol selector
351  // that, it is being called by Style Manager, so recursive calling
352  // of style manager and symbol selector can be arrested
353  // See also: editSymbol()
354  QgsSymbolV2SelectorDialog dlg( symbol, mStyle, NULL, this );
355  if ( dlg.exec() == 0 )
356  {
357  delete symbol;
358  return false;
359  }
360 
361  // get unique name
362  bool nameInvalid = true;
363 
364  while ( nameInvalid )
365  {
366  bool ok;
367  name = QInputDialog::getText( this, tr( "Symbol Name" ),
368  tr( "Please enter a name for new symbol:" ),
369  QLineEdit::Normal, name, &ok );
370  if ( !ok )
371  {
372  delete symbol;
373  return false;
374  }
375  // validate name
376  if ( name.isEmpty() )
377  {
378  QMessageBox::warning( this, tr( "Save symbol" ),
379  tr( "Cannot save symbol without name. Enter a name." ) );
380  }
381  else if ( mStyle->symbolNames().contains( name ) )
382  {
383  int res = QMessageBox::warning( this, tr( "Save symbol" ),
384  tr( "Symbol with name '%1' already exists. Overwrite?" )
385  .arg( name ),
386  QMessageBox::Yes | QMessageBox::No );
387  if ( res == QMessageBox::Yes )
388  {
389  nameInvalid = false;
390  }
391  }
392  else
393  {
394  // valid name
395  nameInvalid = false;
396  }
397  }
398 
399  // add new symbol to style and re-populate the list
400  mStyle->addSymbol( name, symbol, true );
401  // TODO groups and tags
402  mModified = true;
403  return true;
404 }
405 
406 
407 QString QgsStyleV2ManagerDialog::addColorRampStatic( QWidget* parent, QgsStyleV2* style, QString rampType )
408 {
409  // let the user choose the color ramp type if rampType is not given
410  bool ok = true;
411  if ( rampType.isEmpty() )
412  {
413  QStringList rampTypes;
414  rampTypes << tr( "Gradient" ) << tr( "Random" ) << tr( "ColorBrewer" );
415  rampTypes << tr( "cpt-city" ); // todo, only for rasters?
416  rampType = QInputDialog::getItem( parent, tr( "Color ramp type" ),
417  tr( "Please select color ramp type:" ), rampTypes, 0, false, &ok );
418  }
419  if ( !ok || rampType.isEmpty() )
420  return QString();
421 
422  QString name = tr( "new ramp" );
423 
424  QgsVectorColorRampV2 *ramp = NULL;
425  if ( rampType == tr( "Gradient" ) )
426  {
428  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, parent );
429  if ( !dlg.exec() )
430  {
431  delete gradRamp;
432  return QString();
433  }
434  ramp = gradRamp;
435  name = tr( "new gradient ramp" );
436  }
437  else if ( rampType == tr( "Random" ) )
438  {
440  QgsVectorRandomColorRampV2Dialog dlg( randRamp, parent );
441  if ( !dlg.exec() )
442  {
443  delete randRamp;
444  return QString();
445  }
446  ramp = randRamp;
447  name = tr( "new random ramp" );
448  }
449  else if ( rampType == tr( "ColorBrewer" ) )
450  {
452  QgsVectorColorBrewerColorRampV2Dialog dlg( brewerRamp, parent );
453  if ( !dlg.exec() )
454  {
455  delete brewerRamp;
456  return QString();
457  }
458  ramp = brewerRamp;
459  name = brewerRamp->schemeName() + QString::number( brewerRamp->colors() );
460  }
461  else if ( rampType == tr( "cpt-city" ) )
462  {
463  QgsCptCityColorRampV2* cptCityRamp = new QgsCptCityColorRampV2( "", "" );
464  QgsCptCityColorRampV2Dialog dlg( cptCityRamp, parent );
465  if ( !dlg.exec() )
466  {
467  delete cptCityRamp;
468  return QString();
469  }
470  // name = dlg.selectedName();
471  name = QFileInfo( cptCityRamp->schemeName() ).baseName() + cptCityRamp->variantName();
472  if ( dlg.saveAsGradientRamp() )
473  {
474  ramp = cptCityRamp->cloneGradientRamp();
475  delete cptCityRamp;
476  }
477  else
478  {
479  ramp = cptCityRamp;
480  }
481  }
482  else
483  {
484  // Q_ASSERT( 0 && "invalid ramp type" );
485  // bailing out is rather harsh!
486  QgsDebugMsg( "invalid ramp type " + rampType );
487  return QString();
488  }
489 
490  // get unique name
491  bool nameInvalid = true;
492 
493  while ( nameInvalid )
494  {
495  bool ok;
496  name = QInputDialog::getText( parent, tr( "Color Ramp Name" ),
497  tr( "Please enter a name for new color ramp:" ),
498  QLineEdit::Normal, name, &ok );
499  if ( !ok )
500  {
501  delete ramp;
502  return QString();
503  }
504  // validate name
505  if ( name.isEmpty() )
506  {
507  QMessageBox::warning( parent, tr( "Save Color Ramp" ),
508  tr( "Cannot save color ramp without name. Enter a name." ) );
509  }
510  else if ( style->colorRampNames().contains( name ) )
511  {
512  int res = QMessageBox::warning( parent, tr( "Save color ramp" ),
513  tr( "Color ramp with name '%1' already exists. Overwrite?" )
514  .arg( name ),
515  QMessageBox::Yes | QMessageBox::No );
516  if ( res == QMessageBox::Yes )
517  {
518  nameInvalid = false;
519  }
520  }
521  else
522  {
523  // valid name
524  nameInvalid = false;
525  }
526  }
527 
528  // add new symbol to style and re-populate the list
529  style->addColorRamp( name, ramp, true );
530  // TODO groups and tags, using saveColorRamp
531  return name;
532 }
533 
534 
536 {
537  return addColorRamp( 0 );
538 }
539 
541 {
542  // pass the action text, which is the color ramp type
543  QString rampName = addColorRampStatic( this , mStyle,
544  action ? action->text() : QString() );
545  if ( !rampName.isEmpty() )
546  {
547  mModified = true;
548  populateList();
549  return true;
550  }
551 
552  return false;
553 }
554 
556 {
557  bool changed = false;
558  if ( currentItemType() < 3 )
559  {
560  changed = editSymbol();
561  }
562  else if ( currentItemType() == 3 )
563  {
564  changed = editColorRamp();
565  }
566  else
567  {
568  Q_ASSERT( 0 && "not implemented" );
569  }
570 
571  if ( changed )
572  populateList();
573 }
574 
576 {
577  QString symbolName = currentItemName();
578  if ( symbolName.isEmpty() )
579  return false;
580 
581  QgsSymbolV2* symbol = mStyle->symbol( symbolName );
582 
583  // let the user edit the symbol and update list when done
584  QgsSymbolV2SelectorDialog dlg( symbol, mStyle, NULL , this );
585  if ( dlg.exec() == 0 )
586  {
587  delete symbol;
588  return false;
589  }
590 
591  // by adding symbol to style with the same name the old effectively gets overwritten
592  mStyle->addSymbol( symbolName, symbol, true );
593  mModified = true;
594  return true;
595 }
596 
598 {
599  QString name = currentItemName();
600  if ( name.isEmpty() )
601  return false;
602 
603  QgsVectorColorRampV2* ramp = mStyle->colorRamp( name );
604 
605  if ( ramp->type() == "gradient" )
606  {
607  QgsVectorGradientColorRampV2* gradRamp = static_cast<QgsVectorGradientColorRampV2*>( ramp );
608  QgsVectorGradientColorRampV2Dialog dlg( gradRamp, this );
609  if ( !dlg.exec() )
610  {
611  delete ramp;
612  return false;
613  }
614  }
615  else if ( ramp->type() == "random" )
616  {
617  QgsVectorRandomColorRampV2* randRamp = static_cast<QgsVectorRandomColorRampV2*>( ramp );
618  QgsVectorRandomColorRampV2Dialog dlg( randRamp, this );
619  if ( !dlg.exec() )
620  {
621  delete ramp;
622  return false;
623  }
624  }
625  else if ( ramp->type() == "colorbrewer" )
626  {
627  QgsVectorColorBrewerColorRampV2* brewerRamp = static_cast<QgsVectorColorBrewerColorRampV2*>( ramp );
628  QgsVectorColorBrewerColorRampV2Dialog dlg( brewerRamp, this );
629  if ( !dlg.exec() )
630  {
631  delete ramp;
632  return false;
633  }
634  }
635  else if ( ramp->type() == "cpt-city" )
636  {
637  QgsCptCityColorRampV2* cptCityRamp = static_cast<QgsCptCityColorRampV2*>( ramp );
638  QgsCptCityColorRampV2Dialog dlg( cptCityRamp, this );
639  if ( !dlg.exec() )
640  {
641  delete ramp;
642  return false;
643  }
644  if ( dlg.saveAsGradientRamp() )
645  {
646  ramp = cptCityRamp->cloneGradientRamp();
647  delete cptCityRamp;
648  }
649  }
650  else
651  {
652  Q_ASSERT( 0 && "invalid ramp type" );
653  }
654 
655  mStyle->addColorRamp( name, ramp, true );
656  mModified = true;
657  return true;
658 }
659 
660 
662 {
663  bool changed = false;
664  if ( currentItemType() < 3 )
665  {
666  changed = removeSymbol();
667  }
668  else if ( currentItemType() == 3 )
669  {
670  changed = removeColorRamp();
671  }
672  else
673  {
674  Q_ASSERT( 0 && "not implemented" );
675  }
676 
677  if ( changed )
678  {
679  populateList();
680  populateTypes();
681  }
682 }
683 
685 {
686  QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
687  foreach ( QModelIndex index, indexes )
688  {
689  QString symbolName = index.data().toString();
690  // delete from style and update list
691  if ( !symbolName.isEmpty() )
692  mStyle->removeSymbol( symbolName );
693  }
694  mModified = true;
695  return true;
696 }
697 
699 {
700  QString rampName = currentItemName();
701  if ( rampName.isEmpty() )
702  return false;
703 
704  mStyle->removeColorRamp( rampName );
705  mModified = true;
706  return true;
707 }
708 
709 void QgsStyleV2ManagerDialog::itemChanged( QStandardItem* item )
710 {
711  // an item has been edited
712  QString oldName = item->data().toString();
713 
714  bool changed = false;
715  if ( currentItemType() < 3 )
716  {
717  changed = mStyle->renameSymbol( oldName, item->text() );
718  }
719  else if ( currentItemType() == 3 )
720  {
721  changed = mStyle->renameColorRamp( oldName, item->text() );
722  }
723 
724  if ( changed )
725  {
726  populateList();
727  mModified = true;
728  }
729 
730 }
731 
733 {
735  dlg.exec();
736 }
737 
739 {
741  dlg.exec();
742  populateList();
743  populateGroups();
744 }
745 
746 void QgsStyleV2ManagerDialog::setBold( QStandardItem* item )
747 {
748  QFont font = item->font();
749  font.setBold( true );
750  item->setFont( font );
751 }
752 
754 {
755  QStandardItemModel *model = qobject_cast<QStandardItemModel*>( groupTree->model() );
756  model->clear();
757 
758  QStandardItem *allSymbols = new QStandardItem( tr( "All Symbols" ) );
759  allSymbols->setData( "all" );
760  allSymbols->setEditable( false );
761  setBold( allSymbols );
762  model->appendRow( allSymbols );
763 
764  QStandardItem *group = new QStandardItem( "" ); //require empty name to get first order groups
765  group->setData( "groups" );
766  group->setEditable( false );
767  buildGroupTree( group );
768  group->setText( tr( "Groups" ) );//set title later
769  QStandardItem *ungrouped = new QStandardItem( tr( "Ungrouped" ) );
770  ungrouped->setData( 0 );
771  setBold( ungrouped );
772  setBold( group );
773  group->appendRow( ungrouped );
774  model->appendRow( group );
775 
776  QStandardItem *tag = new QStandardItem( tr( "Smart Groups" ) );
777  tag->setData( "smartgroups" );
778  tag->setEditable( false );
779  setBold( tag );
781  QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
782  while ( i != sgMap.constEnd() )
783  {
784  QStandardItem *item = new QStandardItem( i.value() );
785  item->setData( i.key() );
786  tag->appendRow( item );
787  ++i;
788  }
789  model->appendRow( tag );
790 
791  // expand things in the grouo tree
792  int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
793  for ( int i = 0; i < rows; i++ )
794  {
795  groupTree->setExpanded( model->indexFromItem( model->item( i ) ), true );
796  }
797 }
798 
799 void QgsStyleV2ManagerDialog::buildGroupTree( QStandardItem* &parent )
800 {
801  QgsSymbolGroupMap groups = mStyle->childGroupNames( parent->text() );
802  QgsSymbolGroupMap::const_iterator i = groups.constBegin();
803  while ( i != groups.constEnd() )
804  {
805  QStandardItem *item = new QStandardItem( i.value() );
806  item->setData( i.key() );
807  parent->appendRow( item );
808  buildGroupTree( item );
809  ++i;
810  }
811 }
812 
814 {
815  QStringList symbolNames;
816  QStringList groupSymbols;
817 
819  if ( currentItemType() > 3 )
820  {
821  QgsDebugMsg( "Entity not implemented" );
822  return;
823  }
824 
825  QString category = index.data( Qt::UserRole + 1 ).toString();
826  if ( category == "all" || category == "groups" || category == "smartgroups" )
827  {
828  enableGroupInputs( false );
829  if ( category == "groups" || category == "smartgroups" )
830  {
831  btnAddGroup->setEnabled( true );
832  }
833  symbolNames = currentItemType() < 3 ? mStyle->symbolNames() : mStyle->colorRampNames();
834  }
835  else
836  {
837  //determine groups and tags
838  if ( index.parent().data( Qt::UserRole + 1 ) == "smartgroups" )
839  {
840  btnAddGroup->setEnabled( false );
841  btnRemoveGroup->setEnabled( true );
842  btnManageGroups->setEnabled( true );
843  int groupId = index.data( Qt::UserRole + 1 ).toInt();
844  symbolNames = mStyle->symbolsOfSmartgroup( type, groupId );
845  }
846  else // then it must be a group
847  {
848  if (( !index.data( Qt::UserRole + 1 ).toInt() && ( index.data() == "Ungrouped" ) ) || mGrouppingMode )
849  enableGroupInputs( false );
850  else
851  enableGroupInputs( true );
852  int groupId = index.data( Qt::UserRole + 1 ).toInt();
853  symbolNames = mStyle->symbolsOfGroup( type, groupId );
854  if ( mGrouppingMode && groupId )
855  {
856  groupSymbols = symbolNames;
857  symbolNames += mStyle->symbolsOfGroup( type, 0 );
858  }
859  }
860  }
861 
862  if ( currentItemType() < 3 )
863  {
864  populateSymbols( symbolNames, mGrouppingMode );
865  }
866  else if ( currentItemType() == 3 )
867  {
868  populateColorRamps( symbolNames, mGrouppingMode );
869  }
870  if ( mGrouppingMode )
871  setSymbolsChecked( groupSymbols );
872 }
873 
875 {
876  QStandardItemModel *model = qobject_cast<QStandardItemModel*>( groupTree->model() );
877  QModelIndex parentIndex = groupTree->currentIndex();
878 
879  // Violation 1: Creating sub-groups of system defined groups
880  QString parentData = parentIndex.data( Qt::UserRole + 1 ).toString();
881  if ( parentData == "all" || ( parentIndex.data() == "Ungrouped" && parentData == "0" ) )
882  {
883  int err = QMessageBox::critical( this, tr( "Invalid Selection" ),
884  tr( "The parent group you have selected is not user editable.\n"
885  "Kindly select a user defined group." ) );
886  if ( err )
887  return;
888  }
889 
890  // Violation 2: Creating a nested tag
891  if ( parentIndex.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
892  {
893  int err = QMessageBox::critical( this, tr( "Operation Not Allowed" ),
894  tr( "Creation of nested smart groups are not allowed\n"
895  "Select the 'Smart Group' to create a new group." ) );
896  if ( err )
897  return;
898  }
899 
900  QString itemName;
901  QVariant itemData;
902  bool isGroup = true;
903 
904  // create a smart group if that is selected
905  if ( parentIndex.data( Qt::UserRole + 1 ).toString() == "smartgroups" )
906  {
907  QgsSmartGroupEditorDialog dlg( mStyle, this );
908  if ( dlg.exec() == QDialog::Rejected )
909  return;
910  int id = mStyle->addSmartgroup( dlg.smartgroupName(), dlg.conditionOperator(), dlg.conditionMap() );
911  if ( !id )
912  return;
913  itemData = QVariant( id );
914  itemName = dlg.smartgroupName();
915  isGroup = false;
916  }
917  else
918  {
919  itemName = QString( tr( "New Group" ) );
920  itemData = QVariant( "newgroup" );
921  }
922 
923  // Else create a simple child-group to the selected
924  QStandardItem *parentItem = model->itemFromIndex( parentIndex );
925  QStandardItem *childItem = new QStandardItem( itemName );
926  childItem->setData( itemData );
927  parentItem->appendRow( childItem );
928 
929  groupTree->setCurrentIndex( childItem->index() );
930  if ( isGroup )
931  {
932  groupTree->edit( childItem->index() );
933  }
934 }
935 
937 {
938  QStandardItemModel *model = qobject_cast<QStandardItemModel*>( groupTree->model() );
939  QModelIndex index = groupTree->currentIndex();
940 
941  // Violation: removing system groups
942  QString data = index.data( Qt::UserRole + 1 ).toString();
943  if ( data == "all" || data == "groups" || data == "smartgroups" || index.data() == "Ungrouped" )
944  {
945  int err = QMessageBox::critical( this, tr( "Invalid selection" ),
946  tr( "Cannot delete system defined categories.\n"
947  "Kindly select a group or smart group you might want to delete." ) );
948  if ( err )
949  return;
950  }
951 
952  QStandardItem *parentItem = model->itemFromIndex( index.parent() );
953  if ( parentItem->data( Qt::UserRole + 1 ).toString() == "smartgroups" )
954  {
955  mStyle->remove( QgsStyleV2::SmartgroupEntity, index.data( Qt::UserRole + 1 ).toInt() );
956  }
957  else
958  {
959  mStyle->remove( QgsStyleV2::GroupEntity, index.data( Qt::UserRole + 1 ).toInt() );
960  QStandardItem *item = model->itemFromIndex( index );
961  if ( item->hasChildren() )
962  {
963  QStandardItem *parent = item->parent();
964  for ( int i = 0; i < item->rowCount(); i++ )
965  {
966  parent->appendRow( item->takeChild( i ) );
967  }
968  }
969  }
970  parentItem->removeRow( index.row() );
971 }
972 
973 void QgsStyleV2ManagerDialog::groupRenamed( QStandardItem * item )
974 {
975  QString data = item->data( Qt::UserRole + 1 ).toString();
976  QgsDebugMsg( "Symbol group edited: data=" + data + " text=" + item->text() );
977  if ( data == "newgroup" )
978  {
979  int id;
980  if ( item->parent()->data( Qt::UserRole + 1 ).toString() == "groups" )
981  {
982  id = mStyle->addGroup( item->text() );
983  }
984  else
985  {
986  int parentid = item->parent()->data( Qt::UserRole + 1 ).toInt();
987  id = mStyle->addGroup( item->text(), parentid );
988  }
989  if ( !id )
990  {
991  QMessageBox::critical( this, tr( "Error!" ),
992  tr( "New group could not be created.\n"
993  "There was a problem with your symbol database." ) );
994  item->parent()->removeRow( item->row() );
995  return;
996  }
997  else
998  {
999  item->setData( id );
1000  }
1001  }
1002  else
1003  {
1004  int id = item->data( Qt::UserRole + 1 ).toInt();
1005  QString name = item->text();
1006  if ( item->parent()->data( Qt::UserRole + 1 ) == "smartgroups" )
1007  {
1009  }
1010  else
1011  {
1012  mStyle->rename( QgsStyleV2::GroupEntity, id, name );
1013  }
1014  }
1015 }
1016 
1018 {
1019 
1020  QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model() );
1021  QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() );
1022  QAction *senderAction = qobject_cast<QAction*>( sender() );
1023 
1024  if ( mGrouppingMode )
1025  {
1026  mGrouppingMode = false;
1027  senderAction->setText( tr( "Group Symbols" ) );
1028  // disconnect slot which handles regrouping
1029  disconnect( model, SIGNAL( itemChanged( QStandardItem* ) ),
1030  this, SLOT( regrouped( QStandardItem* ) ) );
1031 
1032  // disabel all items except groups in groupTree
1034  groupChanged( groupTree->currentIndex() );
1035 
1036  // Finally: Reconnect all Symbol editing functionalities
1037  connect( treeModel, SIGNAL( itemChanged( QStandardItem* ) ),
1038  this, SLOT( groupRenamed( QStandardItem* ) ) );
1039  connect( model, SIGNAL( itemChanged( QStandardItem* ) ),
1040  this, SLOT( itemChanged( QStandardItem* ) ) );
1041  // Reset the selection mode
1042  listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
1043  }
1044  else
1045  {
1046  bool validGroup = false;
1047  // determine whether it is a valid group
1048  QModelIndex present = groupTree->currentIndex();
1049  while ( present.parent().isValid() )
1050  {
1051  if ( present.parent().data() == "Groups" )
1052  {
1053  validGroup = true;
1054  break;
1055  }
1056  else
1057  present = present.parent();
1058  }
1059  if ( !validGroup )
1060  return;
1061 
1062  mGrouppingMode = true;
1063  // Change the text menu
1064  senderAction->setText( tr( "Finish Grouping" ) );
1065  // Remove all Symbol editing functionalities
1066  disconnect( treeModel, SIGNAL( itemChanged( QStandardItem* ) ),
1067  this, SLOT( groupRenamed( QStandardItem* ) ) );
1068  disconnect( model, SIGNAL( itemChanged( QStandardItem* ) ),
1069  this, SLOT( itemChanged( QStandardItem* ) ) );
1070 
1071  // disabel all items except groups in groupTree
1072  enableItemsForGroupingMode( false );
1073  groupChanged( groupTree->currentIndex() );
1074  btnManageGroups->setEnabled( true );
1075 
1076 
1077  // Connect to slot which handles regrouping
1078  connect( model, SIGNAL( itemChanged( QStandardItem* ) ),
1079  this, SLOT( regrouped( QStandardItem* ) ) );
1080 
1081  // No selection should be possible
1082  listItems->setSelectionMode( QAbstractItemView::NoSelection );
1083  }
1084 }
1085 
1086 void QgsStyleV2ManagerDialog::regrouped( QStandardItem *item )
1087 {
1089  if ( currentItemType() > 3 )
1090  {
1091  QgsDebugMsg( "Unknown style entity" );
1092  return;
1093  }
1094  int groupid = groupTree->currentIndex().data( Qt::UserRole + 1 ).toInt();
1095  QString symbolName = item->text();
1096  bool regrouped;
1097  if ( item->checkState() == Qt::Checked )
1098  regrouped = mStyle->group( type, symbolName, groupid );
1099  else
1100  regrouped = mStyle->group( type, symbolName, 0 );
1101  if ( !regrouped )
1102  {
1103  int er = QMessageBox::critical( this, tr( "Database Error" ),
1104  tr( "There was a problem with the Symbols database while regrouping." ) );
1105  // call the slot again to get back to normal
1106  if ( er )
1108  }
1109 }
1110 
1112 {
1113  QStandardItemModel *model = qobject_cast<QStandardItemModel*>( listItems->model() );
1114  foreach ( const QString symbol, symbols )
1115  {
1116  QList<QStandardItem*> items = model->findItems( symbol );
1117  foreach ( QStandardItem* item, items )
1118  item->setCheckState( Qt::Checked );
1119  }
1120 }
1121 
1123 {
1124  QStringList items;
1125  if ( currentItemType() == 3 )
1126  {
1127  items = mStyle->findSymbols( QgsStyleV2::ColorrampEntity, qword );
1128  populateColorRamps( items );
1129  }
1130  else
1131  {
1132  items = mStyle->findSymbols( QgsStyleV2::SymbolEntity, qword );
1133  populateSymbols( items );
1134  }
1135 }
1136 
1138 {
1139  QModelIndexList indexes = listItems->selectionModel()->selection().indexes();
1140  QStringList addtags;
1141  QStringList removetags;
1142 
1143  QStringList oldtags = mTagList;
1144  QStringList newtags = tagsLineEdit->text().split( ",", QString::SkipEmptyParts );
1145 
1147  if ( currentItemType() < 3 )
1148  {
1149  type = QgsStyleV2::SymbolEntity;
1150  }
1151  else if ( currentItemType() == 3 )
1152  {
1154  }
1155  else
1156  {
1157  QgsDebugMsg( "Unknown Style Entity!" );
1158  return;
1159  }
1160  // compare old with new to find removed tags
1161  foreach ( const QString &tag, oldtags )
1162  {
1163  if ( !newtags.contains( tag ) )
1164  removetags.append( tag );
1165  }
1166  if ( removetags.size() > 0 )
1167  {
1168  foreach ( QModelIndex index, indexes )
1169  {
1170  mStyle->detagSymbol( type, index.data().toString(), removetags );
1171  }
1172  }
1173  // compare new with old to find added tags
1174  foreach ( const QString &tag, newtags )
1175  {
1176  if ( !oldtags.contains( tag ) )
1177  addtags.append( tag );
1178  }
1179  if ( addtags.size() > 0 )
1180  {
1181  foreach ( QModelIndex index, indexes )
1182  {
1183  mStyle->tagSymbol( type, index.data().toString(), addtags );
1184  }
1185  }
1186 }
1187 
1189 {
1190  // Populate the tags for the symbol
1191  tagsLineEdit->clear();
1192  QStandardItem *item = static_cast<QStandardItemModel*>( listItems->model() )->itemFromIndex( index );
1194  mTagList = mStyle->tagsOfSymbol( type, item->data().toString() );
1195  tagsLineEdit->setText( mTagList.join( "," ) );
1196 }
1197 
1199 {
1200  groupTree->setEnabled( enable );
1201  btnAddGroup->setEnabled( enable );
1202  btnRemoveGroup->setEnabled( enable );
1203  btnManageGroups->setEnabled( enable );
1204  searchBox->setEnabled( enable );
1205  tagsLineEdit->setEnabled( enable );
1206 }
1207 
1209 {
1210  btnAddGroup->setEnabled( enable );
1211  btnRemoveGroup->setEnabled( enable );
1212  btnManageGroups->setEnabled( enable );
1213 }
1214 
1216 {
1217  QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model() );
1218  for ( int i = 0; i < treeModel->rowCount(); i++ )
1219  {
1220  if ( treeModel->item( i )->data() != "groups" )
1221  {
1222  treeModel->item( i )->setEnabled( enable );
1223  }
1224  if ( treeModel->item( i )->data() == "groups" )
1225  {
1226  treeModel->item( i )->setEnabled( enable );
1227  for ( int k = 0; k < treeModel->item( i )->rowCount(); k++ )
1228  {
1229  if ( !treeModel->item( i )->child( k )->data().toInt() )
1230  treeModel->item( i )->child( k )->setEnabled( enable );
1231  }
1232  }
1233  if ( treeModel->item( i )->data() == "smartgroups" )
1234  {
1235  for ( int j = 0; j < treeModel->item( i )->rowCount(); j++ )
1236  {
1237  treeModel->item( i )->child( j )->setEnabled( enable );
1238  }
1239  }
1240  }
1241 
1242  // The buttons
1243  // NOTE: if you ever change the layout name in the .ui file edit here too
1244  for ( int i = 0; i < symbolBtnsLayout->count(); i++ )
1245  {
1246  symbolBtnsLayout->itemAt( i )->widget()->setEnabled( enable );
1247  }
1248 
1249 }
1250 
1252 {
1253  QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
1254 
1255  QModelIndex index = groupTree->indexAt( point );
1256  QgsDebugMsg( "Now you clicked: " + index.data().toString() );
1257 
1258  QMenu groupMenu;
1259 
1260  if ( index.parent().isValid() && ( index.data().toString() != "Ungrouped" ) )
1261  {
1262  if ( index.parent().data( Qt::UserRole + 1 ).toString() == "smartgroups" )
1263  {
1264  groupMenu.addAction( tr( "Edit Group" ) );
1265  }
1266  else
1267  {
1268  groupMenu.addAction( tr( "Add Group" ) );
1269  }
1270  groupMenu.addAction( tr( "Remove Group" ) );
1271  }
1272  else if ( index.data( Qt::UserRole + 1 ) == "groups" || index.data( Qt::UserRole + 1 ) == "smartgroups" )
1273  {
1274  groupMenu.addAction( tr( "Add Group" ) );
1275  }
1276 
1277 
1278  QAction* selectedItem = groupMenu.exec( globalPos );
1279 
1280  if ( selectedItem )
1281  {
1282  if ( selectedItem->text() == tr( "Add Group" ) )
1283  addGroup();
1284  else if ( selectedItem->text() == tr( "Remove Group" ) )
1285  removeGroup();
1286  else if ( selectedItem->text() == tr( "Edit Group" ) )
1288  }
1289 }
1290 
1292 {
1293  QPoint globalPos = listItems->viewport()->mapToGlobal( point );
1294 
1295  QMenu *groupMenu = new QMenu( this );
1296  QMenu *groupList = new QMenu( this );
1297  groupList->setTitle( tr( "Apply Group" ) );
1298 
1299  QStringList groups = mStyle->groupNames();
1300  foreach ( QString group, groups )
1301  {
1302  groupList->addAction( group );
1303  }
1304  groupMenu->addMenu( groupList );
1305  groupMenu->addAction( tr( "Un-group" ) );
1306 
1307  QAction* selectedItem = groupMenu->exec( globalPos );
1308 
1309  if ( selectedItem )
1310  {
1312  if ( currentItemType() > 3 )
1313  {
1314  QgsDebugMsg( "unknow entity type" );
1315  return;
1316  }
1317  int groupId = 0;
1318  if ( selectedItem->text() != tr( "Un-group" ) )
1319  {
1320  groupId = mStyle->groupId( selectedItem->text() );
1321  }
1322  QModelIndexList indexes = listItems->selectionModel()->selectedIndexes();
1323  foreach ( QModelIndex index, indexes )
1324  {
1325  mStyle->group( type, index.data().toString(), groupId );
1326  }
1327  populateList();
1328 
1329  QgsDebugMsg( "Selected Action: " + selectedItem->text() );
1330  }
1331 }
1332 
1334 {
1335  QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model() );
1336 
1337  // determine whether it is a valid group
1338  QModelIndex present = groupTree->currentIndex();
1339  if ( present.parent().data( Qt::UserRole + 1 ) != "smartgroups" )
1340  {
1341  QMessageBox::critical( this, tr( "Invalid Selection" ),
1342  tr( "You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
1343  return;
1344  }
1345  QStandardItem* item = treeModel->itemFromIndex( present );
1346 
1347  QgsSmartGroupEditorDialog dlg( mStyle, this );
1348  QgsSmartConditionMap map = mStyle->smartgroup( present.data( Qt::UserRole + 1 ).toInt() );
1349  dlg.setSmartgroupName( item->text() );
1350  dlg.setOperator( mStyle->smartgroupOperator( item->data().toInt() ) );
1351  dlg.setConditionMap( map );
1352 
1353  if ( dlg.exec() == QDialog::Rejected )
1354  return;
1355 
1356  mStyle->remove( QgsStyleV2::SmartgroupEntity, item->data().toInt() );
1357  int id = mStyle->addSmartgroup( dlg.smartgroupName(), dlg.conditionOperator(), dlg.conditionMap() );
1358  if ( !id )
1359  {
1360  QMessageBox::critical( this, tr( "Database Error!" ),
1361  tr( "There was some error while editing the smart group." ) );
1362  return;
1363  }
1364  item->setText( dlg.smartgroupName() );
1365  item->setData( id );
1366 
1367  groupChanged( present );
1368 }
1369 
1370 bool QgsStyleV2ManagerDialog::eventFilter( QObject *obj, QEvent *event )
1371 {
1372 
1373  if (( obj == tagsLineEdit ) && ( event->type() == QEvent::FocusOut ) )
1374  {
1375  tagsChanged();
1376  return true;
1377  }
1378  return false;
1379 }
1380 
QString smartgroupOperator(int id)
returns the operator for the smartgroup
static unsigned index
void remove(StyleEntity type, int id)
remove the specified entity from the db
Definition: qgsstylev2.cpp:679
QStringList tagsOfSymbol(StyleEntity type, QString symbol)
return the tags associated with the symbol
Definition: qgsstylev2.cpp:931
int addSmartgroup(QString name, QString op, QgsSmartConditionMap conditions)
adds new smartgroup to the database and returns the id
static QIcon colorRampPreviewIcon(QgsVectorColorRampV2 *ramp, QSize size)
virtual QString type() const =0
void filterSymbols(QString)
filter the symbols based on input search term
SymbolType type() const
Definition: qgssymbolv2.h:79
QgsSmartConditionMap conditionMap()
returns the condition map
void itemChanged(QStandardItem *item)
void groupChanged(const QModelIndex &)
#define QgsDebugMsg(str)
Definition: qgslogger.h:36
bool group(StyleEntity type, QString name, int groupid)
applies the specified group to the symbol or colorramp specified by StyleEntity
Definition: qgsstylev2.cpp:731
static QString iconPath(QString iconFile)
Returns path to the desired icon file.
void enableItemsForGroupingMode(bool)
Enables or diables the groupTree items for grouping mode.
void setSymbolsChecked(QStringList)
to set symbols checked when in editing mode
QMultiMap< QString, QString > QgsSmartConditionMap
Definition: qgsstylev2.h:56
void tagsChanged()
Listen to tag changes.
QStringList symbolsOfGroup(StyleEntity type, int groupid)
returns the symbolnames of a given groupid
Definition: qgsstylev2.cpp:515
void populateSymbols(QStringList symbolNames, bool checkable=false)
populate list view with symbols of the current type with the given names
QgsStyleV2ManagerDialog(QgsStyleV2 *style, QWidget *parent=NULL)
QgsSymbolV2 * symbol(QString name)
return a NEW copy of symbol
Definition: qgsstylev2.cpp:166
void rename(StyleEntity type, int id, QString newName)
rename the given entity with the specified id
Definition: qgsstylev2.cpp:633
static QIcon icon(QString icon)
QString smartgroupName()
returns the value from mNameLineEdit
QStringList colorRampNames()
return a list of names of color ramps
Definition: qgsstylev2.cpp:276
bool renameSymbol(QString oldName, QString newName)
change symbol's name
Definition: qgsstylev2.cpp:406
QgsSymbolGroupMap childGroupNames(QString parent="")
return a map of groupid and names for the given parent group
Definition: qgsstylev2.cpp:468
bool addSymbol(QString name, QgsSymbolV2 *symbol, bool update=false)
add symbol to style. takes symbol's ownership
Definition: qgsstylev2.cpp:83
bool save(QString filename=QString())
save style into a file (will use current filename if empty string is passed)
Definition: qgsstylev2.cpp:360
void setConditionMap(QgsSmartConditionMap)
sets up the GUI for the given conditionmap
QString variantName() const
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
bool addSymbol()
add a new symbol to style
const QgsSymbolV2 * symbolRef(QString name) const
return a const pointer to a symbol (doesn't create new instance)
Definition: qgsstylev2.cpp:172
int colorRampCount()
return count of color ramps
Definition: qgsstylev2.cpp:271
void populateGroups()
populate the groups
QStringList mTagList
space to store symbol tags
bool renameColorRamp(QString oldName, QString newName)
change ramp's name
Definition: qgsstylev2.cpp:432
void groupRenamed(QStandardItem *)
void buildGroupTree(QStandardItem *&parent)
build the groups tree
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
returns the symbols for the smartgroup
void grouptreeContextMenu(const QPoint &)
Context menu for the groupTree.
void setOperator(QString)
sets the operator AND/OR
void populateTypes()
populate combo box with known style items (symbols, color ramps)
QStringList symbolNames()
return a list of names of symbols
Definition: qgsstylev2.cpp:182
QMap< int, QString > QgsSymbolGroupMap
Definition: qgsstylev2.h:35
QgsSymbolGroupMap smartgroupsListMap()
returns the smart groups map with id as key and name as value
void setSmartgroupName(QString)
sets the smart group Name
bool eventFilter(QObject *, QEvent *)
Event filter to capture tagsLineEdit out of focus.
bool mGrouppingMode
Mode to display the symbol list.
void setBold(QStandardItem *)
sets the text of the item with bold font
QgsVectorGradientColorRampV2 * cloneGradientRamp() const
void symbolSelected(const QModelIndex &)
Perform symbol specific tasks when selected.
void groupSymbolsAction()
carryout symbol grouping using check boxes
bool detagSymbol(StyleEntity type, QString symbol, QStringList tags)
detags the symbol with the given list
Definition: qgsstylev2.cpp:878
bool removeSymbol(QString name)
remove symbol from style (and delete it)
Definition: qgsstylev2.cpp:138
bool addColorRamp(QString name, QgsVectorColorRampV2 *colorRamp, bool update=false)
add color ramp to style. takes ramp's ownership
Definition: qgsstylev2.cpp:188
void listitemsContextMenu(const QPoint &)
Context menu for the listItems ( symbols list )
bool tagSymbol(StyleEntity type, QString symbol, QStringList tags)
tags the symbol with the tags in the list
Definition: qgsstylev2.cpp:826
bool removeColorRamp(QString name)
remove color ramp from style (and delete it)
Definition: qgsstylev2.cpp:242
void editSmartgroupAction()
edit the selected smart group
void populateColorRamps(QStringList colorRamps, bool checkable=false)
populate list view with color ramps
int addGroup(QString groupName, int parent=0)
adds a new group and returns the group's id
Definition: qgsstylev2.cpp:601
static QString addColorRampStatic(QWidget *parent, QgsStyleV2 *style, QString RampType=QString())
open add color ramp dialog, return color ramp's name if the ramp has been added
void enableGroupInputs(bool)
Enables or disables the groupTree specific inputs.
void enableSymbolInputs(bool)
Enables or disbables the symbol specific inputs.
QgsVectorColorRampV2 * colorRamp(QString name)
return a NEW copy of color ramp
Definition: qgsstylev2.cpp:260
void onFinished()
called when the dialog is going to be closed
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstylev2.h:80
QStringList findSymbols(StyleEntity type, QString qword)
return the names of the symbols which have a matching 'substring' in its defintion ...
Definition: qgsstylev2.cpp:752
bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
Definition: qgslayertree.h:34
void regrouped(QStandardItem *)
symbol changed from one group
QStringList groupNames()
return the all the groups in the style
Definition: qgsstylev2.cpp:454
QgsSmartConditionMap smartgroup(int id)
returns the QgsSmartConditionMap for the given id
QString conditionOperator()
returns the AND/OR condition
bool addColorRamp()
add a new color ramp to style
#define tr(sourceText)
int groupId(QString group)
return the DB id for the given group name
Definition: qgsstylev2.cpp:998
void populateList()
adds symbols of some type to list