예제 #1
0
    def set_widgets(self):
        """Set widgets on the Unit tab."""
        self.clear_further_steps()
        # Set widgets
        purpose = self.parent.step_kw_purpose.selected_purpose()
        subcategory = self.parent.step_kw_subcategory.selected_subcategory()
        self.lblSelectUnit.setText(
            unit_question % (subcategory['name'], purpose['name']))
        self.lblDescribeUnit.setText('')
        self.lstUnits.clear()
        subcat = self.parent.step_kw_subcategory.selected_subcategory()['key']
        if purpose == layer_purpose_hazard:
            units_for_layer = hazard_units(subcat)
        else:
            units_for_layer = exposure_units(subcat)
        for unit_for_layer in units_for_layer:
            item = QListWidgetItem(unit_for_layer['name'], self.lstUnits)
            item.setData(QtCore.Qt.UserRole, unit_for_layer['key'])
            self.lstUnits.addItem(item)

        # Set values based on existing keywords (if already assigned)
        if self.parent.step_kw_purpose.\
                selected_purpose() == layer_purpose_hazard:
            key = continuous_hazard_unit['key']
        else:
            key = exposure_unit['key']
        unit_id = self.parent.get_existing_keyword(key)
        if unit_id:
            units = []
            for index in xrange(self.lstUnits.count()):
                item = self.lstUnits.item(index)
                units.append(item.data(QtCore.Qt.UserRole))
            if unit_id in units:
                self.lstUnits.setCurrentRow(units.index(unit_id))

        self.auto_select_one_item(self.lstUnits)
예제 #2
0
    def set_widgets(self):
        """Set widgets on the Unit tab."""
        self.clear_further_steps()
        # Set widgets
        purpose = self.parent.step_kw_purpose.selected_purpose()
        subcategory = self.parent.step_kw_subcategory.selected_subcategory()
        self.lblSelectUnit.setText(
            unit_question % (subcategory['name'], purpose['name']))
        self.lblDescribeUnit.setText('')
        self.lstUnits.clear()
        subcat = self.parent.step_kw_subcategory.selected_subcategory()['key']
        if purpose == layer_purpose_hazard:
            units_for_layer = hazard_units(subcat)
        else:
            units_for_layer = exposure_units(subcat)
        for unit_for_layer in units_for_layer:
            item = QListWidgetItem(unit_for_layer['name'], self.lstUnits)
            item.setData(QtCore.Qt.UserRole, unit_for_layer['key'])
            self.lstUnits.addItem(item)

        # Set values based on existing keywords (if already assigned)
        if self.parent.step_kw_purpose.\
                selected_purpose() == layer_purpose_hazard:
            key = continuous_hazard_unit['key']
        else:
            key = exposure_unit['key']
        unit_id = self.parent.get_existing_keyword(key)
        if unit_id:
            units = []
            for index in range(self.lstUnits.count()):
                item = self.lstUnits.item(index)
                units.append(item.data(QtCore.Qt.UserRole))
            if unit_id in units:
                self.lstUnits.setCurrentRow(units.index(unit_id))

        self.auto_select_one_item(self.lstUnits)
예제 #3
0
 def test_hazards_units(self):
     """Test for hazard_units"""
     expected = [unit_metres, unit_feet, unit_generic]
     self.assertItemsEqual(hazard_units('flood'), expected)
예제 #4
0
 def test_hazards_units(self):
     """Test for hazard_units"""
     expected = [unit_metres, unit_feet, unit_generic]
     self.assertEqual(dict_values_sorted(hazard_units('flood')),
                      dict_values_sorted(expected))
예제 #5
0
 def test_hazards_units(self):
     """Test for hazard_units"""
     expected = [unit_metres, unit_feet, unit_generic]
     self.assertEqual(dict_values_sorted(
         hazard_units('flood')), dict_values_sorted(expected))
예제 #6
0
 def test_hazards_units(self):
     """Test for hazard_units"""
     expected = [unit_metres, unit_feet, unit_generic]
     self.assertItemsEqual(hazard_units('flood'), expected)