Ignore:
Timestamp:
02/23/13 06:37:05 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added support for setting up the delay code table according to the aircraft's type (re #154)

Location:
src/mlx/gui
Files:
4 edited

Legend:

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

    r435 r436  
    44
    55from mlx.gui.common import *
     6
     7import mlx.const as const
    68
    79#------------------------------------------------------------------------------
     
    162164        def setStyle(self):
    163165            """Set the style of the event box from the treeview."""
    164             style = self._treeView.rc_get_style()
    165             self._eventBox.modify_bg(0, style.bg[2])
    166             self._eventBox.modify_fg(0, style.fg[2])
    167 
     166            if self._treeView is not None:
     167                style = self._treeView.rc_get_style()
     168                self._eventBox.modify_bg(0, style.bg[2])
     169                self._eventBox.modify_fg(0, style.fg[2])
    168170
    169171    class Alignment(gtk.Alignment):
     
    187189DELAYCODE = 2
    188190
    189 _data = ( ["Num", "Code", "Reason", "Description"],
    190           [ (CAPTION, "Others"),
    191             (DELAYCODE, ("      6", "OA  ", "NO GATES/STAND AVAILABLE",
    192                          "Due to own airline activity")),
    193             (DELAYCODE, ("9", "SG", "SCHEDULED GROUND TIME",
    194                          "Planned turnaround time less than declared minimum")),
    195             (CAPTION, "Passenger and baggage"),
    196             (DELAYCODE, ("11", "PD", "LATE CHECK-IN",
    197                          "Check-in reopened for late passengers")),
    198             (DELAYCODE, ("12", "PL", "LATE CHECK-IN",
    199                          "Check-in not completed by flight closure time")),
    200             (DELAYCODE, ("13", "PE", "CHECK-IN ERROR",
    201                          "Error with passenger or baggage details")) ] )
     191_data1 = ( ["Num", "Code", "Title", "Description"],
     192           [ (CAPTION, "Others"),
     193             (DELAYCODE, ("      6", "OA  ", "NO GATES/STAND AVAILABLE",
     194                          "Due to own airline activity")),
     195             (DELAYCODE, ("9", "SG", "SCHEDULED GROUND TIME",
     196                          "Planned turnaround time less than declared minimum")),
     197             (CAPTION, "Passenger and baggage"),
     198             (DELAYCODE, ("11", "PD", "LATE CHECK-IN",
     199                          "Check-in reopened for late passengers")),
     200             (DELAYCODE, ("12", "PL", "LATE CHECK-IN",
     201                          "Check-in not completed by flight closure time")),
     202             (DELAYCODE, ("13", "PE", "CHECK-IN ERROR",
     203                          "Error with passenger or baggage details")) ] )
     204
     205_data2 = ( ["MA", "IATA", "Description"],
     206           [ (CAPTION, "Passenger and baggage"),
     207             (DELAYCODE, ("    012", "01",
     208                          "Late shipping of parts and/or materials")),
     209             (DELAYCODE, ("    111", "11",
     210                          "Check-in reopened for late passengers")),
     211             (DELAYCODE, ("    121", "12",
     212                          "Check-in not completed by flight closure time")),
     213             (DELAYCODE, ("    132", "13",
     214                          "Error with passenger or baggage details"))
     215            ])
    202216
    203217#------------------------------------------------------------------------------
     
    209223        super(DelayCodeTable, self).__init__()
    210224
    211         (headers, rows) = _data
    212         numColumns = len(headers) + 1
    213         numRows = len(rows)
     225        self._treeView = None
    214226
    215227        self._listStore = gtk.ListStore(str, str)
    216228        self._treeView = gtk.TreeView(self._listStore)
    217229        self._treeView.set_rules_hint(True)
     230
     231        self.pack_start(self._treeView, False, False, 0)
     232
     233        self._alignments = []
     234
     235        self._eventBox = gtk.EventBox()
     236
     237        self._table = None
     238
     239        self._viewport = self._createViewport()
     240        self._viewport.add(self._eventBox)
     241        self._viewport.set_shadow_type(SHADOW_NONE)
     242
     243        self.pack_start(self._viewport, True, True, 0)
     244
     245        self._previousWidth = 0
     246
     247    def allocate_column_sizes(self, allocation):
     248        """Allocate the column sizes."""
     249        if allocation.width!=self._previousWidth:
     250            self._previousWidth = allocation.width
     251            index = 0
     252            for alignment in self._alignments:
     253                column = self._treeView.get_column(index)
     254                width = alignment.allocatedWidth + (8 if index==0 else 16)
     255                column.set_fixed_width(width)
     256                index += 1
     257
     258    def setType(self, aircraftType):
     259        """Setup the delay code table according to the given aircraft type."""
     260        if aircraftType==const.AIRCRAFT_B736:
     261            data = _data1
     262        else:
     263            data = _data2
     264
     265        columns = self._treeView.get_columns()
     266        for column in columns:
     267            self._treeView.remove_column(column)
     268
     269        (headers, rows) = data
     270        numColumns = len(headers) + 1
     271        numRows = len(rows)
    218272
    219273        column = gtk.TreeViewColumn("", gtk.CellRendererText())
     
    226280            self._treeView.append_column(column)
    227281
    228         self.pack_start(self._treeView, False, False, 0)
    229 
    230         self._alignments = []
    231 
    232         self._eventBox = gtk.EventBox()
    233 
    234282        self._table = gtk.Table(numRows, numColumns)
    235283        self._table.set_homogeneous(False)
    236284        self._table.set_col_spacings(16)
    237285        self._table.set_row_spacings(4)
     286        self._eventBox.add(self._table)
     287
     288        self._alignments = []
    238289
    239290        firstDelayCodeRow = True
     
    267318                firstDelayCodeRow = False
    268319
    269         self._viewport = self._createViewport()
    270         self._eventBox.add(self._table)
    271         self._viewport.add(self._eventBox)
    272         self._viewport.set_shadow_type(SHADOW_NONE)
    273 
    274         self.pack_start(self._viewport, True, True, 0)
    275 
    276320        self._previousWidth = 0
    277 
    278     def allocate_column_sizes(self, allocation):
    279         """Allocate the column sizes."""
    280         if allocation.width!=self._previousWidth:
    281             self._previousWidth = allocation.width
    282             index = 0
    283             for alignment in self._alignments:
    284                 column = self._treeView.get_column(index)
    285                 width = alignment.allocatedWidth + (8 if index==0 else 16)
    286                 column.set_fixed_width(width)
    287                 index += 1
    288 
    289 
    290 #------------------------------------------------------------------------------
     321        self.show_all()
     322
     323    def reset(self):
     324        """Reset the delay code table."""
     325        columns = self._treeView.get_columns()
     326        for column in columns:
     327            self._treeView.remove_column(column)
     328        self._eventBox.remove(self._table)
     329        self._table = None
     330        self.show_all()
     331
     332#------------------------------------------------------------------------------
  • src/mlx/gui/flight.py

    r435 r436  
    591591        flight = self._getSelectedFlight()
    592592        self._wizard._bookedFlight = flight
    593         self._wizard.gui.enableFlightInfo()
     593        self._wizard.gui.enableFlightInfo(flight.aircraftType)
    594594
    595595        self._updateDepartureGate()
  • src/mlx/gui/gui.py

    r393 r436  
    486486            self.reset()
    487487
    488     def enableFlightInfo(self):
     488    def enableFlightInfo(self, aircraftType):
    489489        """Enable the flight info tab."""
    490         self._flightInfo.enable()
     490        self._flightInfo.enable(aircraftType)
    491491
    492492    def cancelFlight(self):
  • src/mlx/gui/info.py

    r435 r436  
    163163        return codes
    164164
    165     def enable(self):
     165    def enable(self, aircraftType):
    166166        """Enable the flight info tab."""
    167167        self._comments.set_sensitive(True)
    168168        self._flightDefects.set_sensitive(True)
     169        self._delayTable.setType(aircraftType)
    169170        self._delayWindow.set_sensitive(True)
    170171        self._delayTable.setStyle()
     
    181182        self._comments.get_buffer().set_text("")
    182183        self._flightDefects.get_buffer().set_text("")
    183 
    184         for widget in self._delayCodeWidgets:
    185             widget.set_active(False)
     184        self._delayTable.reset()
     185        # for widget in self._delayCodeWidgets:
     186        #     widget.set_active(False)
    186187
    187188    def _commentsChanged(self, textbuffer):
Note: See TracChangeset for help on using the changeset viewer.