2222
2323"""VirtualTableModel class file."""
2424
25+ from tsp .virtual_table_tag import VirtualTableTag
26+
2527SIZE_KEY = "size"
2628LOW_INDEX_KEY = "lowIndex"
2729COLUMN_IDS_KEY = "columnIds"
2830LINES_KEY = "lines"
31+ TAGS_KEY = "tags"
2932
3033TABLE_LINE_INDEX_KEY = "index"
3134TABLE_LINE_CELLS_KEY = "cells"
@@ -99,13 +102,32 @@ def __init__(self, params):
99102 self .cells .append (VirtualTableLineCell (cell ))
100103 del params [TABLE_LINE_CELLS_KEY ]
101104
105+ self .tags = VirtualTableTag .NO_TAGS
106+ if TAGS_KEY in params :
107+ if params .get (TAGS_KEY ) is not None and type (params .get (TAGS_KEY )) is int :
108+ tags = int (params .get (TAGS_KEY ))
109+
110+ match tags :
111+ case 0 : # Tag 0 is used for no tags
112+ self .tags = VirtualTableTag .NO_TAGS
113+ case 1 | 2 : # Tags 1 and 2 are reserved
114+ self .tags = VirtualTableTag .RESERVED
115+ case 4 : # Tag 4 is used for border
116+ self .tags = VirtualTableTag .BORDER
117+ case 8 : # Tag 8 is used for highlight
118+ self .tags = VirtualTableTag .HIGHLIGHT
119+ case _: # Other tags are not supported
120+ self .tags = VirtualTableTag .NO_TAGS
121+ del params [TAGS_KEY ]
122+
102123 def print (self ):
103124
104125 print (f" index: { self .index } " )
126+ print (f" tags: { self .tags .name } " )
105127 print (" cells:" )
106128 for i , cell in enumerate (self .cells ):
107129 cell .print ()
108- print (f" { '-' * 10 } " )
130+ print (f" { '-' * 30 } " )
109131
110132class VirtualTableLineCell :
111133 '''
@@ -120,5 +142,25 @@ def __init__(self, params):
120142 self .content = params .get (TABLE_LINE_CELL_CONTENT_KEY )
121143 del params [TABLE_LINE_CELL_CONTENT_KEY ]
122144
145+ self .tags = VirtualTableTag .NO_TAGS
146+ if TAGS_KEY in params :
147+ if params .get (TAGS_KEY ) is not None and type (params .get (TAGS_KEY )) is int :
148+ tags = int (params .get (TAGS_KEY ))
149+
150+ match tags :
151+ case 0 : # Tag 0 is used for no tags
152+ self .tags = VirtualTableTag .NO_TAGS
153+ case 1 | 2 : # Tags 1 and 2 are reserved
154+ self .tags = VirtualTableTag .RESERVED
155+ case 4 : # Tag 4 is used for border
156+ self .tags = VirtualTableTag .BORDER
157+ case 8 : # Tag 8 is used for highlight
158+ self .tags = VirtualTableTag .HIGHLIGHT
159+ case _: # Other tags are not supported
160+ self .tags = VirtualTableTag .NO_TAGS
161+ del params [TAGS_KEY ]
162+
123163 def print (self ):
124- print (f" \" { TABLE_LINE_CELL_CONTENT_KEY } \" : \" { self .content } \" " )
164+ print (f" \" { TABLE_LINE_CELL_CONTENT_KEY } \" : \" { self .content } \" " )
165+ print (f" \" tags\" : { self .tags .name } " )
166+ print (f" { '-' * 10 } " )
0 commit comments