@@ -148,7 +148,7 @@ void QgsStyleV2ManagerDialog::populateList()
148
148
149
149
if ( itemType < 3 )
150
150
{
151
- populateSymbols ( itemType );
151
+ groupChanged ( groupTree-> selectionModel ()-> currentIndex () );
152
152
}
153
153
else if ( itemType == 3 )
154
154
{
@@ -160,6 +160,10 @@ void QgsStyleV2ManagerDialog::populateList()
160
160
}
161
161
}
162
162
163
+ /*
164
+ * Replaced with groupChanged() multiuse function
165
+ *
166
+
163
167
void QgsStyleV2ManagerDialog::populateSymbols( int type )
164
168
{
165
169
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
@@ -185,6 +189,8 @@ void QgsStyleV2ManagerDialog::populateSymbols( int type )
185
189
186
190
}
187
191
192
+ */
193
+
188
194
void QgsStyleV2ManagerDialog::populateColorRamps ()
189
195
{
190
196
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model () );
@@ -570,19 +576,27 @@ void QgsStyleV2ManagerDialog::populateGroups()
570
576
{
571
577
QStandardItemModel *model = qobject_cast<QStandardItemModel*>( groupTree->model () );
572
578
model->clear ();
573
- // Add the groups
574
- // 1. recently used
575
- // 2. project
576
- // 3. all symbol
577
- // 4. group
578
- // QStandardItem *allSymbols = new QStandardItem( "All Symbols" );
579
+
580
+ QStandardItem *allSymbols = new QStandardItem ( " All Symbols" );
581
+ allSymbols->setData ( QVariant ( " all" ) );
582
+ model->appendRow ( allSymbols );
583
+
584
+ QStandardItem *projectSymbols = new QStandardItem ( " Project Symbols" );
585
+ projectSymbols->setData ( " project" );
586
+ model->appendRow ( projectSymbols );
587
+
588
+ QStandardItem *recent = new QStandardItem ( " Recently Used" );
589
+ recent->setData ( QVariant ( " recent" ) );
590
+ model->appendRow ( recent );
579
591
580
592
QStandardItem *group = new QStandardItem ( " " ); // require empty name to get first order groups
593
+ group->setData ( QVariant ( " groups" ) );
581
594
buildGroupTree ( group );
582
595
group->setText ( " Groups" );// set title later
583
596
model->appendRow ( group );
584
597
585
- QStandardItem *tag = new QStandardItem ( " Tags" );
598
+ QStandardItem *tag = new QStandardItem ( " Smart Groups" );
599
+ tag->setData ( QVariant ( " tags" ) );
586
600
buildTagTree ( tag );
587
601
model->appendRow ( tag );
588
602
@@ -597,29 +611,63 @@ void QgsStyleV2ManagerDialog::buildGroupTree( QStandardItem* &parent )
597
611
QStandardItem *item = new QStandardItem ( i.value () );
598
612
item->setData ( QVariant ( i.key () ) );
599
613
parent->appendRow ( item );
600
- QgsDebugMsg ( " Added Group: " + i.value () );
601
614
buildGroupTree ( item );
602
615
++i;
603
616
}
604
-
605
617
}
618
+
606
619
void QgsStyleV2ManagerDialog::buildTagTree ( QStandardItem* &parent )
607
620
{
608
- Q_UNUSED ( parent );
609
- // FIXME
610
-
621
+ QgsSymbolTagMap tags;
622
+ QgsSymbolTagMap::const_iterator i = tags.constBegin ();
623
+ while ( i != tags.constEnd () )
624
+ {
625
+ QStandardItem *item = new QStandardItem ( i.value () );
626
+ item->setData ( QVariant ( i.key () ) );
627
+ parent->appendRow ( item );
628
+ ++i;
629
+ }
611
630
}
612
631
613
632
void QgsStyleV2ManagerDialog::groupChanged ( const QModelIndex& index )
614
633
{
615
- int groupId = index . data ( Qt::UserRole + 1 ). toInt () ;
634
+ QStringList symbolNames ;
616
635
636
+ QString category = index .data ( Qt::UserRole + 1 ).toString ();
637
+ if ( category == " all" || category == " groups" || category == " tags" )
638
+ {
639
+ symbolNames = mStyle ->symbolNames ();
640
+ }
641
+ else if ( category == " recent" )
642
+ {
643
+ // TODO add session symbols
644
+ symbolNames = QStringList ();
645
+ }
646
+ else if ( category == " project" )
647
+ {
648
+ // TODO add project symbols
649
+ symbolNames = QStringList ();
650
+ }
651
+ else
652
+ {
653
+ // determine groups and tags
654
+ if ( index .parent ().data ( Qt::UserRole + 1 ) == " tags" )
655
+ {
656
+ int tagId = index .data ( Qt::UserRole + 1 ).toInt ();
657
+ symbolNames = mStyle ->symbolsWithTag ( tagId );
658
+ }
659
+ else // then it must be a group
660
+ {
661
+ int groupId = index .data ( Qt::UserRole + 1 ).toInt ();
662
+ symbolNames = mStyle ->symbolsOfGroup ( groupId );
663
+ }
664
+ }
665
+
666
+ // Populate the symbols based upon the generated symbolNames List
617
667
int type = currentItemType ();
618
668
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model () );
619
669
model->clear ();
620
670
621
- QStringList symbolNames = mStyle ->symbolsOfGroup ( groupId );
622
-
623
671
for ( int i = 0 ; i < symbolNames.count (); ++i )
624
672
{
625
673
QString name = symbolNames[i];
0 commit comments