@@ -148,7 +148,7 @@ void QgsStyleV2ManagerDialog::populateList()
148148
149149 if ( itemType < 3 )
150150 {
151- populateSymbols ( itemType );
151+ groupChanged ( groupTree-> selectionModel ()-> currentIndex () );
152152 }
153153 else if ( itemType == 3 )
154154 {
@@ -160,6 +160,10 @@ void QgsStyleV2ManagerDialog::populateList()
160160 }
161161}
162162
163+ /*
164+ * Replaced with groupChanged() multiuse function
165+ *
166+
163167void QgsStyleV2ManagerDialog::populateSymbols( int type )
164168{
165169 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
@@ -185,6 +189,8 @@ void QgsStyleV2ManagerDialog::populateSymbols( int type )
185189
186190}
187191
192+ */
193+
188194void QgsStyleV2ManagerDialog::populateColorRamps ()
189195{
190196 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model () );
@@ -570,19 +576,27 @@ void QgsStyleV2ManagerDialog::populateGroups()
570576{
571577 QStandardItemModel *model = qobject_cast<QStandardItemModel*>( groupTree->model () );
572578 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 );
579591
580592 QStandardItem *group = new QStandardItem ( " " ); // require empty name to get first order groups
593+ group->setData ( QVariant ( " groups" ) );
581594 buildGroupTree ( group );
582595 group->setText ( " Groups" );// set title later
583596 model->appendRow ( group );
584597
585- QStandardItem *tag = new QStandardItem ( " Tags" );
598+ QStandardItem *tag = new QStandardItem ( " Smart Groups" );
599+ tag->setData ( QVariant ( " tags" ) );
586600 buildTagTree ( tag );
587601 model->appendRow ( tag );
588602
@@ -597,29 +611,63 @@ void QgsStyleV2ManagerDialog::buildGroupTree( QStandardItem* &parent )
597611 QStandardItem *item = new QStandardItem ( i.value () );
598612 item->setData ( QVariant ( i.key () ) );
599613 parent->appendRow ( item );
600- QgsDebugMsg ( " Added Group: " + i.value () );
601614 buildGroupTree ( item );
602615 ++i;
603616 }
604-
605617}
618+
606619void QgsStyleV2ManagerDialog::buildTagTree ( QStandardItem* &parent )
607620{
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+ }
611630}
612631
613632void QgsStyleV2ManagerDialog::groupChanged ( const QModelIndex& index )
614633{
615- int groupId = index. data ( Qt::UserRole + 1 ). toInt () ;
634+ QStringList symbolNames ;
616635
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
617667 int type = currentItemType ();
618668 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model () );
619669 model->clear ();
620670
621- QStringList symbolNames = mStyle ->symbolsOfGroup ( groupId );
622-
623671 for ( int i = 0 ; i < symbolNames.count (); ++i )
624672 {
625673 QString name = symbolNames[i];
0 commit comments