@@ -75,10 +75,6 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
75
75
listItems->setModel ( model );
76
76
77
77
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
78
connect ( listItems->selectionModel (), SIGNAL ( currentChanged ( const QModelIndex&, const QModelIndex& ) ),
83
79
this , SLOT ( symbolSelected ( const QModelIndex& ) ) );
84
80
@@ -173,10 +169,12 @@ void QgsStyleV2ManagerDialog::populateList()
173
169
174
170
if ( itemType < 3 )
175
171
{
172
+ enableSymbolInputs ( true );
176
173
groupChanged ( groupTree->selectionModel ()->currentIndex () );
177
174
}
178
175
else if ( itemType == 3 )
179
176
{
177
+ enableSymbolInputs ( false );
180
178
populateColorRamps ();
181
179
}
182
180
else
@@ -627,7 +625,7 @@ void QgsStyleV2ManagerDialog::populateGroups()
627
625
model->appendRow ( group );
628
626
629
627
QStandardItem *tag = new QStandardItem ( " Smart Groups" );
630
- tag->setData ( " tags " );
628
+ tag->setData ( " smartgroups " );
631
629
tag->setEditable ( false );
632
630
// TODO populate/build smart groups
633
631
model->appendRow ( tag );
@@ -654,30 +652,42 @@ void QgsStyleV2ManagerDialog::groupChanged( const QModelIndex& index )
654
652
QStringList groupSymbols;
655
653
656
654
QString category = index .data ( Qt::UserRole + 1 ).toString ();
657
- if ( category == " all" || category == " groups" || category == " tags " )
655
+ if ( category == " all" || category == " groups" || category == " smartgroups " )
658
656
{
657
+ enableGroupInputs ( false );
658
+ if ( category == " groups" || category == " smartgroups" )
659
+ {
660
+ btnAddGroup->setEnabled ( true );
661
+ }
659
662
symbolNames = mStyle ->symbolNames ();
660
663
}
661
664
else if ( category == " recent" )
662
665
{
663
666
// TODO add session symbols
667
+ enableGroupInputs ( false );
664
668
symbolNames = QStringList ();
665
669
}
666
670
else if ( category == " project" )
667
671
{
668
672
// TODO add project symbols
673
+ enableGroupInputs ( false );
669
674
symbolNames = QStringList ();
670
675
}
671
676
else
672
677
{
673
678
// determine groups and tags
674
- if ( index .parent ().data ( Qt::UserRole + 1 ) == " tags " )
679
+ if ( index .parent ().data ( Qt::UserRole + 1 ) == " smartgroups " )
675
680
{
676
- int tagId = index .data ( Qt::UserRole + 1 ).toInt ();
677
- symbolNames = mStyle ->symbolsWithTag ( tagId );
681
+ // TODO
682
+ // create a new Menu with smart group specific functions
683
+ // and set it to the btnManageGroups
678
684
}
679
685
else // then it must be a group
680
686
{
687
+ if ( index .data () == " Ungrouped" )
688
+ enableGroupInputs ( false );
689
+ else
690
+ enableGroupInputs ( true );
681
691
int groupId = index .data ( Qt::UserRole + 1 ).toInt ();
682
692
symbolNames = mStyle ->symbolsOfGroup ( groupId );
683
693
if ( mGrouppingMode && groupId )
@@ -710,7 +720,7 @@ void QgsStyleV2ManagerDialog::addGroup()
710
720
}
711
721
712
722
// Violation 2: Creating a nested tag
713
- if ( parentIndex.parent ().data ( Qt::UserRole + 1 ).toString () == " tags " )
723
+ if ( parentIndex.parent ().data ( Qt::UserRole + 1 ).toString () == " smartgroups " )
714
724
{
715
725
int err = QMessageBox::critical ( this , tr ( " Operation Not Allowed" ),
716
726
tr ( " Creation of nested Smart Groups are not allowed\n "
@@ -736,7 +746,7 @@ void QgsStyleV2ManagerDialog::removeGroup()
736
746
737
747
// Violation: removing system groups
738
748
QString data = index .data ( Qt::UserRole + 1 ).toString ();
739
- if ( data == " all" || data == " recent" || data == " project" || data == " groups" || data == " tags " || index .data () == " Ungrouped" )
749
+ if ( data == " all" || data == " recent" || data == " project" || data == " groups" || data == " smartgroups " || index .data () == " Ungrouped" )
740
750
{
741
751
int err = QMessageBox::critical ( this , tr ( " Invalid slection" ),
742
752
tr ( " Cannot delete system defined categories.\n "
@@ -746,7 +756,7 @@ void QgsStyleV2ManagerDialog::removeGroup()
746
756
}
747
757
748
758
QStandardItem *parentItem = model->itemFromIndex ( index .parent () );
749
- if ( parentItem->data ( Qt::UserRole + 1 ).toString () == " tags " )
759
+ if ( parentItem->data ( Qt::UserRole + 1 ).toString () == " smartgroups " )
750
760
{
751
761
mStyle ->remove ( TagEntity, index .data ( Qt::UserRole + 1 ).toInt () );
752
762
}
@@ -773,7 +783,7 @@ void QgsStyleV2ManagerDialog::groupRenamed( QStandardItem * item )
773
783
if ( data == " newgroup" )
774
784
{
775
785
int id;
776
- if ( item->parent ()->data ( Qt::UserRole + 1 ).toString () == " tags " )
786
+ if ( item->parent ()->data ( Qt::UserRole + 1 ).toString () == " smartgroups " )
777
787
{
778
788
id = mStyle ->addTag ( item->text () );
779
789
}
@@ -803,7 +813,7 @@ void QgsStyleV2ManagerDialog::groupRenamed( QStandardItem * item )
803
813
{
804
814
int id = item->data ( Qt::UserRole + 1 ).toInt ();
805
815
QString name = item->text ();
806
- if ( item->parent ()->data ( Qt::UserRole + 1 ) == " tags " )
816
+ if ( item->parent ()->data ( Qt::UserRole + 1 ) == " smartgroups " )
807
817
{
808
818
mStyle ->rename ( TagEntity, id, name );
809
819
}
@@ -837,20 +847,7 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
837
847
btnAddGroup->setEnabled ( true );
838
848
btnRemoveGroup->setEnabled ( true );
839
849
// disabel all items except groups in groupTree
840
- for ( int i = 0 ; i < treeModel->rowCount (); i++ )
841
- {
842
- if ( treeModel->item ( i )->text () == " Smart Groups" )
843
- {
844
- for ( int j = 0 ; j < treeModel->item ( i )->rowCount (); j++ )
845
- {
846
- treeModel->item ( i )->child ( j )->setEnabled ( true );
847
- }
848
- }
849
- if ( treeModel->item ( i )->text () != " Groups" )
850
- {
851
- treeModel->item ( i )->setEnabled ( true );
852
- }
853
- }
850
+ enableItemsForGroupingMode ( true );
854
851
groupChanged ( groupTree->currentIndex () );
855
852
// Finally: Reconnect all Symbol editing functionalities
856
853
connect ( treeModel, SIGNAL ( itemChanged ( QStandardItem* ) ),
@@ -860,7 +857,6 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
860
857
}
861
858
else
862
859
{
863
- mGrouppingMode = true ;
864
860
bool validGroup = false ;
865
861
// determine whether it is a valid group
866
862
QModelIndex present = groupTree->currentIndex ();
@@ -876,6 +872,8 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
876
872
}
877
873
if ( !validGroup )
878
874
return ;
875
+
876
+ mGrouppingMode = true ;
879
877
// Change the text menu
880
878
senderAction->setText ( " Finish Grouping" );
881
879
@@ -894,20 +892,7 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
894
892
btnAddGroup->setEnabled ( false );
895
893
btnRemoveGroup->setEnabled ( false );
896
894
// disabel all items except groups in groupTree
897
- for ( int i = 0 ; i < treeModel->rowCount (); i++ )
898
- {
899
- if ( treeModel->item ( i )->text () == " Smart Groups" )
900
- {
901
- for ( int j = 0 ; j < treeModel->item ( i )->rowCount (); j++ )
902
- {
903
- treeModel->item ( i )->child ( j )->setEnabled ( false );
904
- }
905
- }
906
- if ( treeModel->item ( i )->text () != " Groups" )
907
- {
908
- treeModel->item ( i )->setEnabled ( false );
909
- }
910
- }
895
+ enableItemsForGroupingMode ( false );
911
896
groupChanged ( groupTree->currentIndex () );
912
897
913
898
// Connect to slot which handles regrouping
@@ -986,8 +971,52 @@ void QgsStyleV2ManagerDialog::tagsChanged()
986
971
987
972
void QgsStyleV2ManagerDialog::symbolSelected ( const QModelIndex& index )
988
973
{
974
+ // Populate the tags for the symbol
989
975
tagsLineEdit->clear ();
990
976
QStandardItem *item = static_cast <QStandardItemModel*>( listItems->model () )->itemFromIndex ( index );
991
977
mTagList = mStyle ->tagsOfSymbol ( item->data ().toString () );
992
978
tagsLineEdit->setText ( mTagList .join ( " ," ) );
993
979
}
980
+
981
+ void QgsStyleV2ManagerDialog::enableSymbolInputs ( bool enable )
982
+ {
983
+ groupTree->setEnabled ( enable );
984
+ tagBtn->setEnabled ( enable );
985
+ btnAddGroup->setEnabled ( enable );
986
+ btnRemoveGroup->setEnabled ( enable );
987
+ btnManageGroups->setEnabled ( enable );
988
+ searchBox->setEnabled ( enable );
989
+ tagsLineEdit->setEnabled ( enable );
990
+ }
991
+
992
+ void QgsStyleV2ManagerDialog::enableGroupInputs ( bool enable )
993
+ {
994
+ btnAddGroup->setEnabled ( enable );
995
+ btnRemoveGroup->setEnabled ( enable );
996
+ btnManageGroups->setEnabled ( enable );
997
+ }
998
+
999
+ void QgsStyleV2ManagerDialog::enableItemsForGroupingMode ( bool enable )
1000
+ {
1001
+ QStandardItemModel *treeModel = qobject_cast<QStandardItemModel*>( groupTree->model () );
1002
+ for ( int i = 0 ; i < treeModel->rowCount (); i++ )
1003
+ {
1004
+ if ( treeModel->item ( i )->text () != " Groups" )
1005
+ {
1006
+ treeModel->item ( i )->setEnabled ( enable );
1007
+ }
1008
+ if ( treeModel->item ( i )->text () == " Groups" )
1009
+ {
1010
+ treeModel->item ( i )->setEnabled ( enable );
1011
+ treeModel->item ( i )->child ( treeModel->item ( i )->rowCount () - 1 )->setEnabled ( enable );
1012
+ }
1013
+ if ( treeModel->item ( i )->text () == " Smart Groups" )
1014
+ {
1015
+ for ( int j = 0 ; j < treeModel->item ( i )->rowCount (); j++ )
1016
+ {
1017
+ treeModel->item ( i )->child ( j )->setEnabled ( enable );
1018
+ }
1019
+ }
1020
+ }
1021
+
1022
+ }
0 commit comments