Class: Ruber::Rake::ChooseTaskDlg

Inherits:
KDE::Dialog
  • Object
show all
Defined in:
plugins/rake/rake_widgets.rb

Overview

Where the user can choose the rake task to execute

Instance Method Summary (collapse)

Constructor Details

- (ChooseTaskDlg) initialize(prj, parent = Ruber[:main_window])

A new instance of ChooseTaskDlg

Parameters:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'plugins/rake/rake_widgets.rb', line 48

def initialize prj, parent = Ruber[:main_window]
  super parent
  @ui = Ui::RakeChooseTaskWidget.new
  @ui.setupUi main_widget
  @project = prj
  @ui.tasks.model = Qt::SortFilterProxyModel.new @ui.tasks
  @tasks_model = Qt::StandardItemModel.new self
  @ui.tasks.model.source_model = @tasks_model
  @tasks_model.horizontal_header_labels = %w[Task Description]
  fill_tasks_widget
  enable_button_ok false  
  @ui.tasks.selection_model.connect(SIGNAL('selectionChanged(QItemSelection, QItemSelection)')) do
    enable_button_ok @ui.tasks.selection_model.has_selection
  end
  connect @ui.refresh_tasks, SIGNAL(:clicked), self, SLOT(:update_tasks)
  @ui.search_line.proxy = @ui.tasks.model
  @ui.tasks.set_focus
end

Instance Method Details

- (nil) fill_tasks_widget (private)

Inserts the tasks for the object passed to the constructor in the task widget.

Note: this method uses the ProjectExtension#update_tasks method, so it can take some seconds to complete.

Returns:

  • (nil)


86
87
88
89
90
91
92
93
94
# File 'plugins/rake/rake_widgets.rb', line 86

def fill_tasks_widget
  tasks = @project[:rake, :tasks]
  items = tasks.sort.map{|task, data| [Qt::StandardItem.new(task), Qt::StandardItem.new(data[0])]}
  @tasks_model.remove_rows 0, @ui.tasks.model.row_count
  items.each{|i| @tasks_model.append_row i}
  @ui.tasks.resize_column_to_contents 0
  @ui.tasks.enabled = true
  nil
end

Slot Signature:

fill_tasks_widget()

- (String?) task

The selected task

Returns:

  • (String, nil)

    the selected task or nil if no task has been selected



72
73
74
75
# File 'plugins/rake/rake_widgets.rb', line 72

def task
  sel = @ui.tasks.selection_model.selected_rows[0]
  sel ? sel.data.to_string : nil
end

- (nil) update_tasks (private)

Updates the list of tasks

Returns:

  • (nil)


102
103
104
105
106
107
# File 'plugins/rake/rake_widgets.rb', line 102

def update_tasks
  Ruber::Application.with_override_cursor do
    @project.extension(:rake).update_tasks
    fill_tasks_widget
  end
end

Slot Signature:

update_tasks()