132 |
|
|
133 |
self.SetSelectionMode(wxGrid.wxGridSelectRows) |
self.SetSelectionMode(wxGrid.wxGridSelectRows) |
134 |
|
|
135 |
EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
#EVT_GRID_RANGE_SELECT(self, None) |
136 |
EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
#EVT_GRID_SELECT_CELL(self, None) |
137 |
|
#EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
138 |
|
#EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
139 |
|
|
140 |
|
self.ToggleEventListeners(True) |
141 |
|
|
142 |
def SetTableObject(self, table): |
def SetTableObject(self, table): |
143 |
self.table.SetTable(table) |
self.table.SetTable(table) |
160 |
self.issue(ROW_SELECTED, self.GetSelectedRows()) |
self.issue(ROW_SELECTED, self.GetSelectedRows()) |
161 |
event.Skip() |
event.Skip() |
162 |
|
|
163 |
|
def ToggleEventListeners(self, on): |
164 |
|
if on: |
165 |
|
EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
166 |
|
EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
167 |
|
else: |
168 |
|
EVT_GRID_RANGE_SELECT(self, None) |
169 |
|
EVT_GRID_SELECT_CELL(self, None) |
170 |
|
|
171 |
def disallow_messages(self): |
def disallow_messages(self): |
172 |
"""Disallow messages to be send. |
"""Disallow messages to be send. |
173 |
|
|
270 |
|
|
271 |
self.combo_fields = wxComboBox(self, -1, style=wxCB_READONLY) |
self.combo_fields = wxComboBox(self, -1, style=wxCB_READONLY) |
272 |
self.choice_comp = wxChoice(self, -1, |
self.choice_comp = wxChoice(self, -1, |
273 |
choices=["<", "<=", "=", "<>", ">=", ">"]) |
choices=["<", "<=", "==", "!=", ">=", ">"]) |
274 |
self.combo_value = wxComboBox(self, -1) |
self.combo_value = wxComboBox(self, -1) |
275 |
self.choice_action = wxChoice(self, -1, |
self.choice_action = wxChoice(self, -1, |
276 |
choices=[_("Replace Selection"), |
choices=[_("Replace Selection"), |
283 |
self.grid.SetSize((400, 200)) |
self.grid.SetSize((400, 200)) |
284 |
|
|
285 |
self.combo_value.Append("") |
self.combo_value.Append("") |
286 |
for i in range(table.field_count()): |
for i in range(table.NumColumns()): |
287 |
type, name, len, decc = layer.table.field_info(i) |
name = table.Column(i).name |
288 |
self.combo_fields.Append(name) |
self.combo_fields.Append(name) |
289 |
self.combo_value.Append(name) |
self.combo_value.Append(name) |
290 |
|
|
291 |
# assume at least one field? |
# assume at least one field? |
292 |
self.combo_fields.SetSelection(0) |
self.combo_fields.SetSelection(0) |
293 |
self.combo_value.SetSelection(0) |
self.combo_value.SetSelection(0) |
320 |
|
|
321 |
if self.combo_value.GetSelection() < 1: |
if self.combo_value.GetSelection() < 1: |
322 |
value = self.combo_value.GetValue() |
value = self.combo_value.GetValue() |
|
print value |
|
323 |
else: |
else: |
324 |
value = self.table.Column(self.combo_value.GetValue()) |
value = self.table.Column(self.combo_value.GetValue()) |
325 |
|
|
326 |
#ids = self.table.Query( |
ids = self.table.SimpleQuery( |
327 |
#self.table.Column(self.combo_fields.GetStringSelection()), |
self.table.Column(self.combo_fields.GetStringSelection()), |
328 |
#self.choice_comp.GetStringSelection(), |
self.choice_comp.GetStringSelection(), |
329 |
#value) |
value) |
330 |
|
|
331 |
choice = self.choice_action.GetSelection() |
choice = self.choice_action.GetSelection() |
332 |
|
|
333 |
|
# |
334 |
|
# what used to be nice code got became a bit ugly because |
335 |
|
# each time we select a row a message is sent to the grid |
336 |
|
# which we are listening for and then we send further |
337 |
|
# messages. |
338 |
|
# |
339 |
|
# now, we disable those listeners select everything but |
340 |
|
# the first item, reenable the listeners, and select |
341 |
|
# the first element, which causes everything to be |
342 |
|
# updated properly. |
343 |
|
# |
344 |
|
self.grid.ToggleEventListeners(False) |
345 |
|
|
346 |
if choice == 0: |
if choice == 0: |
|
ids = [1, 2, 3, 4, 5] |
|
347 |
# Replace Selection |
# Replace Selection |
348 |
self.grid.ClearSelection() |
self.grid.ClearSelection() |
|
for id in ids: |
|
|
self.grid.SelectRow(id, True) |
|
349 |
elif choice == 1: |
elif choice == 1: |
|
ids = [1, 3, 5] |
|
350 |
# Refine Selection |
# Refine Selection |
351 |
sel = dict([(i, 0) for i in self.parent.SelectedShapes()]) |
sel = dict([(i, 0) for i in self.parent.SelectedShapes()]) |
352 |
self.grid.ClearSelection() |
self.grid.ClearSelection() |
353 |
for id in filter(sel.has_key, ids): |
ids = filter(sel.has_key, ids) |
|
self.grid.SelectRow(id, True) |
|
354 |
elif choice == 2: |
elif choice == 2: |
|
ids = [2, 4] |
|
355 |
# Add to Selection |
# Add to Selection |
356 |
for id in ids: |
pass |
357 |
|
|
358 |
|
# |
359 |
|
# select the rows (all but the first) |
360 |
|
# |
361 |
|
firsttime = True |
362 |
|
for id in ids: |
363 |
|
if firsttime: |
364 |
|
firsttime = False |
365 |
|
else: |
366 |
self.grid.SelectRow(id, True) |
self.grid.SelectRow(id, True) |
367 |
|
|
368 |
|
self.grid.ToggleEventListeners(True) |
369 |
|
|
370 |
|
# |
371 |
|
# select the first row |
372 |
|
# |
373 |
|
if ids: |
374 |
|
self.grid.SelectRow(ids[0], True) |
375 |
|
|
376 |
wxEndBusyCursor() |
wxEndBusyCursor() |
377 |
|
|
378 |
def OnSaveAs(self, event): |
def OnSaveAs(self, event): |