33 ui->TitleLabel->setStyleSheet(
34 "QLabel { background-color:green; color:beige; font:bold14px; border-style:outset; border-width:2px;"
35 "border-radius:10px; border-color:beige; font:bold14px; min-width:10em; padding:6px}");
36 ui->FirstStepLabel->setStyleSheet(
"QLabel { color:#DB5816; font: bold 14px;}");
37 ui->SecondStepLabel->setStyleSheet(
"QLabel { color:#DE8A14; font: bold 14px;}");
38 ui->ThirdStepLabel->setStyleSheet(
"QLabel { color:#8DAA2E; font: bold 14px;}");
39 setWindowTitle(
"Batch Change");
42 ui->ClassCombo->addItems(ListOfClasses);
43 ui->ClassCombo->setEditable(
true);
44 ui->ClassCombo->setEditText(
"Type/Select Classes");
46 ui->AttributeBox->setEnabled(
false);
47 ui->RelationshipBox->setEnabled(
false);
48 ui->NewAttributeGroupBox->setEnabled(
false);
49 ui->NewRelationshipGroupBox->setEnabled(
false);
50 ui->MatchButton->setEnabled(
false);
51 ui->FilterUid->setText(
"*");
52 ui->AttributeValueFilter->setText(
"*");
59 std::vector<dref>& Objects,
69 ui->ClassCombo->setCurrentIndex(
ui->ClassCombo->findText(
TableClass));
70 ui->SubclassesCheckBox->setEnabled(
false);
74 setWindowTitle(
"Batch change - Table");
75 ui->FilterGroupBox->hide();
78 ui->FirstStepLabel->hide();
79 ui->SecondStepLabel->hide();
80 ui->ThirdStepLabel->hide();
83 ui->TitleLabel->setText(
"Batch Change of multiple objects - Table");
91 connect(
ui->ClassCombo, SIGNAL(activated(QString)),
this, SLOT(
FillInfo(
const QString&)));
93 connect(
ui->ChangeButton, SIGNAL(clicked()),
this, SLOT(
MakeChanges()));
95 connect(
ui->MatchButton, SIGNAL(clicked()),
this, SLOT(
FindMatching()));
97 connect(
ui->NewRelationshipComboBox, SIGNAL(activated(QString)),
this, SLOT(
EnableCheckBox(QString)));
98 connect(
ui->CancelButton, SIGNAL(clicked()),
this, SLOT(close()));
106 if (mainwin !=
nullptr) {
107 connect(
this, SIGNAL(
sig_batch_change_start()), mainwin, SLOT(slot_batch_change_start()), Qt::UniqueConnection);
111 SLOT(slot_batch_change_stop(
const QList<QPair<QString, QString>>&)),
112 Qt::UniqueConnection);
130 std::vector<dunedaq::conffwk::attribute_t>
const& attributes = cinfo.
p_attributes;
131 std::vector<dunedaq::conffwk::relationship_t>
const& relations = cinfo.
p_relationships;
134 std::vector<dref> filtered;
136 if (!
ui->FilterUid->text().isEmpty()) {
137 QRegExp uidfilter(
ui->FilterUid->text());
138 uidfilter.setPatternSyntax(QRegExp::Wildcard);
142 if (uidfilter.exactMatch(QString::fromStdString(it.ref().UID()))) {
143 filtered.push_back(it);
152 QRegExp attribute_filter(
ui->AttributeValueFilter->text());
153 attribute_filter.setPatternSyntax(QRegExp::Wildcard);
155 std::string selected_attribute_name =
ui->AttributeComboBox->currentText().toStdString();
157 std::vector<dunedaq::conffwk::attribute_t>::const_iterator attrdef =
158 std::find_if(std::begin(attributes),
159 std::end(attributes),
161 return attr.
p_name == selected_attribute_name;
164 if (attrdef != std::end(attributes)) {
168 for (QString& v : values)
169 if (attribute_filter.exactMatch(v)) {
170 filtered.push_back(it);
181 std::string selected_relation_name =
ui->RelationshipComboBox->currentText().toStdString();
183 std::vector<dunedaq::conffwk::relationship_t>::const_iterator relationdef = std::find_if(
185 return rel.
p_name == selected_relation_name;
188 if (relationdef != std::end(relations)) {
189 QRegExp relation_filter(
ui->RelationshipValueFilter->currentText());
190 relation_filter.setPatternSyntax(QRegExp::Wildcard);
195 if (ValueList.isEmpty() and
196 (
ui->RelationshipValueFilter->currentText() ==
"*" or
ui->RelationshipValueFilter->currentText() ==
"")) {
197 filtered.push_back(it);
199 for (QString
const& v : ValueList)
200 if (relation_filter.exactMatch(v)) {
201 filtered.push_back(it);
215 ui->AttributeBox->setEnabled(
false);
216 ui->RelationshipBox->setEnabled(
false);
217 ui->NewAttributeGroupBox->setEnabled(
false);
218 ui->NewRelationshipGroupBox->setEnabled(
false);
221 const std::vector<dunedaq::conffwk::attribute_t> AttributeList = ClassInfo.
p_attributes;
222 const std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.
p_relationships;
224 QStringList ValueList;
227 ValueList.append(QString(Attribute.p_name.c_str()));
230 ui->AttributeComboBox->clear();
231 ui->NewAttributeComboBox->clear();
232 ui->AttributeComboBox->addItems(ValueList);
233 ui->NewAttributeComboBox->addItems(ValueList);
235 if (!AttributeList.empty() && !
UseTable) {
236 ui->AttributeBox->setEnabled(
true);
237 ui->NewAttributeGroupBox->setEnabled(
true);
238 ui->MatchButton->setEnabled(
true);
241 if (!AttributeList.empty() &&
UseTable) {
242 ui->NewAttributeGroupBox->setEnabled(
true);
248 ValueList.append(QString(Relationship.p_name.c_str()));
251 ui->RelationshipComboBox->clear();
252 ui->NewRelationshipComboBox->clear();
253 ui->RelationshipComboBox->addItems(ValueList);
254 ui->NewRelationshipComboBox->addItems(ValueList);
256 if (!RelationshipList.empty() && !
UseTable) {
257 ui->RelationshipBox->setEnabled(
true);
258 ui->NewRelationshipGroupBox->setEnabled(
true);
259 ui->MatchButton->setEnabled(
true);
262 if (!RelationshipList.empty() &&
UseTable) {
263 ui->NewRelationshipGroupBox->setEnabled(
true);
269 ui->RelationshipValueFilter->setCurrentIndex(0);
270 ui->RelationshipEdit->setCurrentIndex(-1);
273 ui->RelationshipEdit->setCurrentIndex(-1);
286 std::vector<dref> Objects;
288 BOOST_SCOPE_EXIT(&Objects, this_)
290 QList<QPair<QString, QString>> objs;
291 for (
const auto& o : Objects) {
292 objs.append(QPair<QString, QString>(QString::fromStdString(o.class_name()), QString::fromStdString(o.UID())));
297 QApplication::restoreOverrideCursor();
298 this_->ui->ChangeButton->setEnabled(
true);
303 ui->ChangeButton->setEnabled(
false);
304 QApplication::setOverrideCursor(Qt::WaitCursor);
307 bool SubClasses =
ui->SubclassesCheckBox->isChecked();
308 QString ClassName =
ui->ClassCombo->currentText();
317 std::copy(tmprefs.begin(), tmprefs.end(), std::back_inserter(Objects));
319 if (not Objects.empty()) {
320 filter(Objects, ClassName);
327 QMessageBox::information(
this, tr(
"Message"), tr(
"No objects match filter!"));
331 const std::vector<dunedaq::conffwk::attribute_t> AttributeList = ClassInfo.
p_attributes;
332 const std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.
p_relationships;
337 if (i.p_name ==
ui->NewAttributeComboBox->currentText().toStdString()) {
343 if (i.p_name ==
ui->NewRelationshipComboBox->currentText().toStdString()) {
344 RelationshipChange = i;
348 QStringList AttributeChangeList;
350 if (!
ui->AttributeEdit->text().isEmpty())
351 AttributeChangeList <<
ui->AttributeEdit->text();
353 for (
auto objects_iter = Objects.begin(); objects_iter != Objects.end(); ++objects_iter) {
354 tref Object = objects_iter->
ref();
356 QStringList RelationshipChangeList;
358 if (
ui->ChangeAtrributeCheckBox->isChecked()) {
359 if (!AttributeChangeList.isEmpty()) {
364 if (
ui->ChangeRelationshipCheckBox->isChecked()) {
365 if (
ui->AddCheckBox->isChecked()) {
369 RelationshipChangeList <<
ui->RelationshipEdit->currentText();
379 QString ClassName =
ui->ClassCombo->currentText();
380 bool SubClasses =
ui->SubclassesCheckBox->isChecked();
384 std::vector<dref> candidates;
385 std::copy(tmprefs.begin(), tmprefs.end(), std::back_inserter(candidates));
387 if (!candidates.empty()) {
388 filter(candidates, ClassName);
391 if (candidates.empty()) {
392 QMessageBox::information(
this, tr(
"Message"), tr(
"No objects match filter!"));
394 int NumberOfColumns = 1;
395 bool AttributeEnabled =
false;
396 bool RelationshipEnabled =
false;
398 if (
ui->AttributeComboBox->isEnabled()) {
399 AttributeEnabled =
true;
403 if (
ui->RelationshipComboBox->isEnabled()) {
404 RelationshipEnabled =
true;
408 m_filter_table = std::unique_ptr<QTableWidget>(
new QTableWidget());
413 for (
size_t i = 0; i < candidates.size(); i++) {
414 QTableWidgetItem* AttributeValue;
415 QTableWidgetItem* RelationshipValue;
417 QTableWidgetItem* ObjectUid =
new QTableWidgetItem(
418 tr(
"%1@%2").arg(candidates.at(i).UID().c_str()).arg(candidates.at(i).class_name().c_str()));
421 if (AttributeEnabled) {
428 AttributeValue =
new QTableWidgetItem(AttributeValueList.join(
" "));
432 if (RelationshipEnabled) {
439 RelationshipValue =
new QTableWidgetItem(RelationshipList.join(
" "));
445 Headers <<
"Object Id";
447 if (AttributeEnabled) {
448 Headers <<
ui->AttributeComboBox->currentText();
451 if (RelationshipEnabled) {
452 Headers <<
ui->RelationshipComboBox->currentText();
458 HeaderView->setStretchLastSection(
true);
467 QString ClassName =
ui->ClassCombo->currentText();
470 std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.
p_relationships;
473 if (i.p_name == RelationshipName.toStdString()) {
475 ui->AddCheckBox->setEnabled(
true);
477 ui->AddCheckBox->setEnabled(
false);
488 ui->RelationshipValueFilter->clear();
489 ui->RelationshipValueFilter->addItem(
"*");
491 QString ClassName =
ui->ClassCombo->currentText();
492 QString RelationshipName =
ui->RelationshipComboBox->currentText();
496 std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.
p_relationships;
498 if (RelationshipList.size() != 0) {
502 if (i.p_name == RelationshipName.toStdString()) {
503 ChosenRelationship = i;
510 QStringList ObjectsUid;
512 for (
tref const& Object : Objects) {
513 ObjectsUid.append(Object.UID().c_str());
516 ui->RelationshipValueFilter->addItems(ObjectsUid);
523 ui->RelationshipEdit->clear();
525 QString ClassName =
ui->ClassCombo->currentText();
526 QString RelationshipName =
ui->NewRelationshipComboBox->currentText();
530 std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.
p_relationships;
532 if (RelationshipList.size() != 0) {
536 if (i.p_name == RelationshipName.toStdString()) {
537 ChosenRelationship = i;
544 QStringList ObjectsUid;
546 for (
tref const& Object : Objects) {
547 ObjectsUid.append(Object.UID().c_str());
550 ui->RelationshipEdit->addItems(ObjectsUid);
static MainWindow * findthis()