Changeset 437:750a9bfbc6dd


Ignore:
Timestamp:
02/23/13 08:46:11 (10 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

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

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r393 r437  
    972972msgstr "Delay codes"
    973973
    974 msgid "info_delay_loading"
    975 msgstr "L_oading problems"
    976 
    977 msgid "info_delay_vatsim"
    978 msgstr "_VATSIM problem"
    979 
    980 msgid "info_delay_net"
    981 msgstr "_Net problems"
    982 
    983 msgid "info_delay_atc"
    984 msgstr "Controll_er's fault"
    985 
    986 msgid "info_delay_system"
    987 msgstr "S_ystem crash/freeze"
    988 
    989 msgid "info_delay_nav"
    990 msgstr "Naviga_tion problem"
    991 
    992 msgid "info_delay_traffic"
    993 msgstr "T_raffic problems"
    994 
    995 msgid "info_delay_apron"
    996 msgstr "_Apron navigation problem"
    997 
    998 msgid "info_delay_weather"
    999 msgstr "_Weather problems"
    1000 
    1001 msgid "info_delay_personal"
    1002 msgstr "_Personal reasons"
    1003 
    1004974msgid "statusbar_conn_tooltip"
    1005975msgstr ""
  • locale/hu/mlx.po

    r393 r437  
    975975msgstr "Késés kódok"
    976976
    977 msgid "info_delay_loading"
    978 msgstr "_Betöltési problémák"
    979 
    980 msgid "info_delay_vatsim"
    981 msgstr "_VATSIM probléma"
    982 
    983 msgid "info_delay_net"
    984 msgstr "_Hálózati problémák"
    985 
    986 msgid "info_delay_atc"
    987 msgstr "Irán_yító hibája"
    988 
    989 msgid "info_delay_system"
    990 msgstr "_Rendszer elszállás/fagyás"
    991 
    992 msgid "info_delay_nav"
    993 msgstr "Navi_gációs probléma"
    994 
    995 msgid "info_delay_traffic"
    996 msgstr "_Forgalmi problémák"
    997 
    998 msgid "info_delay_apron"
    999 msgstr "_Előtér navigációs probléma"
    1000 
    1001 msgid "info_delay_weather"
    1002 msgstr "Időjárási _problémák"
    1003 
    1004 msgid "info_delay_personal"
    1005 msgstr "S_zemélyes okok"
    1006 
    1007977msgid "statusbar_conn_tooltip"
    1008978msgstr ""
  • src/mlx/const.py

    r432 r437  
    237237#-------------------------------------------------------------------------------
    238238
    239 ## Delay code: loading problems
    240 DELAYCODE_LOADING = 0
    241 
    242 ## Delay code: VATSIM problem
    243 DELAYCODE_VATSIM = 1
    244 
    245 ## Delay code: network problems
    246 DELAYCODE_NETWORK = 2
    247 
    248 ## Delay code: controller's fault
    249 DELAYCODE_CONTROLLER = 3
    250 
    251 ## Delay code: system crash or freeze
    252 DELAYCODE_SYSTEM = 4
    253 
    254 ## Delay code: navigation problem
    255 DELAYCODE_NAVIGATION = 5
    256 
    257 ## Delay code: traffic problems
    258 DELAYCODE_TRAFFIC = 6
    259 
    260 ## Delay code: apron navigation
    261 DELAYCODE_APRON = 7
    262 
    263 ## Delay code: weather problems
    264 DELAYCODE_WEATHER = 8
    265 
    266 ## Delay code: personal reasons
    267 DELAYCODE_PERSONAL = 9
    268 
    269 #-------------------------------------------------------------------------------
    270 
    271239## Message type: logger error
    272240# FIXME: cannot set the hotkey
  • 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:
  • src/mlx/gui/info.py

    r436 r437  
    2323    """The flight info tab."""
    2424    @staticmethod
    25     def _delayCodes():
    26         """Get an array of delay codes."""
    27         return [ (const.DELAYCODE_LOADING, xstr("info_delay_loading")),
    28                  (const.DELAYCODE_VATSIM, xstr("info_delay_vatsim")),
    29                  (const.DELAYCODE_NETWORK, xstr("info_delay_net")),
    30                  (const.DELAYCODE_CONTROLLER, xstr("info_delay_atc")),
    31                  (const.DELAYCODE_SYSTEM, xstr("info_delay_system")),
    32                  (const.DELAYCODE_NAVIGATION, xstr("info_delay_nav")),
    33                  (const.DELAYCODE_TRAFFIC, xstr("info_delay_traffic")),
    34                  (const.DELAYCODE_APRON, xstr("info_delay_apron")),
    35                  (const.DELAYCODE_WEATHER, xstr("info_delay_weather")),
    36                  (const.DELAYCODE_PERSONAL, xstr("info_delay_personal")) ]
    37 
    38     @staticmethod
    3925    def _createCommentArea(label):
    4026        """Create a comment area.
     
    5440
    5541        scroller = gtk.ScrolledWindow()
    56         # FIXME: these should be constants
    57         scroller.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    58                             else gtk.POLICY_AUTOMATIC,
    59                             gtk.PolicyType.AUTOMATIC if pygobject
    60                             else gtk.POLICY_AUTOMATIC)
    61         scroller.set_shadow_type(gtk.ShadowType.IN if pygobject
    62                                  else gtk.SHADOW_IN)
     42        scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
     43        scroller.set_shadow_type(SHADOW_IN)
     44
    6345        comments = gtk.TextView()
    6446        comments.set_wrap_mode(WRAP_WORD)
     
    10082                              padding_left = 8, padding_right = 8)
    10183
    102 
    103         # self._delayTable = table = gtk.Table(5, 2)
    104         # table.set_col_spacings(16)
    105 
    106         # row = 0
    107         # column = 0
    108 
    109         # self._delayCodeWidgets = []
    110         # for (_code, label) in FlightInfo._delayCodes():
    111         #     button = gtk.CheckButton(label)
    112         #     button.set_use_underline(True)
    113         #     table.attach(button, column, column + 1, row, row + 1)
    114         #     self._delayCodeWidgets.append(button)
    115         #     if column==0:
    116         #         column += 1
    117         #     else:
    118         #         row += 1
    119         #         column = 0
    120         self._delayTable = table = DelayCodeTable()
     84        self._delayCodeTable = table = DelayCodeTable()
    12185        self._delayWindow = scrolledWindow = gtk.ScrolledWindow()
    12286        scrolledWindow.add(table)
     
    156120    def delayCodes(self):
    157121        """Get the list of delay codes checked by the user."""
    158         codes =  []
    159         delayCodes = FlightInfo._delayCodes()
    160         for index in range(0, len(delayCodes)):
    161             if self._delayCodeWidgets[index].get_active():
    162                 codes.append(delayCodes[index][0])
    163         return codes
     122        return self._delayCodeTable.delayCodes
    164123
    165124    def enable(self, aircraftType):
     
    167126        self._comments.set_sensitive(True)
    168127        self._flightDefects.set_sensitive(True)
    169         self._delayTable.setType(aircraftType)
     128        self._delayCodeTable.setType(aircraftType)
    170129        self._delayWindow.set_sensitive(True)
    171         self._delayTable.setStyle()
     130        self._delayCodeTable.setStyle()
    172131
    173132    def disable(self):
     
    176135        self._flightDefects.set_sensitive(False)
    177136        self._delayWindow.set_sensitive(False)
    178         self._delayTable.setStyle()
     137        self._delayCodeTable.setStyle()
    179138
    180139    def reset(self):
     
    182141        self._comments.get_buffer().set_text("")
    183142        self._flightDefects.get_buffer().set_text("")
    184         self._delayTable.reset()
    185         # for widget in self._delayCodeWidgets:
    186         #     widget.set_active(False)
     143        self._delayCodeTable.reset()
    187144
    188145    def _commentsChanged(self, textbuffer):
  • src/mlx/gui/pirep.py

    r303 r437  
    241241        for code in pirep.delayCodes:
    242242            if delayCodes: delayCodes += ", "
    243             delayCodes += PIREP.delayCodeNames[code]
     243            delayCodes += code
    244244       
    245245        self._delayCodes.get_buffer().set_text(delayCodes)       
  • src/mlx/pirep.py

    r401 r437  
    1919class PIREP(object):
    2020    """A pilot's report of a flight."""
    21     delayCodeNames = { const.DELAYCODE_LOADING : "Loading Problems",
    22                        const.DELAYCODE_NETWORK : "Net Problems",
    23                        const.DELAYCODE_SYSTEM : "System Crash/Freezing",
    24                        const.DELAYCODE_TRAFFIC : "Traffic Problems",
    25                        const.DELAYCODE_WEATHER : "Weather Problems",
    26                        const.DELAYCODE_VATSIM : "VATSIM Problem",
    27                        const.DELAYCODE_CONTROLLER : "Controller's Fault",
    28                        const.DELAYCODE_NAVIGATION : "Navigation Problem",
    29                        const.DELAYCODE_APRON : "Apron Navigation Problems",
    30                        const.DELAYCODE_PERSONAL : "Personal Reasons" }
    31 
    3221    @staticmethod
    3322    def _formatLine(timeStr, line):
     
    140129            for code in self.delayCodes:
    141130                if s: s += ", "
    142                 s += PIREP.delayCodeNames[code]
     131                s += code
    143132            return s
    144133
Note: See TracChangeset for help on using the changeset viewer.