@@ -66,23 +66,48 @@ def build_grid(self) -> QtWidgets.QGridLayout:
6666 grid .setSpacing (10 )
6767 grid .setAlignment (QtCore .Qt .AlignmentFlag .AlignTop )
6868
69+ db_locked = bwutils .database_is_locked (self .activity ["database" ])
70+ setup = self .disabled_setup () if db_locked else self .enabled_setup ()
71+
72+ # Arrange widgets for display as a grid
73+ for i , (title , widget ) in enumerate (setup ):
74+ grid .addWidget (widgets .ABLabel .demiBold (title , self ), i , 1 )
75+ grid .addWidget (widget , i , 2 , 1 , 4 )
76+
77+ return grid
78+
79+ def enabled_setup (self ):
6980 setup = [
7081 ("Name:" , ActivityName (self ),),
7182 ("Location:" , ActivityLocation (self ),),
72- ("Properties:" , ActivityProperties (self ),),
7383 ]
7484
85+ if isinstance (self .activity , bf .Process ):
86+ setup .append (("Properties:" , ActivityProperties (self ),),)
87+
7588 # Add allocation strategy selector if the activity is multifunctional
7689 if self .activity .get ("type" ) == "multifunctional" :
7790 setup .append (("Allocation:" , ActivityAllocation (self ),))
7891
79- # Arrange widgets for display as a grid
80- for i , (title , widget ) in enumerate (setup ):
81- grid .addWidget (widgets .ABLabel .demiBold (title , self ), i , 1 )
82- grid .addWidget (widget , i , 2 , 1 , 4 )
83- widget .setDisabled (bwutils .database_is_locked (self .activity ["database" ]))
92+ return setup
93+
94+ def disabled_setup (self ):
95+ setup = [
96+ ("Name:" , QtWidgets .QLabel (self .activity .get ("name" ), self ),),
97+ ("Location:" , QtWidgets .QLabel (self .activity .get ("location" ), self ),),
98+ ]
99+
100+ if isinstance (self .activity , bf .Process ):
101+ props = self .activity .available_properties ()
102+ prop_text = ", " .join (props ) if props else "None"
103+ setup .append (("Properties:" , QtWidgets .QLabel (prop_text , self ),))
104+
105+ # Add allocation strategy selector if the activity is multifunctional
106+ if self .activity .get ("type" ) == "multifunctional" :
107+ setup .append (("Allocation:" , QtWidgets .QLabel (self .activity .get ("allocation" ), self ),),)
108+
109+ return setup
84110
85- return grid
86111
87112
88113
0 commit comments