34 ui->TitleLabel->setStyleSheet (
35 "QLabel { background-color:green; color:beige; font:bold14px; border-style:outset; border-width:2px;"
36 "border-radius:10px; border-color:beige; font:bold14px; min-width:10em; padding:6px}" );
37 ui->FirstStepLabel->setStyleSheet (
"QLabel { color:#DB5816; font: bold 14px;}" );
38 ui->SecondStepLabel->setStyleSheet (
"QLabel { color:#DE8A14; font: bold 14px;}" );
39 ui->ThirdStepLabel->setStyleSheet (
"QLabel { color:#8DAA2E; font: bold 14px;}" );
40 setWindowTitle (
"Batch Change" );
43 ui->ClassCombo->addItems ( ListOfClasses );
44 ui->ClassCombo->setEditable (
true );
45 ui->ClassCombo->setEditText (
"Type/Select Classes" );
47 ui->AttributeBox->setEnabled (
false );
48 ui->RelationshipBox->setEnabled (
false );
49 ui->NewAttributeGroupBox->setEnabled (
false );
50 ui->NewRelationshipGroupBox->setEnabled (
false );
51 ui->MatchButton->setEnabled (
false );
52 ui->FilterUid->setText (
"*" );
53 ui->AttributeValueFilter->setText (
"*" );
59 std::vector<dref> & Objects, QWidget * parent )
69 ui->ClassCombo->setCurrentIndex (
ui->ClassCombo->findText (
TableClass ) );
70 ui->SubclassesCheckBox->setEnabled (
false );
75 setWindowTitle (
"Batch change - Table" );
76 ui->FilterGroupBox->hide();
79 ui->FirstStepLabel->hide();
80 ui->SecondStepLabel->hide();
81 ui->ThirdStepLabel->hide();
84 ui->TitleLabel->setText (
"Batch Change of multiple objects - Table" );
91 connect (
ui->ClassCombo, SIGNAL ( activated ( QString ) ),
this,
92 SLOT (
FillInfo (
const QString & ) ) );
94 connect (
ui->ChangeButton, SIGNAL ( clicked() ),
this, SLOT (
MakeChanges() ) );
96 connect (
ui->MatchButton, SIGNAL ( clicked() ),
this, SLOT (
FindMatching() ) );
98 connect (
ui->NewRelationshipComboBox, SIGNAL ( activated ( QString ) ),
this,
100 connect (
ui->CancelButton, SIGNAL ( clicked() ),
this, SLOT ( close() ) );
102 connect (
ui->RelationshipComboBox, SIGNAL ( activated (
int ) ),
this,
105 connect (
ui->NewRelationshipComboBox, SIGNAL ( activated (
int ) ),
this,
110 if ( mainwin !=
nullptr )
113 SLOT ( slot_batch_change_start() ), Qt::UniqueConnection );
115 SLOT ( slot_batch_change_stop(
const QList<QPair<QString, QString>>&) ),
116 Qt::UniqueConnection );
131 cname.toStdString(),
false );
132 std::vector<dunedaq::conffwk::attribute_t>
const & attributes = cinfo.
p_attributes;
133 std::vector<dunedaq::conffwk::relationship_t>
const & relations = cinfo.
p_relationships;
136 std::vector<dref> filtered;
138 if ( !
ui->FilterUid->text().isEmpty() )
140 QRegExp uidfilter (
ui->FilterUid->text() );
141 uidfilter.setPatternSyntax ( QRegExp::Wildcard );
146 if ( uidfilter.exactMatch ( QString::fromStdString ( it.ref().UID() ) ) )
148 filtered.push_back ( it );
157 QRegExp attribute_filter (
ui->AttributeValueFilter->text() );
158 attribute_filter.setPatternSyntax ( QRegExp::Wildcard );
160 std::string selected_attribute_name =
ui->AttributeComboBox->currentText().toStdString();
162 std::vector<dunedaq::conffwk::attribute_t>::const_iterator attrdef = std::find_if (
163 std::begin ( attributes ), std::end ( attributes ),
166 return attr.
p_name == selected_attribute_name;
169 if ( attrdef != std::end ( attributes ) )
176 for ( QString & v : values )
177 if ( attribute_filter.exactMatch ( v ) )
179 filtered.push_back ( it );
191 std::string selected_relation_name =
192 ui->RelationshipComboBox->currentText().toStdString();
194 std::vector<dunedaq::conffwk::relationship_t>::const_iterator relationdef = std::find_if (
195 std::begin ( relations ), std::end ( relations ),
198 return rel.
p_name == selected_relation_name;
201 if ( relationdef != std::end ( relations ) )
203 QRegExp relation_filter (
ui->RelationshipValueFilter->currentText() );
204 relation_filter.setPatternSyntax ( QRegExp::Wildcard );
208 QStringList ValueList
211 it.ref(), *relationdef ) };
213 if ( ValueList.isEmpty() and (
ui->RelationshipValueFilter->currentText() ==
"*"
214 or
ui->RelationshipValueFilter->currentText() ==
"" ) )
216 filtered.push_back ( it );
220 for ( QString
const & v : ValueList )
221 if ( relation_filter.exactMatch ( v ) )
223 filtered.push_back ( it );
237 ui->AttributeBox->setEnabled (
false );
238 ui->RelationshipBox->setEnabled (
false );
239 ui->NewAttributeGroupBox->setEnabled (
false );
240 ui->NewRelationshipGroupBox->setEnabled (
false );
245 const std::vector<dunedaq::conffwk::attribute_t> AttributeList = ClassInfo.
p_attributes;
246 const std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo
249 QStringList ValueList;
253 ValueList.append ( QString ( Attribute.p_name.c_str() ) );
256 ui->AttributeComboBox->clear();
257 ui->NewAttributeComboBox->clear();
258 ui->AttributeComboBox->addItems ( ValueList );
259 ui->NewAttributeComboBox->addItems ( ValueList );
261 if ( !AttributeList.empty() && !
UseTable )
263 ui->AttributeBox->setEnabled (
true );
264 ui->NewAttributeGroupBox->setEnabled (
true );
265 ui->MatchButton->setEnabled (
true );
268 if ( !AttributeList.empty() &&
UseTable )
270 ui->NewAttributeGroupBox->setEnabled (
true );
277 ValueList.append ( QString ( Relationship.p_name.c_str() ) );
280 ui->RelationshipComboBox->clear();
281 ui->NewRelationshipComboBox->clear();
282 ui->RelationshipComboBox->addItems ( ValueList );
283 ui->NewRelationshipComboBox->addItems ( ValueList );
285 if ( !RelationshipList.empty() && !
UseTable )
287 ui->RelationshipBox->setEnabled (
true );
288 ui->NewRelationshipGroupBox->setEnabled (
true );
289 ui->MatchButton->setEnabled (
true );
292 if ( !RelationshipList.empty() &&
UseTable )
294 ui->NewRelationshipGroupBox->setEnabled (
true );
301 ui->RelationshipValueFilter->setCurrentIndex ( 0 );
302 ui->RelationshipEdit->setCurrentIndex ( -1 );
307 ui->RelationshipEdit->setCurrentIndex ( -1 );
320 std::vector<dref> Objects;
322 BOOST_SCOPE_EXIT(&Objects, this_)
324 QList<QPair<QString, QString>> objs;
325 for(
const auto& o : Objects) {
326 objs.append(QPair<QString, QString>(QString::fromStdString(o.class_name()),
327 QString::fromStdString(o.UID())));
333 QApplication::restoreOverrideCursor();
334 this_->ui->ChangeButton->setEnabled(
true);
339 ui->ChangeButton->setEnabled(
false);
340 QApplication::setOverrideCursor(Qt::WaitCursor);
343 bool SubClasses =
ui->SubclassesCheckBox->isChecked();
344 QString ClassName =
ui->ClassCombo->currentText();
346 std::unique_ptr<dbe::interface::messenger::batch_guard> batchmode (
354 ClassName.toStdString(), SubClasses );
356 std::copy ( tmprefs.begin(), tmprefs.end(), std::back_inserter ( Objects ) );
358 if ( not Objects.empty() )
360 filter ( Objects, ClassName );
368 if ( Objects.empty() ) QMessageBox::information (
this, tr (
"Message" ),
369 tr (
"No objects match filter!" ) );
373 ClassName.toStdString(),
false );
374 const std::vector<dunedaq::conffwk::attribute_t> AttributeList = ClassInfo.
p_attributes;
375 const std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo
381 if ( i.p_name ==
ui->NewAttributeComboBox->currentText().toStdString() )
388 if ( i.p_name ==
ui->NewRelationshipComboBox->currentText().toStdString() )
390 RelationshipChange = i;
394 QStringList AttributeChangeList;
396 if ( !
ui->AttributeEdit->text().isEmpty() ) AttributeChangeList
397 <<
ui->AttributeEdit->text();
399 for (
auto objects_iter = Objects.begin(); objects_iter != Objects.end(); ++objects_iter )
401 tref Object = objects_iter->ref();
403 QStringList RelationshipChangeList;
405 if (
ui->ChangeAtrributeCheckBox->isChecked() )
407 if ( !AttributeChangeList.isEmpty() )
413 if (
ui->ChangeRelationshipCheckBox->isChecked() )
415 if (
ui->AddCheckBox->isChecked() )
417 RelationshipChangeList =
419 Object, RelationshipChange );
422 RelationshipChangeList <<
ui->RelationshipEdit->currentText();
431 QString ClassName =
ui->ClassCombo->currentText();
432 bool SubClasses =
ui->SubclassesCheckBox->isChecked();
435 ClassName.toStdString(), SubClasses );
437 std::vector<dref> candidates;
438 std::copy ( tmprefs.begin(), tmprefs.end(), std::back_inserter ( candidates ) );
440 if ( !candidates.empty() )
442 filter ( candidates, ClassName );
445 if ( candidates.empty() )
447 QMessageBox::information (
this, tr (
"Message" ), tr (
"No objects match filter!" ) );
451 int NumberOfColumns = 1;
452 bool AttributeEnabled =
false;
453 bool RelationshipEnabled =
false;
455 if (
ui->AttributeComboBox->isEnabled() )
457 AttributeEnabled =
true;
461 if (
ui->RelationshipComboBox->isEnabled() )
463 RelationshipEnabled =
true;
467 m_filter_table = std::unique_ptr<QTableWidget> (
new QTableWidget() );
468 m_filter_table->setWindowTitle ( tr (
"Objects matching filter" ) );
472 for (
size_t i = 0; i < candidates.size(); i++ )
474 QTableWidgetItem * AttributeValue;
475 QTableWidgetItem * RelationshipValue;
477 QTableWidgetItem * ObjectUid =
new QTableWidgetItem (
478 tr (
"%1@%2" ).arg ( candidates.at ( i ).UID().c_str() ).arg (
479 candidates.at ( i ).class_name().c_str() ) );
482 if ( AttributeEnabled )
485 ui->AttributeComboBox->currentText(), ClassName );
487 QStringList AttributeValueList
492 AttributeValue =
new QTableWidgetItem ( AttributeValueList.join (
" " ) );
496 if ( RelationshipEnabled )
499 ui->RelationshipComboBox->currentText(), ClassName );
501 QStringList RelationshipList
504 candidates.at ( i ).ref(), Relationship ) };
506 RelationshipValue =
new QTableWidgetItem ( RelationshipList.join (
" " ) );
512 Headers <<
"Object Id";
514 if ( AttributeEnabled )
516 Headers <<
ui->AttributeComboBox->currentText();
519 if ( RelationshipEnabled )
521 Headers <<
ui->RelationshipComboBox->currentText();
527 HeaderView->setStretchLastSection (
true );
561 ui->RelationshipValueFilter->clear();
562 ui->RelationshipValueFilter->addItem (
"*" );
564 QString ClassName =
ui->ClassCombo->currentText();
565 QString RelationshipName =
ui->RelationshipComboBox->currentText();
568 ClassName.toStdString(),
false );
569 std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.
p_relationships;
571 if ( RelationshipList.size() != 0 )
577 if ( i.p_name == RelationshipName.toStdString() )
579 ChosenRelationship = i;
585 ChosenRelationship.
p_type );
587 QStringList ObjectsUid;
589 for (
tref const & Object : Objects )
591 ObjectsUid.append ( Object.UID().c_str() );
594 ui->RelationshipValueFilter->addItems ( ObjectsUid );
600 ui->RelationshipEdit->clear();
602 QString ClassName =
ui->ClassCombo->currentText();
603 QString RelationshipName =
ui->NewRelationshipComboBox->currentText();
606 ClassName.toStdString(),
false );
607 std::vector<dunedaq::conffwk::relationship_t> RelationshipList = ClassInfo.
p_relationships;
609 if ( RelationshipList.size() != 0 )
615 if ( i.p_name == RelationshipName.toStdString() )
617 ChosenRelationship = i;
623 ChosenRelationship.
p_type );
625 QStringList ObjectsUid;
627 for (
tref const & Object : Objects )
629 ObjectsUid.append ( Object.UID().c_str() );
632 ui->RelationshipEdit->addItems ( ObjectsUid );
static MainWindow * findthis()