43
43
44
44
#include < iostream>
45
45
#include < algorithm>
46
+ #include < bitset>
46
47
#include < map>
47
48
#include < set>
48
49
#include < string>
@@ -63,13 +64,14 @@ OSCellWrapper::OSCellWrapper(OSGridView* gridView, QSharedPointer<BaseConcept> b
63
64
m_layout->setSpacing (0 );
64
65
m_layout->setVerticalSpacing (0 );
65
66
m_layout->setHorizontalSpacing (0 );
66
- m_layout->setContentsMargins (0 , 0 , 1 , 1 );
67
67
this ->setLayout (m_layout);
68
68
this ->setAttribute (Qt::WA_StyledBackground);
69
69
this ->setObjectName (" OSCellWrapper" );
70
- setStyleSheet (" QWidget#OSCellWrapper { border: none; border-right: 1px solid gray; border-bottom: 1px solid gray; }"
71
- " QWidget#OSCellWrapper[header=\" true\" ]{ border: none; border-top: 1px solid black; border-right: 1px solid gray; border-bottom: 1px "
70
+ setStyleSheet (" QWidget#OSCellWrapper[style=\" 01\" ] { border: none; border-right: 1px solid gray; border-bottom: 1px solid gray; }" // header = false, visible = true
71
+ " QWidget#OSCellWrapper[style=\" 00\" ] { border: none; border-right: none; border-bottom: none; }" // header = false, visible = false
72
+ " QWidget#OSCellWrapper[style=\" 11\" ]{ border: none; border-top: 1px solid black; border-right: 1px solid gray; border-bottom: 1px " // header = true, visible = true
72
73
" solid black; }" );
74
+ updateStyle ();
73
75
74
76
connect (this , &OSCellWrapper::rowNeedsStyle, objectSelector, &OSObjectSelector::onRowNeedsStyle);
75
77
}
@@ -175,6 +177,8 @@ void OSCellWrapper::setCellProperties(const GridCellLocation& location, const Gr
175
177
for (auto * holder : m_holders) {
176
178
holder->setCellProperties (location, info);
177
179
}
180
+ m_visible = info.isVisible ();
181
+ updateStyle ();
178
182
}
179
183
}
180
184
@@ -570,10 +574,32 @@ void OSCellWrapper::disconnectModelSignals() {
570
574
}
571
575
572
576
void OSCellWrapper::makeHeader () {
573
- m_layout->setContentsMargins (0 , 1 , 1 , 1 );
574
- setProperty (" header" , true );
575
- this ->style ()->unpolish (this );
576
- this ->style ()->polish (this );
577
+ m_header = true ;
578
+ m_visible = true ;
579
+ updateStyle ();
580
+ }
581
+
582
+ void OSCellWrapper::updateStyle () {
583
+ // Locked, Focused, Defaulted
584
+ std::bitset<3 > style;
585
+ style[0 ] = m_header;
586
+ style[1 ] = m_visible;
587
+ QString thisStyle = QString::fromStdString (style.to_string ());
588
+
589
+ QVariant currentStyle = property (" style" );
590
+ if (currentStyle.isNull () || currentStyle.toString () != thisStyle) {
591
+ if (m_header) {
592
+ m_layout->setContentsMargins (0 , 1 , 1 , 1 );
593
+ } else if (m_visible) {
594
+ m_layout->setContentsMargins (0 , 0 , 1 , 1 );
595
+ } else {
596
+ m_layout->setContentsMargins (0 , 0 , 0 , 0 );
597
+ }
598
+
599
+ this ->setProperty (" style" , thisStyle);
600
+ this ->style ()->unpolish (this );
601
+ this ->style ()->polish (this );
602
+ }
577
603
}
578
604
579
605
void OSCellWrapper::onRemoveWorkspaceObject (const WorkspaceObject& object, const openstudio::IddObjectType& iddObjectType,
0 commit comments