Class: Ruber::ProjectBrowser::ToolWidget
- Inherits:
-
Qt::Widget
- Object
- Qt::Widget
- Ruber::ProjectBrowser::ToolWidget
- Defined in:
- plugins/project_browser/project_browser.rb
Overview
The tool widget displaying the project directory
Defined Under Namespace
Classes: FilterModel, View
Instance Method Summary (collapse)
-
- (nil) current_project_changed(prj)
slot
private
Slot called whenever the current project changes.
-
- (ToolWidget) initialize(parent = nil)
constructor
Creates a new instance.
-
- (nil) open_file_in_editor(idx)
slot
private
Slot called whenever the user activates an item in the view.
-
- (nil) project_option_changed(group, name)
slot
private
Slot called whenever a setting of the current project changes.
Constructor Details
- (ToolWidget) initialize(parent = nil)
Creates a new instance
The view of the new instance displays the contents of the directory of the current project, if any
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'plugins/project_browser/project_browser.rb', line 156 def initialize parent = nil super connect Ruber[:world], SIGNAL('active_project_changed(QObject*)'), self, SLOT('current_project_changed(QObject*)') self.layout = Qt::VBoxLayout.new self @view = View.new self @model = KDE::DirModel.new @view @model.dir_lister.open_url KDE::Url.new('/') @filter = FilterModel.new @view @filter.source_model = @model @view.model = @filter @view.edit_triggers = Qt::AbstractItemView::NoEditTriggers 1.upto(@model.column_count-1){|i| @view. i} @view.header_hidden = true layout. @view @project = nil current_project_changed Ruber[:world].active_project @view.connect(SIGNAL('only_project_files_triggered(bool)')){|val| @filter.do_filtering = val} connect @view, SIGNAL('activated(QModelIndex)'), self, SLOT('open_file_in_editor(QModelIndex)') end |
Instance Method Details
- (nil) current_project_changed(prj) (private)
Slot called whenever the current project changes
This method updates the view so that it displays the contents of the project directory (or disables the view if there’s no open project) and sets up the needed connections with the project
188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'plugins/project_browser/project_browser.rb', line 188 def current_project_changed prj @project.disconnect SIGNAL('option_changed(QString,QString)'), self if @project if prj @project = prj connect @project, SIGNAL('option_changed(QString, QString)'), self, SLOT('project_option_changed(QString, QString)') @model.dir_lister.open_url KDE::Url.new(prj.project_directory) @view.enabled = true else @view.enabled = false end @filter.project = prj nil end |
Slot Signature:
current_project_changed(QObject*)
- (nil) open_file_in_editor(idx) (private)
Slot called whenever the user activates an item in the view
If the item corresponds to a file, it will be opened in an editor, otherwise nothing will be done. The tool widget will be closed unless the Meta key is pressed
225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'plugins/project_browser/project_browser.rb', line 225 def open_file_in_editor idx #Currently, only the name column is supported. However, in the future, #other columns can be supported unless idx.column == KDE::DirModel::Name idx = @filter.index(KDE::DirModel::Name, idx.row, idx.parent) end item = @model.item_for_index @filter.map_to_source(idx) return if item.dir? file = item.local_path modifiers = Ruber[:app].keyboard_modifiers Ruber[:main_window].display_document file Ruber[:main_window]. self if (Qt::MetaModifier & modifiers) == 0 nil end |
Slot Signature:
open_file_in_editor(QModelIndex)
- (nil) project_option_changed(group, name) (private)
Slot called whenever a setting of the current project changes
It is needed to re-applicate the filter after the general/project_files
project
setting has changed
211 212 213 214 |
# File 'plugins/project_browser/project_browser.rb', line 211 def project_option_changed group, name @filter.invalidate_filter if group == 'general' and name == 'project_files' nil end |
Slot Signature:
project_option_changed(QString, QString)