Ignore:
Timestamp:
02/23/13 08:46:11 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The main delay code handling logic is present (re #154)

File:
1 edited

Legend:

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

    r436 r437  
    185185#------------------------------------------------------------------------------
    186186
     187class CheckButton(gtk.CheckButton):
     188    """A check button that contains a reference to a row in the delay code
     189    data table."""
     190    def __init__(self, delayCodeRow):
     191        """Construct the check button."""
     192        super(CheckButton, self).__init__()
     193        self.delayCodeRow = delayCodeRow
     194
     195#------------------------------------------------------------------------------
     196
    187197CAPTION = 1
    188198
    189199DELAYCODE = 2
    190200
    191 _data1 = ( ["Num", "Code", "Title", "Description"],
     201_data1 = ( lambda row: row[0].strip(),
     202           ["Num", "Code", "Title", "Description"],
    192203           [ (CAPTION, "Others"),
    193204             (DELAYCODE, ("      6", "OA  ", "NO GATES/STAND AVAILABLE",
     
    203214                          "Error with passenger or baggage details")) ] )
    204215
    205 _data2 = ( ["MA", "IATA", "Description"],
     216_data2 = ( lambda row: row[0].strip(),
     217           ["MA", "IATA", "Description"],
    206218           [ (CAPTION, "Passenger and baggage"),
    207              (DELAYCODE, ("    012", "01",
     219             (DELAYCODE, ("    012", "01   ",
    208220                          "Late shipping of parts and/or materials")),
    209221             (DELAYCODE, ("    111", "11",
     
    223235        super(DelayCodeTable, self).__init__()
    224236
     237        self._delayCodeData = None
     238
    225239        self._treeView = None
    226240
    227         self._listStore = gtk.ListStore(str, str)
    228         self._treeView = gtk.TreeView(self._listStore)
     241        self._treeView = gtk.TreeView(gtk.ListStore(str, str))
    229242        self._treeView.set_rules_hint(True)
    230243
     
    232245
    233246        self._alignments = []
     247        self._checkButtons = []
    234248
    235249        self._eventBox = gtk.EventBox()
     
    244258
    245259        self._previousWidth = 0
     260
     261    @property
     262    def delayCodes(self):
     263        """Get a list of the delay codes checked by the user."""
     264        codes = []
     265
     266        if self._delayCodeData is not None:
     267            codeExtractor = self._delayCodeData[0]
     268            for checkButton in self._checkButtons:
     269                if checkButton.get_active():
     270                    codes.append(codeExtractor(checkButton.delayCodeRow))
     271
     272        return codes
    246273
    247274    def allocate_column_sizes(self, allocation):
     
    263290            data = _data2
    264291
     292        self._delayCodeData = data
     293
    265294        columns = self._treeView.get_columns()
    266295        for column in columns:
    267296            self._treeView.remove_column(column)
    268297
    269         (headers, rows) = data
     298        (_extractor, headers, rows) = data
    270299        numColumns = len(headers) + 1
    271300        numRows = len(rows)
     
    287316
    288317        self._alignments = []
     318        self._checkButtons = []
    289319
    290320        firstDelayCodeRow = True
     
    301331                self._table.set_row_spacing(i, 8)
    302332            elif type==DELAYCODE:
     333                checkButton = CheckButton(elements)
     334                self._checkButtons.append(checkButton)
    303335                alignment = Alignment(xalign = 0.5, yalign = 0.5, xscale = 1.0)
    304                 alignment.add(gtk.CheckButton())
     336                alignment.add(checkButton)
    305337                self._table.attach(alignment, 0, 1, i, i+1)
    306338                if firstDelayCodeRow:
Note: See TracChangeset for help on using the changeset viewer.