def set_from(self, project):
        section = project.options.time_steps
        self.cbxSkip.setChecked(section.skip_steady_state)
        self.sbxLateral.setValue(int(section.lateral_inflow_tolerance))
        self.sbxSystem.setValue(int(section.system_flow_tolerance))

        (days, hours, minutes,
         seconds) = frmTimeSteps.split_days(section.dry_step)
        self.sbxDry.setValue(days)
        self.tmeDry.setTime(QtCore.QTime(hours, minutes, seconds))

        (days, hours, minutes,
         seconds) = frmTimeSteps.split_days(section.wet_step)
        self.sbxWet.setValue(days)
        self.tmeWet.setTime(QtCore.QTime(hours, minutes, seconds))

        (days, hours, minutes,
         seconds) = frmTimeSteps.split_days(section.report_step)
        self.sbxReportDay.setValue(days)
        self.tmeReport.setTime(QtCore.QTime(hours, minutes, seconds))

        (days, hours, minutes,
         seconds) = frmTimeSteps.split_days(section.rule_step)
        self.tmeControl.setTime(QtCore.QTime(hours, minutes, seconds))

        if ':' in section.routing_step:
            if len(section.routing_step.split(':')
                   [0]) == 1:  # Delphi GUI writes routing step as h:mm:ss
                routing_time = QtCore.QTime(0, 0, 0).secsTo(
                    QtCore.QTime.fromString(section.routing_step, 'h:mm:ss'))
            else:
                routing_time = QtCore.QTime(0, 0, 0).secsTo(
                    QtCore.QTime.fromString(section.routing_step,
                                            section.TIME_FORMAT))
        else:
            routing_time, good_int = ParseData.get_int_from_float(
                section.routing_step)
        self.txtRouting.setText(str(routing_time))
    def set_link(self, project, link_name):
        # assume we want to edit the first one
        self.link_name = link_name
        value = None
        try:
            value = self._main_form.project.xsections.get_item(
                "link", self.link_name)
        except:  # This must be a new one we need to add
            value = None

        if not value:
            value = core.swmm.hydraulics.link.CrossSection()
            value.link = self.link_name
            if self._main_form and self._main_form.project_settings:
                self._main_form.project_settings.apply_default_attributes(
                    value)
            self._main_form.project.xsections.value.append(value)

        for value in project.xsections.value:
            if value.link == link_name:
                # this is the link we want to edit
                for list_index in range(0, self.listWidget.count()):
                    list_item = self.listWidget.item(list_index)
                    if str(list_item.text()).upper() == value.shape.name:
                        self.listWidget.setCurrentItem(list_item)
                    elif str(list_item.text(
                    )) == 'Force Main' and value.shape.name == 'FORCE_MAIN':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Filled Circular' and value.shape.name == 'FILLED_CIRCULAR':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Closed Rectangular' and value.shape.name == 'RECT_CLOSED':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(list_item.text(
                    )) == 'Rectangular' and value.shape.name == 'RECT_OPEN':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Horizontal Elliptical' and value.shape.name == 'HORIZ_ELLIPSE':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Vertical Elliptical' and value.shape.name == 'VERT_ELLIPSE':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Rectangular Triangular' and value.shape.name == 'RECT_TRIANGULAR':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Rectangular Round' and value.shape.name == 'RECT_ROUND':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Modified Baskethandle' and value.shape.name == 'MODBASKETHANDLE':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Semi-Elliptical' and value.shape.name == 'SEMIELLIPTICAL':
                        self.listWidget.setCurrentItem(list_item)
                    elif str(
                            list_item.text()
                    ) == 'Semi-Circular' and value.shape.name == 'SEMICIRCULAR':
                        self.listWidget.setCurrentItem(list_item)

                ibarrels, good_int = ParseData.get_int_from_float(
                    value.barrels)
                if good_int:
                    self.sbxNumber.setValue(ibarrels)
                self.txt1.setText(str(value.geometry1))
                self.txt2.setText(str(value.geometry2))
                self.txt3.setText(str(value.geometry3))
                self.txt4.setText(str(value.geometry4))

                # for rect_open sidewalls, set geom3 to 0,1,2 for None, One, Both
                if value.shape.name == 'RECTANGULAR':
                    self.cboCombo.setCurrentIndex(int(value.geometry3))

                # for horizontal and vertical elliptical and arch, combo gets standard sizes
                if value.shape.name == 'HORIZ_ELLIPSE':
                    self.cboCombo.setCurrentIndex(int(value.geometry3))
                if value.shape.name == 'VERT_ELLIPSE':
                    self.cboCombo.setCurrentIndex(int(value.geometry3))
                if value.shape.name == 'ARCH':
                    self.cboCombo.setCurrentIndex(int(value.geometry3))

                if value.shape.name == 'IRREGULAR':
                    # for irregular, combo needs transect names, dialog opens transect buttons
                    for index in range(0, self.cboCombo.count()):
                        if value.geometry1 == self.cboCombo.itemText(index):
                            self.cboCombo.setCurrentIndex(index)

                if value.shape.name == 'CUSTOM':
                    # for custom, combo needs shape curves, dialog opens shape curve editor
                    for index in range(0, self.cboCombo.count()):
                        if value.curve == self.cboCombo.itemText(index):
                            self.cboCombo.setCurrentIndex(index)