ruber 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/CHANGES +54 -0
  2. data/bin/ruber +12 -1
  3. data/data/share/apps/ruber/ruberui.rc +5 -0
  4. data/data/share/icons/pin.png +0 -0
  5. data/lib/ruber/application/application.rb +1 -1
  6. data/lib/ruber/documents/document_list.rb +1 -1
  7. data/lib/ruber/editor/document.rb +26 -6
  8. data/lib/ruber/editor/editor_view.rb +21 -2
  9. data/lib/ruber/filtered_output_widget.rb +1 -1
  10. data/lib/ruber/ktexteditor_sugar.rb +124 -0
  11. data/lib/ruber/main_window/main_window.rb +34 -16
  12. data/lib/ruber/main_window/main_window_actions.rb +98 -5
  13. data/lib/ruber/main_window/main_window_internal.rb +1 -1
  14. data/lib/ruber/main_window/plugin.yaml +5 -0
  15. data/lib/ruber/main_window/ui/choose_plugins_widget.rb +2 -2
  16. data/lib/ruber/main_window/ui/main_window_settings_widget.rb +67 -34
  17. data/lib/ruber/main_window/ui/main_window_settings_widget.ui +77 -30
  18. data/lib/ruber/main_window/ui/new_project_widget.rb +2 -2
  19. data/lib/ruber/main_window/ui/open_file_in_project_dlg.rb +2 -2
  20. data/lib/ruber/main_window/ui/output_color_widget.rb +2 -2
  21. data/lib/ruber/main_window/ui/workspace_settings_widget.rb +1 -1
  22. data/lib/ruber/main_window/view_manager.rb +14 -1
  23. data/lib/ruber/output_widget.rb +409 -288
  24. data/lib/ruber/pane.rb +22 -0
  25. data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +2 -2
  26. data/lib/ruber/projects/ui/project_files_widget.rb +2 -2
  27. data/lib/ruber/qt_sugar.rb +11 -0
  28. data/lib/ruber/version.rb +1 -1
  29. data/plugins/auto_end/auto_end.rb +122 -0
  30. data/plugins/auto_end/plugin.yaml +11 -0
  31. data/plugins/autosave/ui/autosave_config_widget.rb +2 -2
  32. data/plugins/command/command.rb +71 -12
  33. data/plugins/command/output.rb +592 -0
  34. data/plugins/command/ui/tool_widget.rb +143 -0
  35. data/plugins/command/ui/tool_widget.ui +147 -0
  36. data/plugins/find_in_files/ui/config_widget.rb +2 -2
  37. data/plugins/find_in_files/ui/find_in_files_widget.rb +2 -2
  38. data/plugins/rake/ui/add_quick_task_widget.rb +2 -2
  39. data/plugins/rake/ui/choose_task_widget.rb +2 -2
  40. data/plugins/rake/ui/config_widget.rb +2 -2
  41. data/plugins/rake/ui/project_widget.rb +2 -2
  42. data/plugins/rspec/plugin.yaml +7 -2
  43. data/plugins/rspec/rspec.rb +178 -53
  44. data/plugins/rspec/rspecui.rc +2 -3
  45. data/plugins/rspec/ui/config_widget.rb +79 -0
  46. data/plugins/rspec/ui/config_widget.ui +89 -0
  47. data/plugins/rspec/ui/rspec_project_widget.rb +2 -2
  48. data/plugins/ruby_development/ruby_development.rb +1 -1
  49. data/plugins/ruby_development/ui/config_widget.rb +1 -1
  50. data/plugins/ruby_development/ui/project_widget.rb +2 -2
  51. data/plugins/ruby_runner/ruby_runner.rb +13 -12
  52. data/plugins/ruby_runner/ui/config_widget.rb +2 -2
  53. data/plugins/ruby_runner/ui/project_widget.rb +2 -2
  54. data/plugins/ruby_runner/ui/ruby_runnner_plugin_option_widget.rb +2 -2
  55. data/plugins/state/ui/config_widget.rb +2 -2
  56. data/plugins/syntax_checker/syntax_checker.rb +1 -1
  57. data/spec/auto_end_spec.rb +272 -0
  58. data/spec/common.rb +1 -0
  59. data/spec/document_spec.rb +83 -0
  60. data/spec/editor_view_spec.rb +41 -0
  61. data/spec/filtered_output_widget_spec.rb +2 -2
  62. data/spec/ktexteditor_sugar_spec.rb +190 -0
  63. data/spec/output_widget_spec.rb +120 -11
  64. data/spec/pane_spec.rb +1 -1
  65. data/spec/qt_sugar_spec.rb +14 -0
  66. data/spec/state_spec.rb +0 -26
  67. metadata +14 -3
@@ -104,7 +104,7 @@ It adds the document to the part manager and makes several signal-slot connectio
104
104
  update_switch_to_list
105
105
  end
106
106
  slots 'document_created(QObject*)'
107
-
107
+
108
108
  def remove_document_from_part_manager doc
109
109
  @view_manager.part_manager.remove_part doc.send(:internal)
110
110
  end
@@ -8,6 +8,7 @@ config_options:
8
8
  output_font: {default: 'Qt::Font.new("Courier",10)'}
9
9
  auto_annotations: {type: bool, default: 'true'}
10
10
  wrap_output: {type: bool, default: 'true'}
11
+ tool_open_files: {default: :existing}
11
12
  output_colors:
12
13
  message: {default: 'Qt::Color.new(Qt.black)'}
13
14
  message_good: {default: 'Qt::Color.new(Qt.blue)'}
@@ -64,5 +65,9 @@ actions:
64
65
  window-switch_to_new_document: {text: Switch to New File, slot: switch_to_new_document(), state: current_document}
65
66
  window-switch_to_file: {text: Switch to Open File, slot: switch_to_file(), state: current_document}
66
67
  window-switch_to_recent_file: {signal: urlSelected(KUrl), slot: switch_to_recent_file(KUrl), class: KDE::RecentFilesAction, text: Switch to Recent File, state: current_document}
68
+ window-next_horizontally: {text: Next View Horizontally, slot: move_among_views(), state: current_document, shortcut: Ctrl+Alt+Right}
69
+ window-next_vertically: {text: Next View Vertically, slot: move_among_views(), state: current_document, shortcut: Ctrl+Alt+PgDown}
70
+ window-previous_horizontally: {text: Previous View Horizontally, slot: move_among_views(), state: current_document, shortcut: Ctrl+Alt+Left}
71
+ window-previous_vertically: {text: Previous View Vertically, slot: move_among_views(), state: current_document, shortcut: Ctrl+Alt+PgUp}
67
72
  extensions:
68
73
  ruber_default_document: {class: Ruber::Application::DefaultDocumentExtension, scope: document, place: all}
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  ** Form generated from reading ui file 'choose_plugins_widget.ui'
3
3
  **
4
- ** Created: mar nov 16 11:52:49 2010
5
- ** by: Qt User Interface Compiler version 4.7.0
4
+ ** Created: mer gen 12 12:12:11 2011
5
+ ** by: Qt User Interface Compiler version 4.7.1
6
6
  **
7
7
  ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
8
  =end
@@ -1,40 +1,76 @@
1
1
  =begin
2
2
  ** Form generated from reading ui file 'main_window_settings_widget.ui'
3
3
  **
4
- ** Created: mar nov 16 11:52:49 2010
5
- ** by: Qt User Interface Compiler version 4.7.0
4
+ ** Created: ven gen 28 14:09:05 2011
5
+ ** by: Qt User Interface Compiler version 4.7.1
6
6
  **
7
7
  ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
8
  =end
9
9
 
10
10
  class Ui_MainWindowSettingsWidget
11
+ attr_reader :verticalLayout_2
12
+ attr_reader :groupBox
13
+ attr_reader :gridLayout_2
14
+ attr_reader :label_2
15
+ attr_reader :_general__default_script_directory
16
+ attr_reader :label_3
17
+ attr_reader :_general__default_project_directory
18
+ attr_reader :groupBox_2
11
19
  attr_reader :verticalLayout
12
20
  attr_reader :horizontalLayout
13
21
  attr_reader :label
14
22
  attr_reader :_general__output_font
15
23
  attr_reader :_general__wrap_output
16
- attr_reader :groupBox
17
- attr_reader :formLayout
18
- attr_reader :label_2
19
- attr_reader :label_3
20
- attr_reader :_general__default_script_directory
21
- attr_reader :_general__default_project_directory
24
+ attr_reader :horizontalLayout_2
25
+ attr_reader :label_4
26
+ attr_reader :_general__tool_open_files
22
27
 
23
28
  def setupUi(mainWindowSettingsWidget)
24
29
  if mainWindowSettingsWidget.objectName.nil?
25
30
  mainWindowSettingsWidget.objectName = "mainWindowSettingsWidget"
26
31
  end
27
- mainWindowSettingsWidget.resize(380, 154)
28
- @verticalLayout = Qt::VBoxLayout.new(mainWindowSettingsWidget)
32
+ mainWindowSettingsWidget.resize(507, 235)
33
+ @verticalLayout_2 = Qt::VBoxLayout.new(mainWindowSettingsWidget)
34
+ @verticalLayout_2.objectName = "verticalLayout_2"
35
+ @groupBox = Qt::GroupBox.new(mainWindowSettingsWidget)
36
+ @groupBox.objectName = "groupBox"
37
+ @gridLayout_2 = Qt::GridLayout.new(@groupBox)
38
+ @gridLayout_2.objectName = "gridLayout_2"
39
+ @label_2 = Qt::Label.new(@groupBox)
40
+ @label_2.objectName = "label_2"
41
+
42
+ @gridLayout_2.addWidget(@label_2, 0, 0, 1, 1)
43
+
44
+ @_general__default_script_directory = KDE::UrlRequester.new(@groupBox)
45
+ @_general__default_script_directory.objectName = "_general__default_script_directory"
46
+
47
+ @gridLayout_2.addWidget(@_general__default_script_directory, 0, 1, 1, 1)
48
+
49
+ @label_3 = Qt::Label.new(@groupBox)
50
+ @label_3.objectName = "label_3"
51
+
52
+ @gridLayout_2.addWidget(@label_3, 1, 0, 1, 1)
53
+
54
+ @_general__default_project_directory = KDE::UrlRequester.new(@groupBox)
55
+ @_general__default_project_directory.objectName = "_general__default_project_directory"
56
+
57
+ @gridLayout_2.addWidget(@_general__default_project_directory, 1, 1, 1, 1)
58
+
59
+
60
+ @verticalLayout_2.addWidget(@groupBox)
61
+
62
+ @groupBox_2 = Qt::GroupBox.new(mainWindowSettingsWidget)
63
+ @groupBox_2.objectName = "groupBox_2"
64
+ @verticalLayout = Qt::VBoxLayout.new(@groupBox_2)
29
65
  @verticalLayout.objectName = "verticalLayout"
30
66
  @horizontalLayout = Qt::HBoxLayout.new()
31
67
  @horizontalLayout.objectName = "horizontalLayout"
32
- @label = Qt::Label.new(mainWindowSettingsWidget)
68
+ @label = Qt::Label.new(@groupBox_2)
33
69
  @label.objectName = "label"
34
70
 
35
71
  @horizontalLayout.addWidget(@label)
36
72
 
37
- @_general__output_font = KDE::FontRequester.new(mainWindowSettingsWidget)
73
+ @_general__output_font = KDE::FontRequester.new(@groupBox_2)
38
74
  @_general__output_font.objectName = "_general__output_font"
39
75
 
40
76
  @horizontalLayout.addWidget(@_general__output_font)
@@ -42,37 +78,28 @@ class Ui_MainWindowSettingsWidget
42
78
 
43
79
  @verticalLayout.addLayout(@horizontalLayout)
44
80
 
45
- @_general__wrap_output = Qt::CheckBox.new(mainWindowSettingsWidget)
81
+ @_general__wrap_output = Qt::CheckBox.new(@groupBox_2)
46
82
  @_general__wrap_output.objectName = "_general__wrap_output"
47
83
 
48
84
  @verticalLayout.addWidget(@_general__wrap_output)
49
85
 
50
- @groupBox = Qt::GroupBox.new(mainWindowSettingsWidget)
51
- @groupBox.objectName = "groupBox"
52
- @formLayout = Qt::FormLayout.new(@groupBox)
53
- @formLayout.objectName = "formLayout"
54
- @label_2 = Qt::Label.new(@groupBox)
55
- @label_2.objectName = "label_2"
86
+ @horizontalLayout_2 = Qt::HBoxLayout.new()
87
+ @horizontalLayout_2.objectName = "horizontalLayout_2"
88
+ @label_4 = Qt::Label.new(@groupBox_2)
89
+ @label_4.objectName = "label_4"
56
90
 
57
- @formLayout.setWidget(1, Qt::FormLayout::LabelRole, @label_2)
91
+ @horizontalLayout_2.addWidget(@label_4)
58
92
 
59
- @label_3 = Qt::Label.new(@groupBox)
60
- @label_3.objectName = "label_3"
61
-
62
- @formLayout.setWidget(2, Qt::FormLayout::LabelRole, @label_3)
93
+ @_general__tool_open_files = KDE::ComboBox.new(@groupBox_2)
94
+ @_general__tool_open_files.objectName = "_general__tool_open_files"
63
95
 
64
- @_general__default_script_directory = KDE::UrlRequester.new(@groupBox)
65
- @_general__default_script_directory.objectName = "_general__default_script_directory"
96
+ @horizontalLayout_2.addWidget(@_general__tool_open_files)
66
97
 
67
- @formLayout.setWidget(1, Qt::FormLayout::FieldRole, @_general__default_script_directory)
68
98
 
69
- @_general__default_project_directory = KDE::UrlRequester.new(@groupBox)
70
- @_general__default_project_directory.objectName = "_general__default_project_directory"
99
+ @verticalLayout.addLayout(@horizontalLayout_2)
71
100
 
72
- @formLayout.setWidget(2, Qt::FormLayout::FieldRole, @_general__default_project_directory)
73
101
 
74
-
75
- @verticalLayout.addWidget(@groupBox)
102
+ @verticalLayout_2.addWidget(@groupBox_2)
76
103
 
77
104
  @label_2.buddy = @_general__default_script_directory
78
105
  @label_3.buddy = @_general__default_project_directory
@@ -88,11 +115,17 @@ class Ui_MainWindowSettingsWidget
88
115
 
89
116
  def retranslateUi(mainWindowSettingsWidget)
90
117
  mainWindowSettingsWidget.windowTitle = Qt::Application.translate("MainWindowSettingsWidget", "Form", nil, Qt::Application::UnicodeUTF8)
91
- @label.text = Qt::Application.translate("MainWindowSettingsWidget", "Output font", nil, Qt::Application::UnicodeUTF8)
92
- @_general__wrap_output.text = Qt::Application.translate("MainWindowSettingsWidget", "&Wrap lines in output widgets", nil, Qt::Application::UnicodeUTF8)
93
118
  @groupBox.title = Qt::Application.translate("MainWindowSettingsWidget", "Default paths", nil, Qt::Application::UnicodeUTF8)
94
119
  @label_2.text = Qt::Application.translate("MainWindowSettingsWidget", "&Default script directory", nil, Qt::Application::UnicodeUTF8)
95
120
  @label_3.text = Qt::Application.translate("MainWindowSettingsWidget", "&Default project directory", nil, Qt::Application::UnicodeUTF8)
121
+ @groupBox_2.title = Qt::Application.translate("MainWindowSettingsWidget", "Output", nil, Qt::Application::UnicodeUTF8)
122
+ @label.text = Qt::Application.translate("MainWindowSettingsWidget", "Output font", nil, Qt::Application::UnicodeUTF8)
123
+ @_general__wrap_output.text = Qt::Application.translate("MainWindowSettingsWidget", "&Wrap lines in output widgets", nil, Qt::Application::UnicodeUTF8)
124
+ @label_4.text = Qt::Application.translate("MainWindowSettingsWidget", "When opening files from tool widgets in a new editor", nil, Qt::Application::UnicodeUTF8)
125
+ @_general__tool_open_files.insertItems(0, [Qt::Application.translate("MainWindowSettingsWidget", "Open editor in new tab", nil, Qt::Application::UnicodeUTF8),
126
+ Qt::Application.translate("MainWindowSettingsWidget", "Split current editor horizontally", nil, Qt::Application::UnicodeUTF8),
127
+ Qt::Application.translate("MainWindowSettingsWidget", "Split current editor vertically", nil, Qt::Application::UnicodeUTF8)])
128
+ @_general__tool_open_files.setProperty("access", Qt::Variant.new(Qt::Application.translate("MainWindowSettingsWidget", "$tool_open_files", nil, Qt::Application::UnicodeUTF8)))
96
129
  end # retranslateUi
97
130
 
98
131
  def retranslate_ui(mainWindowSettingsWidget)
@@ -6,42 +6,21 @@
6
6
  <rect>
7
7
  <x>0</x>
8
8
  <y>0</y>
9
- <width>380</width>
10
- <height>154</height>
9
+ <width>507</width>
10
+ <height>235</height>
11
11
  </rect>
12
12
  </property>
13
13
  <property name="windowTitle">
14
14
  <string>Form</string>
15
15
  </property>
16
- <layout class="QVBoxLayout" name="verticalLayout">
17
- <item>
18
- <layout class="QHBoxLayout" name="horizontalLayout">
19
- <item>
20
- <widget class="QLabel" name="label">
21
- <property name="text">
22
- <string>Output font</string>
23
- </property>
24
- </widget>
25
- </item>
26
- <item>
27
- <widget class="KFontRequester" name="_general__output_font"/>
28
- </item>
29
- </layout>
30
- </item>
31
- <item>
32
- <widget class="QCheckBox" name="_general__wrap_output">
33
- <property name="text">
34
- <string>&amp;Wrap lines in output widgets</string>
35
- </property>
36
- </widget>
37
- </item>
16
+ <layout class="QVBoxLayout" name="verticalLayout_2">
38
17
  <item>
39
18
  <widget class="QGroupBox" name="groupBox">
40
19
  <property name="title">
41
20
  <string>Default paths</string>
42
21
  </property>
43
- <layout class="QFormLayout" name="formLayout">
44
- <item row="1" column="0">
22
+ <layout class="QGridLayout" name="gridLayout_2">
23
+ <item row="0" column="0">
45
24
  <widget class="QLabel" name="label_2">
46
25
  <property name="text">
47
26
  <string>&amp;Default script directory</string>
@@ -51,7 +30,10 @@
51
30
  </property>
52
31
  </widget>
53
32
  </item>
54
- <item row="2" column="0">
33
+ <item row="0" column="1">
34
+ <widget class="KUrlRequester" name="_general__default_script_directory"/>
35
+ </item>
36
+ <item row="1" column="0">
55
37
  <widget class="QLabel" name="label_3">
56
38
  <property name="text">
57
39
  <string>&amp;Default project directory</string>
@@ -62,14 +44,74 @@
62
44
  </widget>
63
45
  </item>
64
46
  <item row="1" column="1">
65
- <widget class="KUrlRequester" name="_general__default_script_directory"/>
66
- </item>
67
- <item row="2" column="1">
68
47
  <widget class="KUrlRequester" name="_general__default_project_directory"/>
69
48
  </item>
70
49
  </layout>
71
50
  </widget>
72
51
  </item>
52
+ <item>
53
+ <widget class="QGroupBox" name="groupBox_2">
54
+ <property name="title">
55
+ <string>Output</string>
56
+ </property>
57
+ <layout class="QVBoxLayout" name="verticalLayout">
58
+ <item>
59
+ <layout class="QHBoxLayout" name="horizontalLayout">
60
+ <item>
61
+ <widget class="QLabel" name="label">
62
+ <property name="text">
63
+ <string>Output font</string>
64
+ </property>
65
+ </widget>
66
+ </item>
67
+ <item>
68
+ <widget class="KFontRequester" name="_general__output_font"/>
69
+ </item>
70
+ </layout>
71
+ </item>
72
+ <item>
73
+ <widget class="QCheckBox" name="_general__wrap_output">
74
+ <property name="text">
75
+ <string>&amp;Wrap lines in output widgets</string>
76
+ </property>
77
+ </widget>
78
+ </item>
79
+ <item>
80
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
81
+ <item>
82
+ <widget class="QLabel" name="label_4">
83
+ <property name="text">
84
+ <string>When opening files from tool widgets in a new editor</string>
85
+ </property>
86
+ </widget>
87
+ </item>
88
+ <item>
89
+ <widget class="KComboBox" name="_general__tool_open_files">
90
+ <property name="access" stdset="0">
91
+ <string>$tool_open_files</string>
92
+ </property>
93
+ <item>
94
+ <property name="text">
95
+ <string>Open editor in new tab</string>
96
+ </property>
97
+ </item>
98
+ <item>
99
+ <property name="text">
100
+ <string>Split current editor horizontally</string>
101
+ </property>
102
+ </item>
103
+ <item>
104
+ <property name="text">
105
+ <string>Split current editor vertically</string>
106
+ </property>
107
+ </item>
108
+ </widget>
109
+ </item>
110
+ </layout>
111
+ </item>
112
+ </layout>
113
+ </widget>
114
+ </item>
73
115
  </layout>
74
116
  </widget>
75
117
  <customwidgets>
@@ -83,6 +125,11 @@
83
125
  <extends>QWidget</extends>
84
126
  <header>kfontrequester.h</header>
85
127
  </customwidget>
128
+ <customwidget>
129
+ <class>KComboBox</class>
130
+ <extends>QComboBox</extends>
131
+ <header>kcombobox.h</header>
132
+ </customwidget>
86
133
  </customwidgets>
87
134
  <resources/>
88
135
  <connections/>
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  ** Form generated from reading ui file 'new_project_widget.ui'
3
3
  **
4
- ** Created: mar nov 16 11:52:48 2010
5
- ** by: Qt User Interface Compiler version 4.7.0
4
+ ** Created: mer gen 12 12:12:11 2011
5
+ ** by: Qt User Interface Compiler version 4.7.1
6
6
  **
7
7
  ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
8
  =end
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  ** Form generated from reading ui file 'open_file_in_project_dlg.ui'
3
3
  **
4
- ** Created: mar nov 16 11:52:49 2010
5
- ** by: Qt User Interface Compiler version 4.7.0
4
+ ** Created: mer gen 12 12:12:11 2011
5
+ ** by: Qt User Interface Compiler version 4.7.1
6
6
  **
7
7
  ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
8
  =end
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  ** Form generated from reading ui file 'output_color_widget.ui'
3
3
  **
4
- ** Created: mar nov 16 11:52:49 2010
5
- ** by: Qt User Interface Compiler version 4.7.0
4
+ ** Created: mer gen 12 12:12:11 2011
5
+ ** by: Qt User Interface Compiler version 4.7.1
6
6
  **
7
7
  ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
8
  =end
@@ -1,7 +1,7 @@
1
1
  =begin
2
2
  ** Form generated from reading ui file 'workspace_settings_widget.ui'
3
3
  **
4
- ** Created: mar gen 11 14:57:22 2011
4
+ ** Created: mer gen 12 12:12:11 2011
5
5
  ** by: Qt User Interface Compiler version 4.7.1
6
6
  **
7
7
  ** WARNING! All changes made in this file will be lost when recompiling ui file!
@@ -113,6 +113,7 @@ contain another value, @:close_starting_document@
113
113
  view = @solver.place_editor hints
114
114
  if view
115
115
  dir = Qt.const_get hints[:split].to_s.capitalize
116
+ # tab(view).split view, editor, dir
116
117
  view.parent.split view, editor, dir
117
118
  else
118
119
  if hints[:close_starting_document]
@@ -335,14 +336,26 @@ The views is activated, unless it was already active
335
336
  =begin rdoc
336
337
  Slot called whenever a view is closed
337
338
 
338
- It deactivates the view (if it was active) and preforms some cleanup.
339
+ It deactivates the view (if it was active), performs some cleanup and gives focus
340
+ to the editor which had focus before (if any).
339
341
  @param [EditorView] view the view which is being closed
340
342
  @return [nil]
341
343
  =end
342
344
  def view_closing view
345
+ view_tab = self.tab(view)
346
+ has_focus = view_tab.is_active_window if view_tab
347
+ if has_focus
348
+ views = view_tab.to_a
349
+ idx = views.index(view)
350
+ new_view = views[idx-1] || views[idx+1]
351
+ end
343
352
  @activation_order.delete view
344
353
  disconnect view, SIGNAL('focus_in(QWidget*)'), self, SLOT('focus_in_view(QWidget*)')
345
354
  deactivate_editor view
355
+ if new_view
356
+ make_editor_active new_view
357
+ new_view.set_focus
358
+ end
346
359
  nil
347
360
  end
348
361
  slots 'view_closing(QWidget*)'
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (C) 2010 by Stefano Crocco
2
+ Copyright (C) 2010,2011 by Stefano Crocco
3
3
  stefano.crocco@alice.it
4
4
 
5
5
  This program is free software; you can redistribute it andor modify
@@ -24,6 +24,7 @@ require 'ruber/gui_states_handler'
24
24
 
25
25
  module Ruber
26
26
 
27
+
27
28
  =begin rdoc
28
29
  Widget meant to be used as tool widget to display the output of a program. It is
29
30
  based on Qt Model/View classes and provides the following facitlities:
@@ -44,140 +45,151 @@ based on Qt Model/View classes and provides the following facitlities:
44
45
  couple of convenience methods to make text insertion even easier.
45
46
 
46
47
  Note that OutputWidget is not (and doesn't derive from) one of the View classes.
47
- Rather, it's a normal <tt>Qt::Widget</tt> which has the view as its only child.
48
+ Rather, it's a normal @Qt::Widget@ which has the view as its only child.
48
49
  You can add other widgets to the OutputWidget as you would with any other widget:
49
50
  create the widget with the OutputWidget as parent and add it to the OutputWidget's
50
- layout (which is a <tt>Qt::GridLayout</tt> where the view is at position 0,0).
51
+ layout (which is a @Qt::GridLayout@ where the view is at position 0,0).
51
52
 
52
- <b>Note:</b> this class defines two new roles (<tt>OutputTypeRole</tt> and <tt>IsTitleRole</tt>),
53
- which correspond to <tt>Qt::UserRole</tt> and <tt>Qt::UserRole+1</tt>. Therefore,
53
+ *Note:* this class defines two new roles (@OutputTypeRole@ and @IsTitleRole@),
54
+ which correspond to @Qt::UserRole@ and @Qt::UserRole+1@. Therefore,
54
55
  if you need to define other custom roles, please have them start from
55
- <tt>Ruber::OutputWidget::IsTitleRole+1</tt>.
56
+ @Ruber::OutputWidget::IsTitleRole+1@.
56
57
 
57
- ===Colors
58
- The <i>output_type</i> of an entry in the model can be set using the <tt>set_output_type</tt>
58
+ h3. Output types
59
+
60
+ The @output_type@ of an entry in the model can be set using the {#set_output_type}
59
61
  method. This has two effects: first, the item will be displayed using the color
60
62
  chosen by the user for that output type; second, the name of the output type will
61
- be stored in that item under the custom role <tt>OutputTypeRole</tt>.
63
+ be stored in that item under the custom role @OutputTypeRole@.
62
64
 
63
- There are several predefined output types: +message+, <tt>message_good</tt>,
64
- <tt>message_bad</tt>, +output+,
65
- +output1+, +output2+, +warning+, +warning1+, +warning2+, +error+, +error1+ and +error2+.
65
+ There are several predefined output types: @message@, @message_good@,
66
+ @message_bad@, @output@,
67
+ @output1@, @output2@, @warning@, @warning1@, @warning2@, @error@, @error1@ and @error2@.
66
68
  The types ending with a number
67
- can be used when you need different types with similar meaning. The +message+ type
69
+ can be used when you need different types with similar meaning.
70
+
71
+ The @message@ type
68
72
  (and its variations) are meant to display messages which don't come from the external
69
73
  program but from Ruber itself (for example, a message telling that the external
70
- problem exited successfully or exited with an error) Its good and bad version are
74
+ problem exited successfully or exited with an error). Its good and bad version are
71
75
  meant to display messages with good news and bad news respectively (for example:
72
- "the program exited successfully" could be displayed using the <tt>message_good</tt>
73
- type, while "the program crashed" could be displayed using the <tt>message_bad</tt>
74
- type). The +output+ type is meant
76
+ "the program exited successfully" could be displayed using the @message_good@
77
+ type, while "the program crashed" could be displayed using the @message_bad@
78
+ type).
79
+
80
+ The @output@ type is meant
75
81
  to be used to show the text written by the external program on standard output,
76
- while the +error+ type is used to display the text written on standard error. If
77
- you can distinguish between warning and errors, you can use the +warning+ type
82
+ while the @error@ type is used to display the text written on standard error. If
83
+ you can distinguish between warning and errors, you can use the @warning@ type
78
84
  for the latter.
79
85
 
80
86
  The colors for the default output types are chosen by the user from the configuration
81
87
  dialog and are used whenever those output types are requested.
82
88
 
83
89
  New output types (and their associated colors) can be make known to the output
84
- widget by using the <tt>set_color_for</tt> method. There's no need to remove the
90
+ widget by using the @set_color_for@ method. There's no need to remove the
85
91
  color, for example when the plugin is unloaded (indeed, there's no way to do so).
86
92
 
87
- ===The context menu
88
- This widget automatically creates a context menu containing three actions: copy,
89
- copy selected and clear. Copy and copy selected copy the text contained respectively
93
+ h3. The context menu
94
+
95
+ This widget automatically creates a context menu containing three actions: Copy,
96
+ Copy Selected and Clear. Copy and Copy Selected copy the text contained respectively
90
97
  in all the items and in the selected items to the clipboard. The clear action
91
98
  removes all the entries from the model.
92
99
 
93
100
  You can add other actions to the menu by performing the following steps:
94
- * add an entry in the appropriate position of the <tt>action_list</tt> array. Note
95
- that it actually is an instance of ActionList, so it provides the <tt>insert_after</tt>
96
- and <tt>insert_before</tt> methods which allow to easily put the actions in the
97
- correct place. <tt>action_list</tt> should contain the <tt>object_name</tt> of
101
+ * add an entry in the appropriate position of {#action_list}. Note
102
+ that this is an instance of ActionList, so it provides the {ActionList#insert_after insert_after}
103
+ and {ActionList#insert_before insert_before} methods which allow to easily put the actions in the
104
+ correct place. {#action_list} contains the @object_name@ of
98
105
  the actions (and *nil* for the separators), not the action themselves
99
- * create the actions (setting their <tt>object_name</tt> to the values inserted
100
- in <tt>action_list</tt>) and put them into the +actions+ hash, using the <tt>object_name</tt>
106
+ * create the actions (setting their @object_name@ to the values inserted
107
+ in {#action_list}) and put them into the {#actions} hash, using the @object_name@
101
108
  as keys. Of course, you also need to define the appropriate slots and connect
102
109
  them to the actions' signals.
103
110
 
104
111
  Note that actions can only be added _before_ the menu is first shown (usually, you
105
- do that in the widget's constructor). The signal <tt>about_to_fill_menu</tt> is
112
+ do that in the widget's constructor). The {#about_to_fill_menu} signal is
106
113
  emitted just before the menu is built: this is the last time you can add entries
107
114
  to it.
108
115
 
109
- OutputWidget mixes in the GuiStatesHandler module, which means you can define states
110
- to enable and disable actions as usual. By default, two states are defined: <tt>no_text</tt>
111
- and <tt>no_selection</tt>. As the names imply, the former is *true* when the model
116
+ {OutputWidget} mixes in the {GuiStatesHandler} module, which means you can define states
117
+ to enable and disable actions as usual. By default, two states are defined: @no_text@
118
+ and @no_selection@. As the names imply, the former is *true* when the model
112
119
  is empty and *false* when there's at least one item; the second is *true* when no
113
120
  item is selected and *false* when there are selected items.
114
121
 
115
- For the menu to be displayed automatically, the view should have a <tt>context_menu_requested(QPoint)</tt>
122
+ For the menu to be displayed automatically, the view should have a @context_menu_requested(QPoint)@
116
123
  signal. The menu will be displayed in response to that signal, at the point given
117
- as argument. For convenience, there are three classes <tt>OutputWidget::ListView</tt>,
118
- <tt>OutputWidget::TreeView</tt> and <tt>OutputWidget::TableView</tt>, derived
119
- respectively from <tt>Qt::ListView</tt>, <tt>Qt::TreeView</tt> and <tt>Qt::TableView</tt>
120
- which emit that signal from their <tt>contextMenuEvent</tt> method. If you use
124
+ as argument. For convenience, there are three classes {OutputWidget::ListView},
125
+ {OutputWidget::TreeView} and {OutputWidget::TableView}, derived
126
+ respectively from @Qt::ListView@, @Qt::TreeView@ and @Qt::TableView@
127
+ which emit that signal from their @contextMenuEvent@ method. If you use
121
128
  one of these classes as view, the menu will work automatically.
122
129
 
123
- ===Autoscrolling
130
+ h3. Autoscrolling
131
+
124
132
  Whenever an item is added to the list, the view will be scrolled so that the added
125
- item is visible. Plugins which don't want this feature can disable it using the
126
- <tt>auto_scroll</tt> accessor. Note that auto scrolling won't happen if an item
133
+ item is visible. Plugins which don't want this feature can disable it by setting
134
+ {#auto_scroll} to *false*. Note that auto scrolling won't happen if an item
127
135
  is modified or removed
128
136
 
129
- ===Word Wrapping
130
- If the user has enabled word wrapping for output widgets in the config dialog (
131
- the general/wrap_output option), word wrapping will be automatically enabled for
137
+ h3. Word wrapping
138
+
139
+ If the user has enabled word wrapping for output widgets in the config dialog
140
+ (the @general/wrap_output@ option), word wrapping will be automatically enabled for
132
141
  all output widgets. If the user has disabled it, it will be disabled for all
133
142
  widgets.
134
143
 
135
- Subclasses can avoid the automatic behaviour by setting the <tt>ignore_word_wrap_option</tt>
144
+ Subclasses can avoid the automatic behaviour by setting the {#ignore_word_wrap_option}
136
145
  attribute to *true* and managing word wrap by themselves. This is mostly useful
137
146
  for output widgets for which word wrap is undesirable or meaningless.
138
147
 
139
- ===Opening files in the editor
148
+ h3. Opening files in the editor
149
+
140
150
  Whenever the user activates an item, the text of the item is searched for a filename
141
151
  (and optionally for a line number). If it's found, a new editor view is opened
142
- and the file is displayed in it. This process uses three methods:
143
- <tt>maybe_open_file</tt>::
144
- the method connected to the view's <tt>activated(QModelIndex)</tt> signal. It
145
- starts the search for the filename and, if successful, opens the editor view
146
- <tt>find_filename_in_index</tt>::
147
- performs the search of the filename. By default, it uses <tt>find_filename_in_string</tt>,
148
- but subclasses can override it to change the behaviour
149
- <tt>find_filename_in_string</tt>::
150
- the method used by default by <tt>find_filename_in_index</tt> to find the
151
- filename.
152
+ and the file is displayed in it. The editor can be an already existing editor
153
+ or a new one created by splitting the current editor or in a new tab, according to
154
+ the @general/tool_open_files@ option.
155
+
156
+ This process uses four methods:
157
+
158
+ - {#maybe_open_file}:=
159
+ the method connected to the view's @activated(QModelIndex)@ signal. It
160
+ starts the search for the filename and, if successful, opens the editor view =:
161
+ - {#find_filename_in_index}:=
162
+ performs the search of the filename. By default, it uses {#find_filename_in_string},
163
+ but subclasses can override it to change the behaviour=:
164
+ - {#find_filename_in_string}:=
165
+ the method used by default by {#find_filename_in_index} to find the
166
+ filename.=:
167
+ - {#display_file}:= opens the file in an editor. By default uses the @general/tool_open_files@
168
+ to decide how the editor should be created, but this behaviour can be overridden
169
+ by subclasses.
152
170
 
153
171
  If a relative filename is found, it's considered relative to the directory contained
154
- in the <tt>working_dir</tt> attribute.
172
+ in the {#working_dir} attribute.
155
173
 
156
- ===The <tt>OutputWidget::Model</tt> class
157
- It behaves as a standard <tt>Qt::StandardItemModel</tt>, but it provides an +insert+
158
- method and an <tt>insert_lines</tt> method which make easier adding items. You
159
- don't need to use this model. If you don't, simply pass another one to the OutputWidget
160
- constructor
174
+ h3. {OutputWidget::Model}
161
175
 
162
- ===Signals
163
- =====<tt>about_to_fill_menu()</tt>
164
- Signal emitted immediately before the menu is created. You should connect to this
165
- signal if you want to add actions to the menu at the last possible time. Usually,
166
- however, you don't need it, as actions are usually created in the constructor.
167
- ===Slots
168
- * <tt>show_menu(QPoint)</tt>
169
- * <tt>selection_changed(QItemSelection, QItemSelection)</tt>
170
- * <tt>rows_changed()</tt>
171
- * <tt>do_auto_scroll(QModelIndex, int, int)</tt>
172
- * <tt>copy()</tt>
173
- * <tt>copy_selected()</tt>
174
- * <tt>clear_output()</tt>
175
- * <tt>maybe_open_file()</tt>
176
+ The {OutputWidget::Model} class behaves as a standard @Qt::StandardItemModel@, but
177
+ provides two methods, {OutputWidget::Model#insert insert} and
178
+ {OutputWidget::Model#insert_lines insert_lines} which make easier adding items. You
179
+ aren't forced to use this model, however: if you want to use another class,
180
+ pass it to the constructor.
176
181
  =end
177
182
  class OutputWidget < Qt::Widget
178
183
 
179
184
  include GuiStatesHandler
185
+
186
+ =begin rdoc
187
+ Signal emitted immediately before the menu is created
180
188
 
189
+ You should connect to this
190
+ signal if you want to add actions to the menu at the last possible time. Usually,
191
+ however, you don't need it, as actions are usually created in the constructor.
192
+ =end
181
193
  signals :about_to_fill_menu
182
194
 
183
195
  slots 'show_menu(QPoint)', 'selection_changed(QItemSelection, QItemSelection)',
@@ -195,76 +207,70 @@ The role which contains whether an item is or not the title
195
207
  IsTitleRole = OutputTypeRole + 1
196
208
 
197
209
  =begin rdoc
198
- Whether auto scrolling should be enabled or not (default: *true*)
210
+ @return [Boolean ] whether auto scrolling should be enabled or not (default: *true*)
199
211
  =end
200
212
  attr_accessor :auto_scroll
201
213
 
202
214
  =begin rdoc
203
- Whether word wrapping should be enabled and disabled automatically according to
204
- the general/wrap_output setting or not (default: *false*)
215
+ @return [Boolean] whether or not word wrapping should respect the @general/wrap_output@ option (default: *false*)
205
216
  =end
206
217
  attr_accessor :ignore_word_wrap_option
207
218
 
208
219
  =begin rdoc
209
- The directory used to resolve relative paths when opening a file (default *nil*)
220
+ @return [String] the directory used to resolve relative paths when opening a file (default *nil*)
210
221
  =end
211
222
  attr_accessor :working_dir
212
223
  alias :working_directory :working_dir
213
224
  alias :working_directory= :working_dir=
214
225
 
215
226
  =begin rdoc
216
- Whether or not to skip the first file name in the title if the user activates it
217
- (see <tt>find_filename_in_index</tt>)
227
+ @return [Boolean] whether or not to {#find_filename_in_index} should skip the first
228
+ file name in the title
218
229
  =end
219
230
  attr_accessor :skip_first_file_in_title
220
231
 
221
232
  =begin rdoc
222
- An ActionList containing the names of the actions and the separators (represented
223
- by *nil*) to use to build the menu. The default is ['copy', 'copy_selected', nil, 'clear'].
224
-
225
- <b>Note:</b> this is private
233
+ @return [ActionList] the names of the action to use to build the menu
234
+
235
+ Separators are represented by *nil* entries. The default is
236
+ @['copy', 'copy_selected', nil, 'clear']@.
226
237
  =end
227
238
  attr_reader :action_list
228
239
 
229
240
  =begin rdoc
230
- A hash having the names of actions to be inserted in the menu as keys and the actions
231
- themselves as values. By default, it contains the 'copy', 'copy_selected' and
232
- 'clear' actions.
241
+ @return [Hash{String => KDE::Action}] the actions to insert in the menu
233
242
 
234
- <b>Note:</b> this is private
243
+ Each action is inserted using its @object_name@ as key. By default, the hash
244
+ contains the 'copy', 'copy_selected' and 'clear' actions.
235
245
  =end
236
246
  attr_reader :actions
237
247
 
238
248
  =begin rdoc
239
- The model used by the OutputWidget
249
+ @return [Qt::AbstractItemModel] the model used by the {OutputWidget}
240
250
  =end
241
251
  attr_reader :model
242
252
 
243
253
  =begin rdoc
244
- The view used by the OutputWidget
254
+ @return [Qt::AbstractItemView] the view used by the OutputWidget
245
255
  =end
246
256
  attr_reader :view
247
257
 
248
-
249
258
  private :action_list, :actions
250
259
 
251
260
  =begin rdoc
252
- Creates a new OutputWidget. _parent_ is the parent widget. _opts_ can contain
253
- the following keys:
254
- +:view+:: the view to use. It can be either a widget derived from <tt>Qt::AbstractItemView</tt>,
255
- which will be used as view, or one of the symbols +:list+, +:tree+ or
256
- +:table+. If it's a symbol, then the view will be a new instance of
257
- OutputWidget::ListView, OutputWidget::TreeView or OutputWidget::TableView
258
- respectively. Defaults to +:list+.
259
- +:model+:: the model to use. If this option isn't given, then a new instance of
260
- OutputWidget::Model will be used
261
- <tt>use_default_font</tt>::
262
- whether or not to use the application\'s default font in the view. If *false*
263
- (the default), then the font chosen by the user for the general/output_font
264
- option will be used.
265
-
266
- <b>Note:</b> if a widget is specified as value of the +:view+ option, it will become
267
- a child of the new OutputWidget.
261
+ @param [Qt::Widget,nil] the parent widget
262
+ @param [Hash] opts fine-tune the new widget
263
+ @option opts [Qt::AbstractItemView, Symbol] :view (:list) the view to use for
264
+ the widget. If it is an instance of a subclass of @Qt::AbstractItemView@, it'll
265
+ be used as it is (and the new widget will become a child of the output widget).
266
+ If it is a symbol, it can be either @:list@, @:tree@ or @:table@. In this case,
267
+ a new instance respectively of {ListView}, {TreeView} or {TableView} will be
268
+ created
269
+ @option opts [Qt::AbstractItemModel,nil] :model (nil) the model the output widget
270
+ should use. If *nil*, a new instance of {Model} will be used
271
+ @option opts [Boolean] :use_default_font (false) whether or not the application's
272
+ default font should by used for the output widget. By default, the font used
273
+ is the one the user set in the @general/output_font@ option
268
274
  =end
269
275
  def initialize parent = nil, opts = {}
270
276
 
@@ -296,26 +302,29 @@ a child of the new OutputWidget.
296
302
  end
297
303
 
298
304
  =begin rdoc
299
- Instructs the OutputWidget to use the <tt>Qt::Color</tt> _color_ to display items
300
- whose output type is _name_. _name_ should be a symbol.
305
+ Associates a color with an output type
301
306
 
302
- If a color had already been set for _name_, it will be overwritten
307
+ If a color had already been associated with the given output type, it'll be overwritten.
308
+
309
+ This method is useful to define new output types.
310
+ @param [Symbol] name the name of the output type
311
+ @param [Qt::Color] color the color to associate with the given output type
312
+ @return [nil]
303
313
  =end
304
314
  def set_color_for name, color
305
315
  @colors[name] = color
316
+ nil
306
317
  end
307
318
 
308
319
  =begin rdoc
309
- Scrolls the view so that the item corresponding to the index _idx_ is visible.
310
-
311
- _idx_ can be:
312
- * a <tt>Qt::ModelIndex</tt>
313
- * a positive integer. In this case, the view will be scrolled so that the first
314
- item toplevel item in the row _idx_ is visible.
315
- * a negative integer. It works as for a positive integer except that the rows are
316
- counted from the end (the same as passing a negative integer to <tt>Array#[]</tt>)
317
- * *nil*. In this case, the view will be scrolled so that the first toplevel item
318
- of the last row is visible.
320
+ Scrolls the view so that the item corresponding the given index is visible
321
+
322
+ @param [Qt::ModelIndex,Integer,nil] idx the item to make visible. If it's a
323
+ @Qt::ModelIndex@, it's the index to make visible. If it is a positive integer.
324
+ the view will be scrolled so that the first toplevel item in the row _idx_ is
325
+ visible; if it's a negative integer, the rows are counted from the end. If *nil*
326
+ the first toplevel item of the last row will become visible
327
+ @return [nil]
319
328
  =end
320
329
  def scroll_to idx
321
330
  case idx
@@ -334,19 +343,19 @@ of the last row is visible.
334
343
  @view.scroll_to @model.index(@model.row_count - 1, 0),
335
344
  Qt::AbstractItemView::PositionAtBottom
336
345
  end
346
+ nil
337
347
  end
338
348
 
339
349
  =begin rdoc
340
- Sets the output type associated with the <tt>Qt::ModelIndex</tt> _idx_ to _type_
341
- (a symbol).
350
+ Changes the output type of a given index
342
351
 
343
- If a color has been associated with _type_ (either because _type_ is one of the
344
- standard types or because it's been set with <tt>set_color_for</tt>), the foreground
345
- role of the index will be changed to that color and the +OutputTypeRole+ of the
346
- index will be set to a string version of _type_. In this case, _type_ is returned.
352
+ If a color has been associated with that output type, the foreground role and the
353
+ output type role of that index are updated accordingly.
347
354
 
348
- If no color has been associated with _type_, this method does nothing and returns
349
- *nil*.
355
+ If no color has been associated with the output type, nothing is done
356
+ @param [Qt::ModelIndex] idx the index to set the output type for
357
+ @param [Symbol] type the new output type to associate with the index
358
+ @return [Symbol,nil] _type_ if a color was associated with it and *nil* otherwise
350
359
  =end
351
360
  def set_output_type idx, type
352
361
  color = @colors[type]
@@ -358,8 +367,13 @@ If no color has been associated with _type_, this method does nothing and return
358
367
  end
359
368
 
360
369
  =begin rdoc
361
- Executes the block with autoscrolling turned on or off according to _val_, without
362
- permanently changing the autoscrolling setting.
370
+ Executes a block while temporarily turning autoscrolling on or off
371
+
372
+ After the block has been executed, autoscrolling returns to the original state.
373
+
374
+ @param [Boolean] val whether to turn autoscrolling on or off
375
+ @yield the block to execute with autoscroll turned on or off
376
+ @return [Object] the value returned by the block
363
377
  =end
364
378
  def with_auto_scrolling val
365
379
  old = @auto_scroll
@@ -372,19 +386,21 @@ permanently changing the autoscrolling setting.
372
386
  =begin rdoc
373
387
  Gives a title to the widget.
374
388
 
375
- A title is a toplevel entry at position 0,0 with output type +:message+ and has
376
- the +IsTitleRole+ set to *true*. Of course, there can be only one item which is
389
+ A title is a toplevel entry at position 0, 0 with output type @:message@ and has
390
+ the @IsTitleRole@ set to *true*. Of course, there can be only one item which is
377
391
  a title.
378
392
 
379
- If the item in position 0,0 is not a title, a new row is inserted at position 0,
380
- its first element's DisplayRole is set to _text_ and its IsTitleRole is set to
381
- true.
393
+ If the item in position 0, 0 is not a title, a new row with title role and the
394
+ given text is inserted.
382
395
 
383
- If the item in position 0,0 is a title, then its DisplayRole value is replaced
384
- with _text_.
396
+ If the item in position 0,0 is a title, then its display role is replaced with
397
+ the given text.
385
398
 
386
399
  Usually, the title is created when the external program is started and changed
387
- later if needed
400
+ later if needed.
401
+
402
+ @param [String] text the text of title
403
+ @return [nil]
388
404
  =end
389
405
  def title= text
390
406
  idx = @model.index 0, 0
@@ -398,11 +414,14 @@ later if needed
398
414
  @model.set_data idx, Qt::Variant.new(true), IsTitleRole
399
415
  end
400
416
  set_output_type idx, :message
417
+ nil
401
418
  end
402
419
 
403
420
  =begin rdoc
404
- Tells whether the toplevel 0,0 element is the title or not. See <tt>title=</tt>
405
- for the meaning of the title
421
+ Whether or not the output widget has a title
422
+
423
+ See {#title=} for what is meant here by title
424
+ @return [Boolean] whether or not the output widget has a title
406
425
  =end
407
426
  def has_title?
408
427
  @model.index(0,0).data(IsTitleRole).to_bool
@@ -410,6 +429,8 @@ for the meaning of the title
410
429
 
411
430
  =begin rdoc
412
431
  Loads the settings from the configuration file.
432
+
433
+ @return [nil]
413
434
  =end
414
435
  def load_settings
415
436
  cfg = Ruber[:config]
@@ -427,34 +448,30 @@ Loads the settings from the configuration file.
427
448
  rescue NoMethodError
428
449
  end
429
450
  end
451
+ nil
430
452
  end
431
453
 
432
454
  =begin rdoc
433
455
  Removes all the entries from the model
456
+
457
+ @return [nil]
434
458
  =end
435
459
  def clear_output
436
460
  @model.remove_rows 0, @model.row_count
461
+ nil
437
462
  end
438
-
439
- protected
440
-
441
- # def keyReleaseEvent e
442
- # ed = Ruber[:main_window].active_editor
443
- # return super unless ed
444
- # Ruber[:main_window].activate_editor ed
445
- # ed.set_focus
446
- # # mod = e.modifiers
447
- # # if mod == Qt::NoModifier or mod == Qt::ShiftModifier
448
- # # ed.insert_text e.text
449
- # # end
450
- # nil
451
- # end
452
463
 
464
+ def pinned_down?
465
+ @pin_button.checked?
466
+ end
467
+
453
468
  private
454
469
 
455
470
  =begin rdoc
456
- Changes the foreground color of the Qt::ModelIndex _idx_ and of its children so
457
- that it matches the color set for its output type.
471
+ Updates the color of an index and its children so that it matches their output types
472
+ @param [Qt::ModelIndex] idx the index whose foreground color should be updated.
473
+ Its children will also be updated
474
+ @return [nil]
458
475
  =end
459
476
  def update_index_color idx
460
477
  type = idx.data(OutputTypeRole).to_string.to_sym rescue nil
@@ -469,10 +486,17 @@ that it matches the color set for its output type.
469
486
  end
470
487
  end
471
488
  end
489
+ nil
472
490
  end
473
491
 
474
492
  =begin rdoc
475
- Creates the model (if needed) and makes some signal-slot connections
493
+ Prepares the model to use
494
+
495
+ After a call to this method, the model will become a child of the {OutputWidget}
496
+
497
+ @param [Qt::AbstractItemModel,nil] mod the model to use. If *nil*, a new instance
498
+ of {Model} will be used
499
+ @return [nil]
476
500
  =end
477
501
  def setup_model mod
478
502
  @model = mod || Model.new(self)
@@ -482,26 +506,48 @@ Creates the model (if needed) and makes some signal-slot connections
482
506
  connect @model, SIGNAL('rowsInserted(QModelIndex, int, int)'), self, SLOT(:rows_changed)
483
507
  connect @model, SIGNAL('rowsRemoved(QModelIndex, int, int)'), self, SLOT(:rows_changed)
484
508
  connect @model, SIGNAL('rowsInserted(QModelIndex, int, int)'), self, SLOT('do_auto_scroll(QModelIndex, int, int)')
509
+ nil
485
510
  end
486
511
 
487
512
  =begin rdoc
488
- Automatically scrolls to the first row of <i>end_idx</i> if auto scrolling is enabled.
489
-
490
- Note: all parameters are considered relative to the model associated with the view,
491
- not with the @model@ attribute (of course, this only matters in subclasses where
492
- the two differ, such as {FilteredOutputWidget}).
513
+ Slot called whenever rows are inserted in the model
514
+
515
+ If autoscrolling is enabled, it scrolls so that the last row inserted is at the
516
+ bottom of the widget. It does nothing if autoscrolling is disabled.
517
+
518
+ If the scrollbar slider is not at the bottom of the scroll bar, autoscrolling
519
+ isn't done, regardless of the option. This is because it's likely that the user
520
+ moved the slider, which may mean he's looking at some particular lines of output
521
+ and he wouldn't like them to scroll away.
522
+
523
+ @param [Qt::ModelIndex] parent the parent index of the inserted rows
524
+ @param [Qt::ModelIndex] start_idx the index corresponding to the first inserted
525
+ row (unused)
526
+ @param [Qt::ModelIndex] end_idx the index correspodnding to the last inserted row
527
+
528
+ @note all indexes are considered relative to the model associated with the view,
529
+ not to the model returned by {#model}. This doesn' matter for {OutputWidget} itself,
530
+ but makes a difference in sublclasses where the two models are different (for
531
+ example, {FilteredOutputWidget})
532
+ @return [nil]
493
533
  =end
494
534
  def do_auto_scroll parent, start_idx, end_idx
495
- scroll_to @view.model.index(end_idx, 0, parent) if @auto_scroll
535
+ if @auto_scroll
536
+ scroll_bar = @view.vertical_scroll_bar
537
+ scroll_to @view.model.index(end_idx, 0, parent) if scroll_bar.value == scroll_bar.maximum
538
+ end
539
+ nil
496
540
  end
497
541
 
498
542
  =begin rdoc
499
- Creates the menu, according to the contents of the <tt>@action_list</tt> and
500
- <tt>@actions</tt> instance variables.
543
+ Creates the context menu
501
544
 
502
- Before creating the menu, it emits the <tt>about_to_fill_menu()</tt> signal. Connecting
545
+ The menu is created using the values returned by {#action_list} and {#actions}.
546
+
547
+ Before creating the menu, the {#about_to_fill_menu} signal is emitted. Connecting
503
548
  to this signal allows to do some last-minute changes to the actions which will
504
549
  be inserted in the menu.
550
+ @return [nil]
505
551
  =end
506
552
  def fill_menu
507
553
  emit about_to_fill_menu
@@ -513,18 +559,28 @@ be inserted in the menu.
513
559
  end
514
560
 
515
561
  =begin rdoc
516
- Shows the menu (asynchronously) at the point _pt_.
562
+ Shows the menu
517
563
 
518
564
  If the menu hasn't as yet been created, it creates it.
565
+
566
+ The menu is shown asynchronously. This means that this method doesn't wait for
567
+ the user to choose an action but returns immediately.
568
+
569
+ @param [Qt::Point] the point where the menu should be shown
570
+ @return [ni;]
519
571
  =end
520
572
  def show_menu pt
521
573
  fill_menu if @menu.empty?
522
574
  @menu.popup pt
575
+ nil
523
576
  end
524
577
 
525
578
  =begin rdoc
526
- Creates the layout and the view. _view_ has the same meaning as the <tt>:view</tt>
527
- option in the constructor
579
+ Creates the layout and the view
580
+
581
+ @param [AbstractItemView,Symbol] view the view to use. Has the same meaning as the
582
+ @:view@ option to {#initialize}
583
+ @return [nil]
528
584
  =end
529
585
  def create_widgets view
530
586
  self.layout = Qt::GridLayout.new(self)
@@ -534,12 +590,21 @@ option in the constructor
534
590
  else @view = self.class.const_get(view.to_s.capitalize + 'View').new self
535
591
  end
536
592
  @view.selection_mode = Qt::AbstractItemView::ExtendedSelection
537
- layout.add_widget @view, 0, 0
593
+ @pin_button = Qt::ToolButton.new self
594
+ @pin_button.tool_tip = i18n("Don't hide the tool widget when clicking on a file name")
595
+ @pin_button.auto_raise = true
596
+ @pin_button.icon = Qt::Icon.new KDE::Global.dirs.find_resource('icon', 'pin.png')
597
+ @pin_button.checkable = true
598
+ layout.add_widget @view, 1, 0
599
+ layout.add_widget @pin_button, 0, 0, 1, -1, Qt::AlignRight | Qt::AlignVCenter
600
+ nil
538
601
  end
539
602
 
540
603
  =begin rdoc
541
- Creates the 'Copy', 'Copy selected' and 'Clear' actions and the correspongind
542
- state handlers
604
+ Creates the default actions for the context menu
605
+
606
+ It also sets up the gui state handlers for them
607
+ @return [nil]
543
608
  =end
544
609
  def create_standard_actions
545
610
  @actions['copy'] = KDE::Action.new(self){|a| a.text = '&Copy'}
@@ -553,13 +618,15 @@ state handlers
553
618
  connect @actions['copy'], SIGNAL(:triggered), self, SLOT(:copy)
554
619
  connect @actions['copy_selected'], SIGNAL(:triggered), self, SLOT(:copy_selected)
555
620
  connect @actions['clear'], SIGNAL(:triggered), self, SLOT(:clear_output)
621
+ nil
556
622
  end
557
623
 
558
624
  =begin rdoc
559
625
  Slot connected to the 'Copy' action.
560
626
 
561
627
  It copies the content of all the items to the clipboard. The text is obtained
562
- from the items by calling <tt>text_for_clipboard</tt> passing it all the items.
628
+ from the items by calling {#text_for_clipboard}.
629
+ @return [nil]
563
630
  =end
564
631
  def copy
565
632
  items = []
@@ -576,13 +643,15 @@ from the items by calling <tt>text_for_clipboard</tt> passing it all the items.
576
643
  end
577
644
  clp = KDE::Application.clipboard
578
645
  clp.text = text_for_clipboard items
646
+ nil
579
647
  end
580
648
 
581
649
  =begin rdoc
582
650
  Slot connected to the 'Copy Selection' action.
583
651
 
584
652
  It copies the content of all the items to the clipboard. The text is obtained
585
- from the items by calling <tt>text_for_clipboard</tt> passing it the selected items.
653
+ from the items by calling {#text_for_clipboard}.
654
+ @return [nil]
586
655
  =end
587
656
  def copy_selected
588
657
  clp = KDE::Application.clipboard
@@ -590,20 +659,22 @@ from the items by calling <tt>text_for_clipboard</tt> passing it the selected it
590
659
  end
591
660
 
592
661
  =begin rdoc
593
- Method used by the +copy+ and <tt>copy_selected</tt> methods to obtain the text
594
- to put in the clipboard from the indexes.
662
+ Retrieves the text to copy to the clipboard from the given indexes
595
663
 
596
- The default behaviour is to create a string which contains the content of all the
597
- toplevel items on the same row separated by tabs and separate different rows by
664
+ The string is created by joining the text of toplevel items on the same row and
665
+ different columns using tabs as separators. Different rows are separated with
598
666
  newlines. Child items are ignored.
599
667
 
600
668
  Derived class can override this method (and, if they plan to put child items in
601
- the view, they're advised to do so). The method must accept an array of <tt>Qt::ModelIndex</tt>
602
- as argument and return a string with the text to put in the clipboard.
669
+ the view, they're advised to do so).
603
670
 
604
671
  The reason the default behaviour ignores child items is that their meaning (and
605
672
  therefore the way their contents should be inserted into the string) depends
606
- very much on the specific content.
673
+ very much on the specific content, so there's no way to have a sensible default
674
+ behaviour.
675
+
676
+ @param [Array<Qt::ModelIndex>] indexes the indexes to use to create the text
677
+ @return [String] the text which should be put in the clipboard
607
678
  =end
608
679
  def text_for_clipboard indexes
609
680
  indexes = indexes.select{|i| !i.parent.valid?}
@@ -622,96 +693,128 @@ very much on the specific content.
622
693
  end
623
694
 
624
695
  =begin rdoc
625
- Slot connected to the view's selection model's selectionChanged signal.
696
+ Slot connected to the view's selection model's @selectionChanged@ signal
626
697
 
627
- Turns the <tt>no_selection</tt> state on or off depending on whether the selection
628
- is empty or not
698
+ Turns the @no_selection@ gui state on or off according to whether the selection
699
+ is empty or not.
700
+
701
+ @return [nil]
629
702
  =end
630
703
  def selection_changed sel, desel
631
704
  change_state 'no_selection', !@view.selection_model.has_selection
705
+ nil
632
706
  end
633
707
 
634
708
  =begin rdoc
635
- Turns the <tt>no_text</tt> state on or off depending on whether the model
709
+ Slot called whenever rows are added to or removed from the model
710
+
711
+ Turns the @no_text@ gui state on or off depending on whether the model
636
712
  is empty or not
713
+ @return [nil]
637
714
  =end
638
715
  def rows_changed
639
716
  change_state 'no_text', @model.row_count == 0
717
+ nil
640
718
  end
641
719
 
642
720
  =begin rdoc
643
- Searches for a filename in the DisplayRole of the <tt>Qt::ModelIndex</tt> idx (
644
- using the <tt>find_filename_in_index</tt> method). If a filename is found, opens
645
- a new editor view containing the file, scrolls it to the appropriate line and
646
- hides the tool widget (*self*).
721
+ Attempts to display the file whose name is contained in the given index
722
+
723
+ Searches for a filename in the DisplayRole of the index using the {#find_filename_in_index}
724
+ method. If a filename is found, an editor for it is displayed.
647
725
 
648
726
  The behaviour of this method (which usually is only called via a signal-slot connection
649
- to the views' <tt>activated(QModelindex) signal) changes according to the active
650
- keyboard modifiers:
727
+ to the views' @activated(QModelindex)@ signal) changes according to the active
728
+ keyboard modifiers and to whether the Pinned tool button is on or off:
651
729
  * if Ctrl or Shift are pressed and the view allows selection (that is, its selection
652
730
  mode is not +NoSelection+), then this method does nothing. The reason for this
653
731
  behaviour is that Ctrl and Shift are used to select items, so the user is most
654
732
  likely doing that, not requesting to open a file
655
- * if Meta is pressed, then the tool widget won't be closed
733
+ * if the Pinned button is pressed, then the tool widget won't be closed (but the
734
+ focus will be moved to the editor)
735
+ * if Meta is pressed, then the file will be opened in a new editor, regardless
736
+ of whether an editor for that file already exists
737
+
738
+ If a new editor should be created (either because the Meta key is pressed or because
739
+ no editor exists for the given file), the hints returned by {#hints} are used.
740
+ Unless the {#hints} method has been overloaded, this means that the @general/tool_open_files@
741
+ option is used.
742
+ @param [Qt::ModelIndex] idx the index which could contain the file name
743
+ @return [EditorView,nil] the editor for the filename contained in the index or
744
+ *nil* if no file name was found or if either the Shift or Control modifiers were
745
+ active
746
+ @see #find_filename_in_index
747
+ @see #hints
656
748
  =end
657
749
  def maybe_open_file idx
658
750
  modifiers = Application.keyboard_modifiers
659
751
  if @view.selection_mode != Qt::AbstractItemView::NoSelection
660
752
  return if Qt::ControlModifier & modifiers != 0 or Qt::ShiftModifier & modifiers != 0
661
753
  end
662
- file = find_filename_in_index idx
754
+ file, line = find_filename_in_index idx
663
755
  return unless file
664
- line = file[1]
665
- line -= 1 if line > 0
666
- Ruber[:main_window].display_document file[0], line, 0
667
- Ruber[:main_window].hide_tool self if (Qt::MetaModifier & modifiers) == 0
756
+ line -= 1 unless line == 0
757
+ existing = (Qt::MetaModifier & modifiers) == 0 ? :always : :never
758
+ display_hints = hints.merge(:line => line, :existing => existing)
759
+ ed = Ruber[:main_window].display_document file, display_hints
760
+ Ruber[:main_window].hide_tool self unless pinned_down?
761
+ ed
668
762
  end
669
763
 
670
764
  =begin rdoc
671
- Method used by <tt>maybe_open_file</tt> to find out the name of the file to open
672
- (if any) when an item is activated.
765
+ The hints to pass to {MainWindow#display_document}
673
766
 
674
- _idx_ can be either the <tt>Qt::ModelIndex</tt> corresponding to the activated
675
- item or a string. The first form is used when this method is called from the
676
- <tt>activated(QModelIndex)</tt> signal of the view; the string form is usually
677
- called by overriding methods using *super*.
678
-
679
- The actual work is done by <tt>find_filename_in_string</tt>, which returns the
680
- first occurrence of what it considers a filename (possibly followed by a line
681
- number).
682
-
683
- If <tt>find_filename_in_string</tt> finds a filename, this method makes sure it
684
- actually corresponds to an existing file and, if it's a relative path, expands
685
- it, considering it relative to the <tt>working_dir</tt> attribute. If that
686
- attribute is not set, the behaviour is undefined (most likely, an exception will
687
- be raised).
767
+ This method determines the hints to use according to the @general/tool_open_files@
768
+ option. Derived classes may override this method to provide different hints. The
769
+ values which can be used are the ones described for {MainWindow#editor_for!}. Note,
770
+ however, that the @:existing@ entry won't be used.
771
+ @return [Hash] see the description for the _hints_ argument of {MainWindow#editor_for!}
772
+ =end
773
+ def hints
774
+ case Ruber[:config][:general, :tool_open_files]
775
+ when :split_horizontally then {:new => :current_tab, :split => :horizontal}
776
+ when :split_vertically then {:new => :current_tab, :split => :vertical}
777
+ else {:new => :new_tab}
778
+ end
779
+ end
780
+
781
+ =begin rdoc
782
+ Searches in the display role of the given index for a file name
688
783
 
689
- If _idx_ is the title (see <tt>title=</tt>) and <tt>skip_first_file_in_title</tt>
690
- is *true*, all the text from the beginning to the first space or colon is removed
691
- from it before being passed to <tt>find_filename_in_string</tt>. The reason is
692
- that often the title contains the command line of a program, for example:
784
+ This method is used by {#maybe_open_file} to find out the name of the file to open
785
+ (if any) when an item is activated.
693
786
 
694
- /usr/bin/ruby /path/to/script.rb
787
+ The actual search for the file name is done by {#find_filename_in_string}. If it
788
+ reports a success, this method makes sure the file actually exists, expanding it
789
+ relative to {#working_dir} if it's not an absolute path. If {#working_dir} is
790
+ not set, the current directory will be used. However, you're advised not to relay
791
+ on this behaviour and always set the working directory.
695
792
 
696
- In this case, when the user activates the title, he will most likely want to
697
- open <tt>/path/to/script.rb</tt> rather than <tt>/usr/bin/ruby</tt> (which, being
698
- an executable, couldn't even be correctly displayed). Nothing like this will
699
- ever happen if _idx_ is a string.
793
+ If the given index is the title of the widget (see {#title=}) and {#skip_first_file_in_title}
794
+ is *true*, all the text from the beginning of the title up to the first whitespace
795
+ or colon is ignored. Since often the first word of the title is the name of the
796
+ program being run (which may as well be compiled), it doesn't make sense to attempt
797
+ to open it. This behaviour allows the user to activate on a title like
798
+ @/usr/bin/ruby /path/to/script.rb@ and see the file @/path/to/script.rb@ in the
799
+ editor. Without it, @/usr/bin/ruby@ would be opened instead.
700
800
 
701
801
  Subclasses can override this method to extend or change its functionality. They
702
802
  have two choices on how to do this. The simplest is useful if they want to alter
703
803
  the string. In this case they can retrieve the text from the index, change it
704
- then call *super* passing the modified string as argument. Otherwise, they should
705
- reimplement all the functionality. In this case, the method should:
706
- * take a <tt>Qt::ModelIndex</tt> or a string as argument
707
- * return a string with the name of the file or an array containing a string and
708
- the associated line number (if found) if a file name is found
709
- * return *nil* if no file name is found
710
- * convert relative file names to absolute (either using the <tt>working_dir</tt>
711
- attribute or any other way they see fit)
712
-
713
- A subclass can decide to completely disable this functionality by overriding this
714
- method with one which always returns *nil*.
804
+ then call *super* passing the modified string as argument. The other way is to
805
+ reimplement this method from scratch.
806
+
807
+ A subclass can also decide to completely disallow opening a file by activating the
808
+ corresponding item by overriding this method to always return *nil*.
809
+
810
+ @param [Qt::ModelIndex,String] idx the index or string to search a file name in.
811
+ The form which takes a string is usually used by subclasses which want to alter
812
+ the string without reimplementing all the functionality. Note that if _idx_
813
+ is a string, there's no way to know whether it refers to the title or not, so
814
+ {#skip_first_file_in_title} is ignored
815
+ @return [Array(String,Integer),nil] if a file name is found (and the corresponding
816
+ file exists) an array containing the filename and the line number (or 0 if no
817
+ line number was found). If no suitable file is found, *nil* is returned
715
818
  =end
716
819
  def find_filename_in_index idx
717
820
  str = if idx.is_a?(String) then idx
@@ -720,7 +823,6 @@ method with one which always returns *nil*.
720
823
  else idx.data.to_string
721
824
  end
722
825
  res = find_filename_in_string str
723
- d res
724
826
  return unless res
725
827
  res = Array res
726
828
  res << 0 if res.size == 1
@@ -729,7 +831,7 @@ method with one which always returns *nil*.
729
831
  res[0].sub! %r{^file://}, ''
730
832
  if KDE::Url.file_url?(res[0]) then res
731
833
  else
732
- res[0] = File.join @working_dir, res[0] unless Pathname.new(res[0]).absolute?
834
+ res[0] = File.join (@working_dir || Dir.pwd), res[0] unless Pathname.new(res[0]).absolute?
733
835
  if File.exist?(res[0]) and !File.directory?(res[0])
734
836
  res
735
837
  else nil
@@ -738,24 +840,25 @@ method with one which always returns *nil*.
738
840
  end
739
841
 
740
842
  =begin rdoc
741
- Searches the given string for the first occurrence of a file name (possibly followed by a colon and a line
742
- number). If a file name is found, returns an array containing the file name and
743
- the corresponding line number (if present). Returns *nil* if no file name was found.
843
+ Searches the given string for the first occurrence of a file name
744
844
 
845
+ The file name can optionally be followed by a colon and a line number.
846
+
745
847
  What is a file name and what isn't is a bit arbitrary. Here's what this method
746
848
  recognizes as a filename:
747
849
  * an absolute path not containing spaces and colons starting with '/'
748
850
  * an absolute path not containing spaces and colons starting with '~' or '~user'
749
- (they're expanded using @File.expand_path@)
851
+ (they're expanded using @File.expand_path@)
750
852
  * a relative path starting with @./@ or @../@ (either followed by a slash or not)
751
853
  * a relative path of the form @.filename@ or @.dirname/dir/file@
752
- * any string not containing spaces or colons followed by a colon and a line number
753
854
  * absolute URLs with an authority component
855
+ * any string not containing spaces or colons followed by a colon and a line number
856
+ (in this case, the line number is required)
754
857
 
755
858
  File names enclosed in quotes or parentheses are recognized.
756
-
757
- The first three entries of the previous list can be followed by a colon and a line
758
- number; for the last one they're mandatory
859
+ @return [Array(String,Integer), Array(String),nil] an array whose first element
860
+ is the file name and whose second element is the line number (if found) or
861
+ *nil* if no file name was found. Note that the file name can be relative
759
862
  =end
760
863
  def find_filename_in_string str
761
864
  #This ensures that file names inside quotes or brackets are found. It's
@@ -781,8 +884,6 @@ number; for the last one they're mandatory
781
884
  m = str.match a
782
885
  matches << [m.begin(0),[$1,$2]] if m
783
886
  end
784
- d str
785
- d matches
786
887
  match = matches.sort_by{|i| i[0]}[0]
787
888
  return unless match
788
889
  file, line = *match[1]
@@ -967,18 +1068,23 @@ same type is used for all lines.
967
1068
  end
968
1069
 
969
1070
  =begin rdoc
970
- Convenience class to be used instead of <tt>Qt::ListView</tt> in an OutputWidget.
1071
+ Convenience class to be used instead of @Qt::ListView@ in an {OutputWidget}.
971
1072
 
972
- The only difference from Qt::ListVew is that it defines a <tt>context_menu_requested(QPoint)</tt>
973
- signal and emits it from its +contextMenuEvent+ method
1073
+ The only difference from @Qt::ListVew@ is that it defines a @context_menu_requested(QPoint)@
1074
+ signal and emits it from its {#contextMenuEvent} method
974
1075
  =end
975
1076
  class ListView < Qt::ListView
976
1077
 
1078
+ =begin rdoc
1079
+ Signal emitted when the user right-clicks on the view
1080
+ @param [Qt::Point] pt the point where the user clicked
1081
+ =end
977
1082
  signals 'context_menu_requested(QPoint)'
978
1083
 
979
1084
  =begin rdoc
980
- Works as in the superclass but also emits the <tt>context_menu_requested(QPoint)</tt>
981
- signal
1085
+ Override of @Qt::ListView#contextMenuEvent@
1086
+
1087
+ It emits the {#context_menu_requested} signal
982
1088
  =end
983
1089
  def contextMenuEvent e
984
1090
  super e
@@ -988,18 +1094,23 @@ signal
988
1094
  end
989
1095
 
990
1096
  =begin rdoc
991
- Convenience class to be used instead of <tt>Qt::TreeView</tt> in an OutputWidget.
1097
+ Convenience class to be used instead of @Qt::TreeView@ in an {OutputWidget}.
992
1098
 
993
- The only difference from Qt::TreeVew is that it defines a <tt>context_menu_requested(QPoint)</tt>
994
- signal and emits it from its +contextMenuEvent+ method
1099
+ The only difference from @Qt::TreeVew@ is that it defines a {#context_menu_requested}
1100
+ signal and emits it from its {#contextMenuEvent} method
995
1101
  =end
996
1102
  class TreeView < Qt::TreeView
997
-
1103
+
1104
+ =begin rdoc
1105
+ Signal emitted when the user right-clicks on the view
1106
+ @param [Qt::Point] pt the point where the user clicked
1107
+ =end
998
1108
  signals 'context_menu_requested(QPoint)'
999
1109
 
1000
1110
  =begin rdoc
1001
- Works as in the superclass but also emits the <tt>context_menu_requested(QPoint)</tt>
1002
- signal
1111
+ Override of @Qt::TreeView#contextMenuEvent@
1112
+
1113
+ It emits the {#context_menu_requested} signal
1003
1114
  =end
1004
1115
  def contextMenuEvent e
1005
1116
  super e
@@ -1009,18 +1120,23 @@ signal
1009
1120
  end
1010
1121
 
1011
1122
  =begin rdoc
1012
- Convenience class to be used instead of <tt>Qt::TableView</tt> in an OutputWidget.
1123
+ Convenience class to be used instead of @Qt::TableView@ in an {OutputWidget}.
1013
1124
 
1014
- The only difference from Qt::TableVew is that it defines a <tt>context_menu_requested(QPoint)</tt>
1015
- signal and emits it from its +contextMenuEvent+ method
1125
+ The only difference from @Qt::TableVew@ is that it defines a {#context_menu_requested}
1126
+ signal and emits it from its {#contextMenuEvent} method
1016
1127
  =end
1017
1128
  class TableView < Qt::TableView
1018
-
1129
+
1130
+ =begin rdoc
1131
+ Signal emitted when the user right-clicks on the view
1132
+ @param [Qt::Point] pt the point where the user clicked
1133
+ =end
1019
1134
  signals 'context_menu_requested(QPoint)'
1020
1135
 
1021
1136
  =begin rdoc
1022
- Works as in the superclass but also emits the <tt>context_menu_requested(QPoint)</tt>
1023
- signal
1137
+ Override of @Qt::TableView#contextMenuEvent@
1138
+
1139
+ It emits the {#context_menu_requested} signal
1024
1140
  =end
1025
1141
  def contextMenuEvent e
1026
1142
  super e
@@ -1036,30 +1152,32 @@ signal
1036
1152
  class ActionList < Array
1037
1153
 
1038
1154
  =begin rdoc
1039
- :call-seq: list.insert_before entry, name1 [, name2, ...]
1040
-
1041
- Adds one or more actions before a given one
1042
- =====Arguments
1043
- _entry_:: the name of the action before which to insert the new ones. If this
1044
- an integer _n_, then the actions will be added before the _n_th
1045
- separator. If the entry doesn't exist, or the number of separators is
1046
- less than _n_, the new entries will be added at the end of the list
1047
- _namei_:: the names of the actions to add (or +nil+ for separators)
1155
+ Inserts one or more actions before a given one
1156
+
1157
+ @param [String,Integer] entry the entry before which the new action(s) should
1158
+ be inserted. If it's a string, the actions will be inserted before the action
1159
+ with that name. If it's an integer, the new actions will be inserted before
1160
+ the action at position _entry_. If the given entry doesn't exist (or it's a number
1161
+ larger than the size of the array), the new actions will be appended at the end
1162
+ @param [Array<String,nil>] names the names of the actions to insert. *nil* entries
1163
+ represent separator
1164
+ @return [self]
1048
1165
  =end
1049
1166
  def insert_before entry, *names
1050
1167
  insert_after_or_before entry, :before, names
1051
1168
  end
1052
1169
 
1053
1170
  =begin rdoc
1054
- :call-seq: list.insert_after entry, name1 [, name2, ...]
1055
-
1056
- Adds one or more actions after a given one
1057
- =====Arguments
1058
- _entry_:: the name of the action after which to insert the new ones. If this
1059
- an integer _n_, then the actions will be added after the _n_th
1060
- separator. If the entry doesn't exist, or the number of separators is
1061
- less than _n_, the new entries will be added at the end of the list
1062
- _namei_:: the names of the actions to add (or +nil+ for separators)
1171
+ Inserts one or more actions after a given one
1172
+
1173
+ @param [String,Integer] entry the entry after which the new action(s) should
1174
+ be inserted. If it's a string, the actions will be inserted after the action
1175
+ with that name. If it's an integer, the new actions will be inserted after
1176
+ the action at position _entry_. If the given entry doesn't exist (or it's a number
1177
+ larger than the size of the array), the new actions will be appended at the end
1178
+ @param [Array<String,nil>] names the names of the actions to insert. *nil* entries
1179
+ represent separator
1180
+ @return [self]
1063
1181
  =end
1064
1182
  def insert_after entry, *names
1065
1183
  insert_after_or_before entry, :after, names
@@ -1068,13 +1186,15 @@ signal
1068
1186
  private
1069
1187
 
1070
1188
  =begin rdoc
1071
- Helper method used by <tt>insert_after</tt> and <tt>insert_before</tt> which performs
1072
- the actual insertion of the elements.
1189
+ Helper method used by {#insert_after} and {#insert_before}
1190
+
1191
+ This is the method which performs the actual insertion of elements
1073
1192
 
1074
- _entry_ has the same meaning as in <tt>insert_after</tt> and <i>insert_before</tt>,
1075
- while _names_ has the same meaning as the optional arguments of those methods.
1076
- _where_ can be +:after+ or +:before+ and tells whether the new elements should be
1077
- inserted after or before the position.
1193
+ @param entry (see #insert_after)
1194
+ @param [Symbol] where whether the new actions should be inserted before or after
1195
+ _entry_. It can be either @:before@ or @:after@
1196
+ @param names (see #insert_after)
1197
+ @return [self]
1078
1198
  =end
1079
1199
  def insert_after_or_before entry, where, names
1080
1200
  idx = if entry.is_a? Integer
@@ -1090,6 +1210,7 @@ inserted after or before the position.
1090
1210
  #first item should be at position idx, the second at idx+1 and so on. With reverse_each)
1091
1211
  #this happens automatically. The +1 is needed to insert the items after idx
1092
1212
  names.reverse_each{|n| insert idx, n}
1213
+ self
1093
1214
  end
1094
1215
 
1095
1216
  end