Skip to content

Commit

Permalink
Added History class to Ruberri plugin tool widget
Browse files Browse the repository at this point in the history
  • Loading branch information
stcrocco committed Mar 22, 2015
1 parent ea13956 commit a61c245
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions plugins/ruberri/ruberri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,59 @@ def find_methods drv, name

class ToolWidget < Qt::Widget

HistoryData = Struct :schema, :path, :links

class History

def initialize
@entries = []
@current = -1
end

def current
@entries[@current]
end

def current_index
@current
end

def empty?
@entries.empty?
end

def at_end?
@current == -1
end

def at_beginning?
@current == -@entries.count
end

def << entry
if at_end? @entries << entry
else
@entries.slice! @current+1, -1
@entries << entry
@current = -1
end
end

def move_back
@current -= 1 unless at_beginning
end

def move_forward
@current += 1 unless at_end?
end

end

def initialize parent = nil
super
@ui = Ruber::Ui::RIToolWidget.new
@ui.setup_ui self
@history = History.new
connect @ui.search_term, SIGNAL(:returnPressed), @ui.search, SIGNAL(:clicked)
connect @ui.search, SIGNAL(:clicked), self, SLOT(:start_search)
@ui.content.open_links = false
Expand Down

0 comments on commit a61c245

Please sign in to comment.