Ignore:
Timestamp:
02/22/14 09:50:09 (10 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The flight type is also considered when checking the arrival and departure times (re #227)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r563 r564  
    28152815    def __init__(self, wizard):
    28162816        """Construct the finish page."""
    2817         help = xstr("finish_help") + xstr("finish_help_wrongtime")
     2817        help = xstr("finish_help") + xstr("finish_help_goodtime")
    28182818        super(FinishPage, self).__init__(wizard, xstr("finish_title"), help)
    28192819
     
    30493049            self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
    30503050
    3051         bookedFlight = self._wizard.bookedFlight
    3052 
    3053         (markup, tooBigDeparture) = \
    3054             self._formatTime(bookedFlight.departureTime, flight.blockTimeStart)
    3055 
    3056         self._depTime.set_markup(markup)
    3057 
    30583051        flightLength = flight.flightTimeEnd - flight.flightTimeStart
    30593052        self._flightTime.set_markup("<b>%s</b>" % \
     
    30633056        self._blockTime.set_markup("<b>%s</b>" % \
    30643057                                   (util.getTimeIntervalString(blockLength),))
    3065 
    3066         (markup, tooBigArrival) = \
    3067             self._formatTime(bookedFlight.arrivalTime, flight.blockTimeEnd)
    3068 
    3069         self._tooBigTimeDifference = tooBigDeparture or tooBigArrival
    3070 
    3071         if self._tooBigTimeDifference:
    3072             self.setHelp(xstr("finish_help") + xstr("finish_help_wrongtime"))
    3073         else:
    3074             self.setHelp(xstr("finish_help"))
    3075 
    3076         self._arrTime.set_markup(markup)
    30773058
    30783059        self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
     
    31013082            self._gate.set_sensitive(False)
    31023083
    3103         self.updateButtons()
     3084        self._updateTimes()
    31043085
    31053086    def updateButtons(self):
     
    31473128    def _flightTypeChanged(self, comboBox):
    31483129        """Called when the flight type has changed."""
    3149         self.updateButtons()
     3130        self._updateTimes()
    31503131
    31513132    def _gateChanged(self, comboBox):
     
    33103291        pass
    33113292
    3312     def _formatTime(self, scheduledTime, realTimestamp):
     3293    def _formatTime(self, scheduledTime, realTimestamp, (warning, error)):
    33133294        """Format the departure or arrival time based on the given data as a
    3314         markup for a label.
    3315 
    3316         If the difference is greater than 15 minutes, the text should be
    3317         red. Otherwise, if the difference is greater that 5 minutes, the text
    3318         should be yellow. Otherwise it should be black.
    3319 
    3320         scheduledTime is the scheduled time as a datetime object
    3321         realTimestamp is the real time as a timestamp (i.e. seconds
    3322         since the epoch)
    3323 
    3324         Returns a tuple consisting of:
    3325         - the markup,
    3326         - a boolean indicating if the difference is greater than 15 minutes."""
     3295        markup for a label."""
    33273296        realTime = time.gmtime(realTimestamp)
    33283297
    3329         scheduledMinute = scheduledTime.hour * 60 + scheduledTime.minute
    3330         realMinute = realTime.tm_hour * 60 + realTime.tm_min
    3331 
    3332         diff1 = scheduledMinute - realMinute
    3333         diff2 = -1 * diff1
    3334 
    3335         if diff1 < 0: diff1 += 60*24
    3336         else: diff2 += 60*24
    3337 
    3338         diff = min(diff1, diff2)
    3339 
    3340         if diff>5:
    3341             colour = "red" if diff>15 else "orange"
     3298        if warning:
     3299            colour = "red" if error else "orange"
    33423300            markupBegin = '<span foreground="%s">' % (colour,)
    33433301            markupEnd = '</span>'
     
    33513309                  markupEnd)
    33523310
    3353         # print "mlx.gui.flight.FinishPage._formatTime: markup='%s', diff=%d" % \
    3354         #       (markup, diff)
    3355 
    3356         return (markup, diff>15)
     3311        return markup
     3312
     3313    def _updateTimes(self):
     3314        """Format the flight times and the help text according to the flight
     3315        type.
     3316
     3317        The buttons are also updated.
     3318        """
     3319        flight = self._wizard.gui._flight
     3320        bookedFlight = flight.bookedFlight
     3321
     3322        (departureWarning, departureError) = flight.blockTimeStartWrong
     3323        (arrivalWarning, arrivalError) = flight.blockTimeEndWrong
     3324
     3325        if self.flightType==const.FLIGHTTYPE_VIP:
     3326            departureError = arrivalError = False
     3327
     3328        self._tooBigTimeDifference = departureError or arrivalError
     3329
     3330        if self._tooBigTimeDifference and self.flightType is not None:
     3331            self.setHelp(xstr("finish_help") + xstr("finish_help_wrongtime"))
     3332        else:
     3333            self.setHelp(xstr("finish_help") + xstr("finish_help_goodtime"))
     3334
     3335        self._depTime.set_markup(self._formatTime(bookedFlight.departureTime,
     3336                                                  flight.blockTimeStart,
     3337                                                  (departureWarning,
     3338                                                   departureError)))
     3339
     3340        self._arrTime.set_markup(self._formatTime(bookedFlight.arrivalTime,
     3341                                                  flight.blockTimeEnd,
     3342                                                  (arrivalWarning,
     3343                                                   arrivalError)))
     3344
     3345        self.updateButtons()
    33573346
    33583347#-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.