comparison browser_side/xmlui.py @ 376:ab923b870fb0

browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
author Goffi <goffi@goffi.org>
date Tue, 25 Feb 2014 02:13:53 +0100
parents 678d1739bbf2
children 3dd0b5334aef
comparison
equal deleted inserted replaced
375:41a386a27002 376:ab923b870fb0
169 self.col = 0 169 self.col = 0
170 self._xmlui_rows_idx = [] 170 self._xmlui_rows_idx = []
171 self._xmlui_selectable = selectable != 'no' 171 self._xmlui_selectable = selectable != 'no'
172 self._xmlui_selected_row = None 172 self._xmlui_selected_row = None
173 self.addTableListener(self) 173 self.addTableListener(self)
174 if self._xmlui_selectable:
175 self.addStyleName('AdvancedListSelectable')
174 176
175 def onCellClicked(self, grid, row, col): 177 def onCellClicked(self, grid, row, col):
176 if not self._xmlui_selectable: 178 if not self._xmlui_selectable:
177 return 179 return
178 if self._xmlui_selected_row != row: 180 self._xmlui_selected_row = row
179 for widget in self._xmluiGetSelectedWidgets():
180 widget.removeStyleName('AdvancedListSelectableRow-selected')
181 self._xmlui_selected_row = row
182 for widget in self._xmluiGetSelectedWidgets():
183 widget.addStyleName('AdvancedListSelectableRow-selected')
184 try: 181 try:
185 self._xmlui_select_cb(self) 182 self._xmlui_select_cb(self)
186 except AttributeError: 183 except AttributeError:
187 print "WARNING: no select callback set" 184 print "WARNING: no select callback set"
188 185
186
189 def _xmluiAppend(self, widget): 187 def _xmluiAppend(self, widget):
190 self.setWidget(self.row, self.col, widget) 188 self.setWidget(self.row, self.col, widget)
191 widget.addStyleName('AdvancedListSelectableRow')
192 self.col += 1 189 self.col += 1
193 190
194 def _xmluiAddRow(self, idx): 191 def _xmluiAddRow(self, idx):
195 self.row += 1 192 self.row += 1
196 self.col = 0 193 self.col = 0
197 self._xmlui_rows_idx.insert(self.row, idx) 194 self._xmlui_rows_idx.insert(self.row, idx)
198 self.resizeRows(self.row + 1) 195 self.resizeRows(self.row+1)
199 196
200 def _xmluiGetSelectedWidgets(self): 197 def _xmluiGetSelectedWidgets(self):
201 return [self.getWidget(self._xmlui_selected_row, col) for col in range(self.columns)] 198 return [self.getWidget(self._xmlui_selected_row, col) for col in range(self.columns)]
202 199
203 def _xmluiGetSelectedIndex(self): 200 def _xmluiGetSelectedIndex(self):