Class: Ruber::ProjectFilesRuleChooser
- Defined in:
- lib/ruber/world/project_files_widget.rb
Overview
Widget which displays and allows to modify the rules which determine whether a file belongs to a project or not.
It contains a @Qt::TreeView@ where the rules are displayed and some buttons to add and remove rules. The tree view has two columns: the first displays the contents of the rules, while the second contains the rules’ type (whether they’re regexp rules or file rules).
Defined Under Namespace
Classes: RegexpRuleValidator
Instance Attribute Summary collapse
-
#project ⇒ Ruber::Project
writeonly
The project the widget displays rules for.
Instance Method Summary collapse
-
#initialize(parent = nil) ⇒ ProjectFilesRuleChooser
constructor
A new instance of ProjectFilesRuleChooser.
-
#rules ⇒ Array<String,Regexp>
The rules chosen by the user.
-
#rules=(list) ⇒ nil
Fills the tree view.
-
#sizeHint ⇒ Qt::Size
Override of @Qt::Widget#sizeHint@.
Constructor Details
#initialize(parent = nil) ⇒ ProjectFilesRuleChooser
Returns a new instance of ProjectFilesRuleChooser.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ruber/world/project_files_widget.rb', line 83 def initialize parent = nil super @project = nil @ui = Ui::ProjectFilesRuleChooser.new @ui.setupUi self model = Qt::StandardItemModel.new @ui. @ui..model = model model.horizontal_header_labels = %w[Pattern Type] connect @ui.add_regexp_btn, SIGNAL('clicked()'), self, SLOT('add_regexp_rule()') connect @ui.add_path_btn, SIGNAL('clicked()'), self, SLOT('add_path_rule()') connect @ui.remove_rule_btn, SIGNAL('clicked()'), self, SLOT('remove_rule()') connect @ui..selection_model, SIGNAL('selectionChanged(QItemSelection, QItemSelection)'), self, SLOT('change_button_state()') @ui.remove_rule_btn.enabled = false end |
Instance Attribute Details
#project=(value) ⇒ Ruber::Project (writeonly)
Returns the project the widget displays rules for.
49 50 51 |
# File 'lib/ruber/world/project_files_widget.rb', line 49 def project=(value) @project = value end |
Instance Method Details
#rules ⇒ Array<String,Regexp>
The rules chosen by the user
String entries correspond to file rules, while regexp entries correspond to regexp rules
114 115 116 117 118 119 120 |
# File 'lib/ruber/world/project_files_widget.rb', line 114 def rules @ui..model.enum_for(:each_row).map do |rule, type| if type.text == 'Path' then rule.text else Regexp.new rule.text end end end |
#rules=(list) ⇒ nil
Fills the tree view
Note: calling this method won’t trigger the #rules_edited signal
entries will be considered as file rules, while regexp entries will be considered regexp rules
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/ruber/world/project_files_widget.rb', line 132 def rules= list model = @ui..model model.clear model.horizontal_header_labels = %w[Pattern Type] list.each do |rule| type = 'Path' if rule.is_a? Regexp type = 'Regexp' rule = rule.source end model.append_row [Qt::StandardItem.new(rule), Qt::StandardItem.new(type)] end nil end |