1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
# (C) Copyright 2005-2023 Enthought, Inc., Austin, TX
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only under
# the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
""" An adapter model that inverts all of its row/column targets. Use
this class with the CompositeGridModel to make models with different
orientations match, or use it to visually flip the data without modifying
the underlying model's sense of row and column. """
from traits.api import Instance
from .grid_model import GridModel
class InvertedGridModel(GridModel):
""" An adapter model that inverts all of its row/column targets. Use
this class with the CompositeGridModel to make models with different
orientations match, or use it to visually flip the data without modifying
the underlying model's sense of row and column. """
model = Instance(GridModel, ())
# ------------------------------------------------------------------------
# 'GridModel' interface.
# ------------------------------------------------------------------------
def get_column_count(self):
return self.model.get_row_count()
def get_column_name(self, index):
return self.model.get_row_name(index)
def get_cols_drag_value(self, cols):
return self.model.get_rows_drag_value(cols)
def get_cols_selection_value(self, cols):
return self.model.get_rows_selection_value(cols)
def get_column_context_menu(self, col):
return self.model.get_row_context_menu(col)
def sort_by_column(self, col, reverse=False):
return self.model.sort_by_row(col, reverse)
def is_column_read_only(self, index):
return self.model.is_row_read_only(index)
def get_row_count(self):
return self.model.get_column_count()
def get_row_name(self, index):
return self.model.get_column_name(index)
def get_rows_drag_value(self, rows):
return self.model.get_cols_drag_value(rows)
def get_rows_selection_value(self, rows):
return self.model.get_cols_selection_value(rows)
def get_row_context_menu(self, row):
return self.model.get_col_context_menu(row)
def sort_by_row(self, row, reverse=False):
return self.model.sort_by_col(row, reverse)
def is_row_read_only(self, index):
return self.model.is_column_read_only(index)
def delete_rows(self, pos, num_rows):
return self.model.delete_cols(pos, num_rows)
def insert_cols(self, pos, num_rows):
return self.model.insert_rows(pos, num_rows)
def get_value(self, row, col):
return self.model.get_value(col, row)
def get_cell_drag_value(self, row, col):
return self.model.get_cell_drag_value(col, row)
def get_cell_selection_value(self, row, col):
return self.model.get_cell_selection_value(col, row)
def resolve_selection(self, selection_list):
return self.model.resolve_selection(selection_list)
def get_cell_context_menu(self, row, col):
return self.model.get_cell_context_menu(col, row)
def set_value(self, row, col, value):
return self.model.set_value(col, row, value)
def is_cell_empty(self, row, col):
return self.model.is_cell_empty(col, row)
def is_cell_editable(self, row, col):
return self.model.is_cell_editable(col, row)
|