issue 826 sort group names in alphabetical case insensitive order

--HG--
branch : feature
This commit is contained in:
Ronan Le Tiec 2018-03-25 18:21:55 +02:00
parent e3f48b797f
commit 6ce7ac1248
2 changed files with 12 additions and 9 deletions

View File

@ -4124,7 +4124,6 @@ void MainWindow::InitDocksContain()
groupsWidget = new VWidgetGroups(doc, this); groupsWidget = new VWidgetGroups(doc, this);
ui->dockWidgetGroups->setWidget(groupsWidget); ui->dockWidgetGroups->setWidget(groupsWidget);
connect(doc,&VAbstractPattern::UpdateGroups , groupsWidget, &VWidgetGroups::UpdateGroups); connect(doc,&VAbstractPattern::UpdateGroups , groupsWidget, &VWidgetGroups::UpdateGroups);
connect(doc,&VAbstractPattern::UpdateGroups , groupsWidget, &VWidgetGroups::UpdateGroups);
detailsWidget = new VWidgetDetails(pattern, doc, this); detailsWidget = new VWidgetDetails(pattern, doc, this);
connect(doc, &VPattern::FullUpdateFromFile, detailsWidget, &VWidgetDetails::UpdateList); connect(doc, &VPattern::FullUpdateFromFile, detailsWidget, &VWidgetDetails::UpdateList);

View File

@ -157,12 +157,14 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI
{ {
QMenu *menuAddToGroup = menu.addMenu(QIcon::fromTheme("list-add"), tr("Add to group")); QMenu *menuAddToGroup = menu.addMenu(QIcon::fromTheme("list-add"), tr("Add to group"));
QMap<quint32,QString>::iterator i; QStringList list = QStringList(groupsNotContainingItem.values());
for(i = groupsNotContainingItem.begin();i != groupsNotContainingItem.end(); ++i) list.sort(Qt::CaseInsensitive);
for(int i=0; i<list.count(); ++i)
{ {
QAction *actionAddToGroup = menuAddToGroup->addAction(i.value()); QAction *actionAddToGroup = menuAddToGroup->addAction(list[i]);
actionsAddToGroup->addAction(actionAddToGroup); actionsAddToGroup->addAction(actionAddToGroup);
actionAddToGroup->setData(i.key()); actionAddToGroup->setData(groupsNotContainingItem.key(list[i]));
} }
} }
@ -173,12 +175,14 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI
{ {
QMenu *menuRemoveFromGroup = menu.addMenu(QIcon::fromTheme("list-remove"), tr("Remove from group")); QMenu *menuRemoveFromGroup = menu.addMenu(QIcon::fromTheme("list-remove"), tr("Remove from group"));
QMap<quint32,QString>::iterator i; QStringList list = QStringList(groupsContainingItem.values());
for(i = groupsContainingItem.begin();i != groupsContainingItem.end(); ++i) list.sort(Qt::CaseInsensitive);
for(int i=0; i<list.count(); ++i)
{ {
QAction *actionRemoveFromGroup = menuRemoveFromGroup->addAction(i.value()); QAction *actionRemoveFromGroup = menuRemoveFromGroup->addAction(list[i]);
actionsRemoveFromGroup->addAction(actionRemoveFromGroup); actionsRemoveFromGroup->addAction(actionRemoveFromGroup);
actionRemoveFromGroup->setData(i.key()); actionRemoveFromGroup->setData(groupsContainingItem.key(list[i]));
} }
} }