Changeset 814:6886acd6bcd5 for src/mlx


Ignore:
Timestamp:
09/25/16 06:30:42 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Columns can be sorted in the flight list (re #307).

File:
1 edited

Legend:

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

    r811 r814  
    1111    def __init__(self, attribute, heading, type = str,
    1212                 convertFn = None, renderer = gtk.CellRendererText(),
    13                  extraColumnAttributes = None):
     13                 extraColumnAttributes = None, sortable = False):
    1414        """Construct the descriptor."""
    1515        self._attribute = attribute
     
    1919        self._renderer = renderer
    2020        self._extraColumnAttributes = extraColumnAttributes
     21        self._sortable = sortable
    2122
    2223    def appendType(self, types):
     
    3940                                    text = index)
    4041        column.set_expand(True)
     42        if self._sortable:
     43            column.set_sort_column_id(index)
     44            column.set_sort_indicator(True)
    4145
    4246        return column
     
    6367        self._popupMenu = None
    6468
    65         types = []
     69        types = [int]
    6670        for columnDescriptor in self._columnDescriptors:
    6771            columnDescriptor.appendType(types)
    6872
    6973        self._model = gtk.ListStore(*types)
     74        self._model.set_sort_column_id(2, SORT_ASCENDING)
    7075        self._view = gtk.TreeView(self._model)
    7176
    72         index = 0
     77        flightIndexColumn = gtk.TreeViewColumn()
     78        flightIndexColumn.set_visible(False)
     79        self._view.append_column(flightIndexColumn)
     80
     81        index = 1
    7382        for columnDescriptor in self._columnDescriptors:
    7483            column = columnDescriptor.getViewColumn(index)
     
    106115            return None
    107116        else:
    108             path = model.get_path(iter)
    109             [index] = path.get_indices() if pygobject else path
     117            index = model.get_value(iter, 0)
    110118            return index
    111119
     
    116124    def addFlight(self, flight):
    117125        """Add the given booked flight."""
    118         values = []
     126        values = [self._model.iter_n_children(None)]
    119127        for columnDescriptor in self._columnDescriptors:
    120128            values.append(columnDescriptor.getValueFrom(flight))
Note: See TracChangeset for help on using the changeset viewer.