24 #include <ArmarXGui/gui-plugins/StatechartEditorPlugin/view/dialogs/ui_RenameGroupDialog.h>
27 #include <QFileDialog>
42 groupRenamer(groupRenamer),
43 validGroupName(
"([a-zA-Z][a-zA-Z0-9]*)"),
44 colorGreen(QColor::fromRgb(120, 255, 120)),
45 colorRed(QColor::fromRgb(255, 120, 120)),
46 colorYellow(QColor::fromRgb(255, 200, 0)),
50 setOkButtonsEnabled(
false);
51 ui->editOldName->setText(group->getName());
52 ui->editOldName->setReadOnly(
true);
55 ui->editNewName->setValidator(
new QRegExpValidator(validGroupName,
this));
57 connect(ui->btnCancel, SIGNAL(clicked()),
this, SLOT(reject()));
59 connect(ui->btnDontSaveAndProceed, SIGNAL(clicked()),
this, SLOT(accept()));
60 connect(ui->editNewName, SIGNAL(textChanged(QString)),
this, SLOT(
verifyNewName(QString)));
69 auto childGroup =
c->getGroup();
70 allGroups.push_back(childGroup);
72 QVector<statechartmodel::StatePtr> allGroupStates = childGroup->getAllStates(
false);
74 bool isDependent = std::find_if(dependencies.constBegin(), dependencies.constEnd(), [&](
const StatechartGroupPtr & g)
76 return g->getGroupPath() == group->getGroupPath();
77 }) != dependencies.constEnd();
79 if (isDependent && childGroup->getGroupPath() != group->getGroupPath())
81 dependantGroups.push_back(childGroup);
85 ui->groupsWidget->setRowCount(dependantGroups.size() + 1);
86 ui->groupsWidget->setColumnCount(1);
87 ui->groupsWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
88 ui->groupsWidget->setHorizontalHeaderLabels({
"Affected Groups"});
90 QTableWidgetItem* groupItem =
new QTableWidgetItem(group->getName());
91 groupItem->setFlags(groupItem->flags() ^ Qt::ItemIsEditable);
92 ui->groupsWidget->setItem(0, 0, groupItem);
94 for (
int i = 0; i < dependantGroups.size(); ++i)
96 QTableWidgetItem* item =
new QTableWidgetItem(dependantGroups[i]->getName());
97 item->setFlags(item->flags() ^ Qt::ItemIsEditable);
98 ui->groupsWidget->setItem(i + 1, 0, item);
102 void RenameGroupDialog::setOkButtonsEnabled(
bool enabled)
104 ui->btnDontSaveAndProceed->setEnabled(
enabled);
105 ui->btnSaveAndProceed->setEnabled(
enabled);
130 return dependantGroups;
140 return ui->editNewName->text();
153 for (
const auto& g : allGroups)
155 if (newName == g->getName())
166 ui->labelNewNameError->setText(
"Name already in use");
167 colorToUse = colorRed;
168 setOkButtonsEnabled(
false);
172 ui->labelNewNameError->setText(
"Valid name");
173 colorToUse = colorGreen;
174 setOkButtonsEnabled(
true);
177 QPalette p(ui->labelNewNameError->palette());
178 p.setColor(ui->labelNewNameError->backgroundRole(), colorToUse);
179 ui->labelNewNameError->setPalette(p);