@@ -73,6 +73,7 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
7373
7474 QStandardItemModel* model = new QStandardItemModel ( listItems );
7575 listItems->setModel ( model );
76+ listItems->setSelectionMode ( QAbstractItemView::ExtendedSelection );
7677
7778 connect ( model, SIGNAL ( itemChanged ( QStandardItem* ) ), this , SLOT ( itemChanged ( QStandardItem* ) ) );
7879 connect ( listItems->selectionModel (), SIGNAL ( currentChanged ( const QModelIndex&, const QModelIndex& ) ),
@@ -91,7 +92,8 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
9192 }
9293 connect ( groupTree->selectionModel (), SIGNAL ( currentChanged ( const QModelIndex&, const QModelIndex& ) ),
9394 this , SLOT ( groupChanged ( const QModelIndex& ) ) );
94- connect ( groupModel, SIGNAL ( itemChanged ( QStandardItem* ) ), this , SLOT ( groupRenamed ( QStandardItem* ) ) );
95+ connect ( groupModel, SIGNAL ( itemChanged ( QStandardItem* ) ),
96+ this , SLOT ( groupRenamed ( QStandardItem* ) ) );
9597
9698 QMenu *groupMenu = new QMenu ( " Group Actions" );
9799 QAction *groupSymbols = groupMenu->addAction ( " Group Symbols" );
@@ -114,6 +116,11 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
114116 connect ( groupTree, SIGNAL ( customContextMenuRequested ( const QPoint& ) ),
115117 this , SLOT ( grouptreeContextMenu ( const QPoint& ) ) );
116118
119+ // Context menu for listItems
120+ listItems->setContextMenuPolicy ( Qt::CustomContextMenu );
121+ connect ( listItems, SIGNAL ( customContextMenuRequested ( const QPoint& ) ),
122+ this , SLOT ( listitemsContextMenu ( const QPoint& ) ) );
123+
117124}
118125
119126void QgsStyleV2ManagerDialog::onFinished ()
@@ -639,7 +646,7 @@ void QgsStyleV2ManagerDialog::populateGroups()
639646
640647void QgsStyleV2ManagerDialog::buildGroupTree ( QStandardItem* &parent )
641648{
642- QgsSymbolGroupMap groups = mStyle ->groupNames ( parent->text () );
649+ QgsSymbolGroupMap groups = mStyle ->childGroupNames ( parent->text () );
643650 QgsSymbolGroupMap::const_iterator i = groups.constBegin ();
644651 while ( i != groups.constEnd () )
645652 {
@@ -860,6 +867,8 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
860867 this , SLOT ( groupRenamed ( QStandardItem* ) ) );
861868 connect ( model, SIGNAL ( itemChanged ( QStandardItem* ) ),
862869 this , SLOT ( itemChanged ( QStandardItem* ) ) );
870+ // Reset the selection mode
871+ listItems->setSelectionMode ( QAbstractItemView::ExtendedSelection );
863872 }
864873 else
865874 {
@@ -904,6 +913,9 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
904913 // Connect to slot which handles regrouping
905914 connect ( model, SIGNAL ( itemChanged ( QStandardItem* )),
906915 this , SLOT ( regrouped ( QStandardItem* ) ) );
916+
917+ // No selection should be possible
918+ listItems->setSelectionMode ( QAbstractItemView::NoSelection );
907919 }
908920}
909921
@@ -1049,3 +1061,40 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
10491061 removeGroup ();
10501062 }
10511063}
1064+
1065+ void QgsStyleV2ManagerDialog::listitemsContextMenu ( const QPoint& point )
1066+ {
1067+ QPoint globalPos = listItems->viewport ()->mapToGlobal ( point );
1068+
1069+ QMenu *groupMenu = new QMenu ( this );
1070+ QMenu *groupList = new QMenu ( this );
1071+ groupList->setTitle ( " Apply Group" );
1072+
1073+ QStringList groups = mStyle ->groupNames ();
1074+ foreach ( QString group, groups )
1075+ {
1076+ groupList->addAction ( group );
1077+ }
1078+ groupMenu->addMenu ( groupList );
1079+
1080+ groupMenu->addAction ( " Un-group" );
1081+
1082+ QAction* selectedItem = groupMenu->exec ( globalPos );
1083+
1084+ if ( selectedItem )
1085+ {
1086+ int groupId = 0 ;
1087+ if ( selectedItem->text () != " Un-group" )
1088+ {
1089+ groupId = mStyle ->groupId ( selectedItem->text () );
1090+ }
1091+ QModelIndexList indexes = listItems->selectionModel ()->selection ().indexes ();
1092+ foreach ( QModelIndex index, indexes )
1093+ {
1094+ mStyle ->regroup ( index.data ().toString (), groupId );
1095+ }
1096+ populateList ();
1097+
1098+ QgsDebugMsg ( " Selected Action: " + selectedItem->text () );
1099+ }
1100+ }
0 commit comments