Method: Ruber::OpenFileInProjectDlg#initialize

Defined in:
lib/ruber/main_window/open_file_in_project_dlg.rb

#initialize(prj, parent = nil) ⇒ OpenFileInProjectDlg

Returns a new OpenFileInProjectDlg.

=====Arguments
_parent_:: the widget parent of the dialog


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/ruber/main_window/open_file_in_project_dlg.rb', line 113

def initialize prj, parent = nil
  super parent
  files = prj.project_files.to_a
  @base_dir = prj.project_directory
  @ui = Ui::OpenFileInProjectDlg.new
  @ui.setupUi self
  @ui.regexp_error.hide
  filter = FilterModel.new @ui.file_list
  model = Qt::StandardItemModel.new filter
  @ui.file_list.model = filter
  filter.source_model = model
  files.each do |f|
    path = f.sub %r{\A#{Regexp.quote(@base_dir)}/}, ''
    it = Qt::StandardItem.new path
    it.set_data Qt::Variant.new(File.basename(path))
    it.editable = false
    model.append_row it
  end      
  @ui.pattern.install_event_filter self
  connect @ui.pattern, SIGNAL('textChanged(const QString &)'), self, SLOT('change_filter(const QString &)')
  connect @ui.file_list, SIGNAL('activated(const QModelIndex &)'), self, SLOT('item_activated(const QModelIndex &)')
  @ui.file_list.selection_model.select @ui.file_list.model.index(0,0), 
    Qt::ItemSelectionModel::ClearAndSelect|Qt::ItemSelectionModel::Rows
  @ui.file_list.current_index = @ui.file_list.model.index(0,0)
#       @ui.file_list.header.resize_sections Qt::HeaderView::ResizeToContents
end