Skip to content

Commit

Permalink
Merge pull request #142 from HerrMuellerluedenscheid/master
Browse files Browse the repository at this point in the history
emit chunk-wise selection of markers to editor
  • Loading branch information
Marius Kriegerowski committed Oct 22, 2016
2 parents 9241915 + ace2fc5 commit b17ee88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/marker_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ def __init__(self):
self.sort(1, qc.Qt.AscendingOrder)

def lessThan(self, left, right):
if left.column() not in _string_header:
return left.data().toDouble()[0] > right.data().toDouble()[0]
else:
if left.column() == _column_mapping['Time']:
return util.stt(str(left.data().toString())) > \
util.stt(str(right.data().toString()))
elif left.column() == _column_mapping['Label']:
return left > right
else:
return left.data().toDouble()[0] > right.data().toDouble()[0]


class MarkerTableView(qg.QTableView):
Expand Down Expand Up @@ -447,12 +450,14 @@ def update_selection_model(self, indices):
flag = qg.QItemSelectionModel.SelectionFlags(
(qg.QItemSelectionModel.Current | qg.QItemSelectionModel.Select))

for i in indices:
for chunk in indices:
istart = min(chunk)
istop = max(chunk)
left = self.proxy_filter.mapFromSource(
self.marker_model.index(i, 0))
self.marker_model.index(istart, 0))

right = self.proxy_filter.mapFromSource(
self.marker_model.index(i, num_columns-1))
self.marker_model.index(istop, num_columns-1))

row_selection = qg.QItemSelection(left, right)
row_selection.select(left, right)
Expand All @@ -461,15 +466,13 @@ def update_selection_model(self, indices):
if len(indices) != 0:
self.marker_table.setCurrentIndex(
self.proxy_filter.mapFromSource(
self.marker_model.index(indices[0], 0)))
self.marker_model.index(indices[0][0], 0)))
self.selection_model.setCurrentIndex(
self.proxy_filter.mapFromSource(
self.marker_model.index(indices[0], 0)),
self.marker_model.index(indices[0][0], 0)),
qg.QItemSelectionModel.SelectCurrent)

self.selection_model.select(selections, flag)

if len(indices) != 0:
self.marker_table.scrollTo(
self.proxy_filter.mapFromSource(
self.marker_model.index(indices[0], 0)))
self.marker_model.index(indices[0][0], 0)))

self.selection_model.select(selections, flag)
3 changes: 3 additions & 0 deletions src/pile_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,9 @@ def emit_selected_markers(self):
for sm in selected_markers:
if sm in markers:
_indexes.append(markers.index(sm))

_indexes.sort()
_indexes = make_chunks(_indexes)
self.emit(qc.SIGNAL('changed_marker_selection'), _indexes)

def toggle_marker_editor(self):
Expand Down

0 comments on commit b17ee88

Please sign in to comment.