@@ -75,6 +75,12 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
7575 listItems->setModel ( model );
7676
7777 connect ( model, SIGNAL ( itemChanged ( QStandardItem* ) ), this , SLOT ( itemChanged ( QStandardItem* ) ) );
78+ // TODO take up the selectiopn model for the symbols
79+ // connect currentChanged signal to a slot which would populate the tags for that symbol
80+ // as comma seperated values in tagLineEdit and fill the mTagList
81+ //
82+ connect ( listItems->selectionModel (), SIGNAL ( currentChanged ( const QModelIndex&, const QModelIndex& ) ),
83+ this , SLOT ( symbolSelected ( const QModelIndex& ) ) );
7884
7985 populateTypes ();
8086
@@ -105,6 +111,7 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
105111 populateList ();
106112
107113 connect ( searchBox, SIGNAL ( textChanged ( QString ) ), this , SLOT ( filterSymbols ( QString ) ) );
114+ connect ( tagBtn, SIGNAL ( clicked () ), this , SLOT ( tagsChanged () ) );
108115
109116}
110117
@@ -622,7 +629,7 @@ void QgsStyleV2ManagerDialog::populateGroups()
622629 QStandardItem *tag = new QStandardItem ( " Smart Groups" );
623630 tag->setData ( " tags" );
624631 tag->setEditable ( false );
625- buildTagTree ( tag );
632+ // TODO populate/build smart groups
626633 model->appendRow ( tag );
627634
628635}
@@ -641,19 +648,6 @@ void QgsStyleV2ManagerDialog::buildGroupTree( QStandardItem* &parent )
641648 }
642649}
643650
644- void QgsStyleV2ManagerDialog::buildTagTree ( QStandardItem* &parent )
645- {
646- QgsSymbolTagMap tags = mStyle ->symbolTags ();
647- QgsSymbolTagMap::const_iterator i = tags.constBegin ();
648- while ( i != tags.constEnd () )
649- {
650- QStandardItem *item = new QStandardItem ( i.value () );
651- item->setData ( i.key () );
652- parent->appendRow ( item );
653- ++i;
654- }
655- }
656-
657651void QgsStyleV2ManagerDialog::groupChanged ( const QModelIndex& index )
658652{
659653 QStringList symbolNames;
@@ -933,7 +927,8 @@ void QgsStyleV2ManagerDialog::regrouped( QStandardItem *item )
933927 regrouped = mStyle ->regroup ( symbolName, 0 );
934928 if ( !regrouped )
935929 {
936- int er = QMessageBox::critical ( this , tr ( " Database Error" ), tr ( " There was a problem with the Symbols database while regrouping." ) );
930+ int er = QMessageBox::critical ( this , tr ( " Database Error" ),
931+ tr ( " There was a problem with the Symbols database while regrouping." ) );
937932 // call the slot again to get back to normal
938933 if ( er )
939934 groupSymbolsAction ();
@@ -961,3 +956,38 @@ void QgsStyleV2ManagerDialog::filterSymbols( QString qword )
961956 QStringList symbols = mStyle ->findSymbols ( qword );
962957 populateSymbols ( symbols );
963958}
959+
960+ void QgsStyleV2ManagerDialog::tagsChanged ()
961+ {
962+ QStringList addtags;
963+ QStringList removetags;
964+
965+ QStringList oldtags = mTagList ;
966+ QStringList newtags = tagsLineEdit->text ().split ( " ," , QString::SkipEmptyParts );
967+
968+ // compare old with new to find removed tags
969+ foreach ( const QString &tag, oldtags )
970+ {
971+ if ( !newtags.contains ( tag ) )
972+ removetags.append ( tag );
973+ }
974+ if ( removetags.size () > 0 )
975+ mStyle ->detagSymbol ( currentItemName (), removetags );
976+
977+ // compare new with old to find added tags
978+ foreach ( const QString &tag, newtags )
979+ {
980+ if ( !oldtags.contains ( tag ) )
981+ addtags.append ( tag );
982+ }
983+ if ( addtags.size () > 0 )
984+ mStyle ->tagSymbol ( currentItemName (), addtags );
985+ }
986+
987+ void QgsStyleV2ManagerDialog::symbolSelected ( const QModelIndex& index )
988+ {
989+ tagsLineEdit->clear ();
990+ QStandardItem *item = static_cast <QStandardItemModel*>( listItems->model () )->itemFromIndex ( index );
991+ mTagList = mStyle ->tagsOfSymbol ( item->data ().toString () );
992+ tagsLineEdit->setText ( mTagList .join ( " ," ) );
993+ }
0 commit comments