@@ -73,6 +73,7 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
73
73
74
74
QStandardItemModel* model = new QStandardItemModel ( listItems );
75
75
listItems->setModel ( model );
76
+ listItems->setSelectionMode ( QAbstractItemView::ExtendedSelection );
76
77
77
78
connect ( model, SIGNAL ( itemChanged ( QStandardItem* ) ), this , SLOT ( itemChanged ( QStandardItem* ) ) );
78
79
connect ( listItems->selectionModel (), SIGNAL ( currentChanged ( const QModelIndex&, const QModelIndex& ) ),
@@ -91,7 +92,8 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
91
92
}
92
93
connect ( groupTree->selectionModel (), SIGNAL ( currentChanged ( const QModelIndex&, const QModelIndex& ) ),
93
94
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* ) ) );
95
97
96
98
QMenu *groupMenu = new QMenu ( " Group Actions" );
97
99
QAction *groupSymbols = groupMenu->addAction ( " Group Symbols" );
@@ -114,6 +116,11 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
114
116
connect ( groupTree, SIGNAL ( customContextMenuRequested ( const QPoint& ) ),
115
117
this , SLOT ( grouptreeContextMenu ( const QPoint& ) ) );
116
118
119
+ // Context menu for listItems
120
+ listItems->setContextMenuPolicy ( Qt::CustomContextMenu );
121
+ connect ( listItems, SIGNAL ( customContextMenuRequested ( const QPoint& ) ),
122
+ this , SLOT ( listitemsContextMenu ( const QPoint& ) ) );
123
+
117
124
}
118
125
119
126
void QgsStyleV2ManagerDialog::onFinished ()
@@ -639,7 +646,7 @@ void QgsStyleV2ManagerDialog::populateGroups()
639
646
640
647
void QgsStyleV2ManagerDialog::buildGroupTree ( QStandardItem* &parent )
641
648
{
642
- QgsSymbolGroupMap groups = mStyle ->groupNames ( parent->text () );
649
+ QgsSymbolGroupMap groups = mStyle ->childGroupNames ( parent->text () );
643
650
QgsSymbolGroupMap::const_iterator i = groups.constBegin ();
644
651
while ( i != groups.constEnd () )
645
652
{
@@ -860,6 +867,8 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
860
867
this , SLOT ( groupRenamed ( QStandardItem* ) ) );
861
868
connect ( model, SIGNAL ( itemChanged ( QStandardItem* ) ),
862
869
this , SLOT ( itemChanged ( QStandardItem* ) ) );
870
+ // Reset the selection mode
871
+ listItems->setSelectionMode ( QAbstractItemView::ExtendedSelection );
863
872
}
864
873
else
865
874
{
@@ -904,6 +913,9 @@ void QgsStyleV2ManagerDialog::groupSymbolsAction()
904
913
// Connect to slot which handles regrouping
905
914
connect ( model, SIGNAL ( itemChanged ( QStandardItem* )),
906
915
this , SLOT ( regrouped ( QStandardItem* ) ) );
916
+
917
+ // No selection should be possible
918
+ listItems->setSelectionMode ( QAbstractItemView::NoSelection );
907
919
}
908
920
}
909
921
@@ -1049,3 +1061,40 @@ void QgsStyleV2ManagerDialog::grouptreeContextMenu( const QPoint& point )
1049
1061
removeGroup ();
1050
1062
}
1051
1063
}
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