1 require 'plugins/plugin'
3 class SimpleMoveList < Qt::ListView
7 plugin :name => 'Simple Move List',
8 :keywords => %w(movelist)
10 class LinearHistoryModel < Qt::StringListModel
16 @history = match.history
17 @serializer = match.game.serializer.new(:compact)
19 @history.add_observer(self)
21 insert_rows(0, @history.size)
22 (0...@history.size).each do |i|
28 if @history.size > rowCount
29 insert_rows(rowCount, @history.size - rowCount)
31 remove_rows(@history.size, rowCount - @history.size)
33 update_row(@history.current)
46 fire :change_current => index(@history.current, 0)
53 state = @history[i - 1].state
54 move = @history[i].move
55 san = @serializer.serialize(move, state)
64 "#{count}#{dots} #{san}"
69 set_data(index(i, 0), move(i), Qt::DisplayRole)
74 Qt::ItemIsSelectable | Qt::ItemIsEnabled
81 def initialize(controller, opts = {})
82 super(controller.table)
83 @controller = controller
84 self.font = opts[:font] if opts[:font]
86 @controller.table.add_observer(self)
90 self.model = LinearHistoryModel.new(match)
91 model.observe(:change_current) do |current|
92 selection_model.select(current,
93 Qt::ItemSelectionModel::ClearAndSelect)
95 sig = 'selectionChanged(QItemSelection, QItemSelection)'
96 selection_model.on(sig) do |selected, deselected|
97 @controller.go_to(selected.indexes.first.row)