200 const wxString fieldName = wxS(
"GroupedState" );
201 const wxString fieldValue = wxS(
"Original" );
202 std::set<SCH_SYMBOL*> symbols;
208 if( !symbols.insert( symbol ).second )
218 model.AddColumn( fieldName, fieldName,
false );
221 int fieldCol =
model.GetFieldNameCol( fieldName );
225 model.SetShowColumn( referenceCol,
true );
226 model.SetShowColumn( fieldCol,
true );
227 model.SetGroupingEnabled(
true );
228 model.SetGroupColumn( fieldCol,
true );
234 for(
int row = 0; row <
model.GetNumberRows() && groupedRow < 0; ++row )
236 const std::vector<SCH_REFERENCE> refs =
model.GetRowReferences( row );
238 for(
size_t ii = 1; ii < refs.size(); ++ii )
240 if( refs[ii].GetSymbol() != refs[0].GetSymbol() )
243 symbolToModify = refs[ii].GetSymbol();
255 BOOST_CHECK( !
model.IsCellEdited( groupedRow, referenceCol ) );
256 BOOST_CHECK(
model.IsCellEdited( groupedRow, fieldCol ) );
257 BOOST_CHECK(
model.IsRowEdited( groupedRow ) );
303 auto model = MakeScopedModel( wxEmptyString, wxS(
"${DNP}" ) );
308 variant.
m_DNP =
true;
314 model->CopyCellFromVariant( m_row, m_col, wxS(
"Source" ) );
316 BOOST_CHECK( !m_symbol->GetDNP() );
318 model->SetCurrentVariant( wxS(
"Source" ) );
319 BOOST_CHECK( !
model->CanCopyCellFromVariant( m_row, m_col ) );
320 model->CopyCellFromVariant( m_row, m_col, wxEmptyString );
321 model->SetCurrentVariant( wxEmptyString );
323 BOOST_CHECK( m_symbol->GetDNP() );
543 auto model = MakeScopedModel( wxEmptyString,
name );
545 field->
SetText( wxS(
"base" ) );
546 model->UpdateReferences( m_refs );
547 m_schematic->AddVariant( wxS(
"A" ) );
548 model->SetCurrentVariant( wxS(
"A" ) );
549 model->SetValue( m_row, m_col, wxS(
"A staged" ) );
550 model->RenameStoredVariant( wxS(
"A" ), wxS(
"Renamed" ) );
551 m_schematic->RenameVariant( wxS(
"A" ), wxS(
"Renamed" ) );
555 m_schematic->AddVariant( wxS(
"Deleted" ) );
556 model->SetCurrentVariant( wxS(
"Deleted" ) );
557 model->SetValue( m_row, m_col, wxS(
"discarded" ) );
558 model->DeleteStoredVariant( wxS(
"Deleted" ) );
559 m_schematic->DeleteVariant( wxS(
"Deleted" ) );
560 model->SetCurrentVariant( wxS(
"Renamed" ) );
595 auto model = MakeScopedModel( wxEmptyString, valueName );
596 int valueCol = m_col;
598 field->
SetText( wxS(
"live" ) );
599 model->UpdateReferences( m_refs );
600 model->AddColumn( wxS(
"Nested" ), wxS(
"Nested" ),
true );
601 int nestedCol =
model->GetFieldNameCol( wxS(
"Nested" ) );
602 model->SetValue( m_row, nestedCol, wxS(
"Value: ${vAlUe}" ) );
603 model->AddColumn( wxS(
"Report" ), wxS(
"Report" ),
true );
604 int reportCol =
model->GetFieldNameCol( wxS(
"Report" ) );
605 model->SetShowColumn( reportCol,
true );
606 model->SetValue( m_row, reportCol, wxS(
"${REFERENCE}: ${NESTED}" ) );
607 model->SetValue( m_row, valueCol, wxS(
"base staged" ) );
608 wxString prefix = m_symbol->GetRef( &m_scopePath,
true ) + wxS(
": Value: " );
610 BOOST_CHECK(
model->Export(
BOM_FMT_PRESET() ).Contains( prefix + wxS(
"base staged" ) ) );
612 model->SetCurrentVariant( wxS(
"A" ) );
613 model->SetValue( m_row, nestedCol, wxS(
"Value: ${VALUE}" ) );
614 model->SetValue( m_row, reportCol, wxS(
"${REFERENCE}: ${Nested}" ) );
615 model->SetValue( m_row, valueCol, wxS(
"A staged" ) );
617 model->SetCurrentVariant( wxEmptyString );
658 m_symbol.SetKeyWords( wxS(
"original keywords" ) );
659 m_symbol.GetDescriptionField().SetText( wxS(
"Monostable" ) );
670 model.AddColumn( footprint, footprint,
false );
671 model.SetShowColumn( 0,
true );
672 model.AddColumn( keywords, keywords,
false );
673 model.SetShowColumn( 1,
true );
674 model.AddColumn( wxS(
"PartNumber" ), wxS(
"PartNumber" ),
false );
678 model.AddColumn( description, description,
false );
679 model.AddColumn( value, value,
false );
683 auto rowFor = [&](
const LIB_SYMBOL* aSymbol )
685 for(
int row = 0; row <
model.GetNumberRows(); ++row )
687 if(
model.GetSymbolForRow( row ) == aSymbol )
694 const int parentRow = rowFor( &m_symbol );
695 const int childRow = rowFor( &child );
696 const int grandchildRow = rowFor( &grandchild );
697 BOOST_REQUIRE( parentRow >= 0 && childRow >= 0 && grandchildRow >= 0 );
699 BOOST_CHECK( !
model.CanUseParentValue( parentRow, 0 ) );
700 BOOST_CHECK( !
model.CanUseParentValue( parentRow, 1 ) );
701 BOOST_CHECK( !
model.CanUseParentValue( childRow, 0 ) );
702 BOOST_CHECK( !
model.CanUseParentValue( childRow, 1 ) );
703 BOOST_CHECK( !
model.CanUseParentValue( childRow, 2 ) );
704 BOOST_CHECK(
model.CanUseParentValue( childRow, 3 ) );
705 BOOST_CHECK( !
model.CanUseParentValue( childRow, 4 ) );
706 BOOST_CHECK( !
model.CanUseParentValue( childRow, 5 ) );
707 model.UseParentValue( parentRow, 0 );
708 model.UseParentValue( childRow, 4 );
712 BOOST_CHECK(
model.GetValue( childRow, 1 ).IsEmpty() );
721 model.SetValue( parentRow, 0, wxS(
"Package_DIP:DIP-16_W7.62mm" ) );
722 model.SetValue( parentRow, 1, wxS(
"staged keywords" ) );
723 model.SetValue( parentRow, 3, wxS(
"New description" ) );
725 BOOST_CHECK(
model.GetValue( childRow, 0 ).IsEmpty() );
730 model.SetValue( childRow, 0, wxS(
"Package_SO:SOIC-16" ) );
731 model.SetValue( childRow, 1, wxS(
"child keywords" ) );
732 model.SetValue( parentRow, 0, wxS(
"Package_DIP:DIP-16" ) );
733 model.SetValue( parentRow, 1, wxS(
"new parent keywords" ) );
737 BOOST_CHECK(
model.CanUseParentValue( childRow, 0 ) );
738 BOOST_CHECK(
model.CanUseParentValue( childRow, 1 ) );
739 model.UseParentValue( childRow, 0 );
740 model.UseParentValue( childRow, 1 );
741 model.UseParentValue( childRow, 3 );
742 BOOST_CHECK( !
model.CanUseParentValue( childRow, 3 ) );
764 BOOST_CHECK( formatter.
GetString().find(
"ki_keywords" ) == std::string::npos );
767 childOnlyModel.
AddColumn( keywords, keywords,
false );
768 childOnlyModel.RebuildRows();
769 BOOST_CHECK_EQUAL( childOnlyModel.GetResolvedValue( 0, 0 ), wxS(
"new parent keywords" ) );
772 model.SetValue( childRow, 1, wxS(
"new parent keywords" ) );
773 model.SetValue( grandchildRow, 1, wxS(
"new parent keywords" ) );
774 model.SetGroupingEnabled(
true );
775 model.SetGroupColumn( 1,
true );
777 BOOST_REQUIRE_EQUAL(
model.GetNumberRows(), 1 );
778 BOOST_CHECK( !
model.CanUseParentValue( 0, 1 ) );
779 model.UseParentValue( 0, 1 );
783 model.SetFilter( wxS(
"*child*" ) );
785 BOOST_REQUIRE_EQUAL(
model.GetNumberRows(), 1 );
786 BOOST_REQUIRE_EQUAL(
model.GetRowReferences( 0 ).size(), 2 );
787 BOOST_CHECK(
model.CanUseParentValue( 0, 1 ) );
788 model.UseParentValue( 0, 1 );
789 BOOST_CHECK(
model.GetValue( 0, 1 ).IsEmpty() );
BOOST_CHECK_EQUAL(result, "25.4")