ruber 0.0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. data/COPYING +339 -0
  2. data/INSTALL +137 -0
  3. data/LICENSE +8 -0
  4. data/bin/ruber +65 -0
  5. data/data/share/apps/ruber/core_components.yaml +31 -0
  6. data/data/share/apps/ruber/ruberui.rc +109 -0
  7. data/data/share/icons/ruber.png +0 -0
  8. data/data/share/pixmaps/ruby.png +0 -0
  9. data/icons/ruber-16.png +0 -0
  10. data/icons/ruber-32.png +0 -0
  11. data/icons/ruber-48.png +0 -0
  12. data/icons/ruber-8.png +0 -0
  13. data/lib/ruber/application/application.rb +288 -0
  14. data/lib/ruber/application/plugin.yaml +11 -0
  15. data/lib/ruber/component_manager.rb +899 -0
  16. data/lib/ruber/config/config.rb +82 -0
  17. data/lib/ruber/config/plugin.yaml +3 -0
  18. data/lib/ruber/document_project.rb +209 -0
  19. data/lib/ruber/documents/document_list.rb +416 -0
  20. data/lib/ruber/documents/plugin.yaml +4 -0
  21. data/lib/ruber/editor/document.rb +506 -0
  22. data/lib/ruber/editor/editor_view.rb +167 -0
  23. data/lib/ruber/editor/ktexteditor_wrapper.rb +202 -0
  24. data/lib/ruber/exception_widgets.rb +245 -0
  25. data/lib/ruber/external_program_plugin.rb +397 -0
  26. data/lib/ruber/filtered_output_widget.rb +342 -0
  27. data/lib/ruber/gui_states_handler.rb +231 -0
  28. data/lib/ruber/kde_config_option_backend.rb +167 -0
  29. data/lib/ruber/kde_sugar.rb +249 -0
  30. data/lib/ruber/main_window/choose_plugins_dlg.rb +353 -0
  31. data/lib/ruber/main_window/main_window.rb +524 -0
  32. data/lib/ruber/main_window/main_window_actions.rb +537 -0
  33. data/lib/ruber/main_window/main_window_internal.rb +239 -0
  34. data/lib/ruber/main_window/open_file_in_project_dlg.rb +212 -0
  35. data/lib/ruber/main_window/output_color_widget.rb +35 -0
  36. data/lib/ruber/main_window/plugin.yaml +58 -0
  37. data/lib/ruber/main_window/save_modified_files_dlg.rb +89 -0
  38. data/lib/ruber/main_window/status_bar.rb +156 -0
  39. data/lib/ruber/main_window/ui/choose_plugins_widget.rb +90 -0
  40. data/lib/ruber/main_window/ui/choose_plugins_widget.ui +77 -0
  41. data/lib/ruber/main_window/ui/main_window_settings_widget.rb +108 -0
  42. data/lib/ruber/main_window/ui/main_window_settings_widget.ui +89 -0
  43. data/lib/ruber/main_window/ui/new_project_widget.rb +119 -0
  44. data/lib/ruber/main_window/ui/new_project_widget.ui +178 -0
  45. data/lib/ruber/main_window/ui/open_file_in_project_dlg.rb +109 -0
  46. data/lib/ruber/main_window/ui/open_file_in_project_dlg.ui +168 -0
  47. data/lib/ruber/main_window/ui/output_color_widget.rb +241 -0
  48. data/lib/ruber/main_window/ui/output_color_widget.ui +204 -0
  49. data/lib/ruber/main_window/workspace.rb +442 -0
  50. data/lib/ruber/output_widget.rb +1093 -0
  51. data/lib/ruber/plugin.rb +264 -0
  52. data/lib/ruber/plugin_like.rb +589 -0
  53. data/lib/ruber/plugin_specification.rb +106 -0
  54. data/lib/ruber/plugin_specification_reader.rb +451 -0
  55. data/lib/ruber/project.rb +493 -0
  56. data/lib/ruber/project_backend.rb +105 -0
  57. data/lib/ruber/projects/plugin.yaml +11 -0
  58. data/lib/ruber/projects/project_files_list.rb +314 -0
  59. data/lib/ruber/projects/project_files_widget.rb +301 -0
  60. data/lib/ruber/projects/project_list.rb +314 -0
  61. data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +74 -0
  62. data/lib/ruber/projects/ui/project_files_rule_chooser_widget.ui +61 -0
  63. data/lib/ruber/projects/ui/project_files_widget.rb +117 -0
  64. data/lib/ruber/projects/ui/project_files_widget.ui +123 -0
  65. data/lib/ruber/qt_sugar.rb +673 -0
  66. data/lib/ruber/settings_container.rb +515 -0
  67. data/lib/ruber/settings_dialog.rb +244 -0
  68. data/lib/ruber/settings_dialog_manager.rb +503 -0
  69. data/lib/ruber/utils.rb +414 -0
  70. data/lib/ruber/yaml_option_backend.rb +159 -0
  71. data/outsider_files +15 -0
  72. data/plugins/autosave/autosave.rb +404 -0
  73. data/plugins/autosave/plugin.yaml +16 -0
  74. data/plugins/autosave/ui/autosave_config_widget.rb +83 -0
  75. data/plugins/autosave/ui/autosave_config_widget.ui +68 -0
  76. data/plugins/command/command.png +0 -0
  77. data/plugins/command/command.rb +74 -0
  78. data/plugins/command/plugin.yaml +11 -0
  79. data/plugins/find_in_files/find_in_files.rb +337 -0
  80. data/plugins/find_in_files/find_in_files_dlg.rb +411 -0
  81. data/plugins/find_in_files/find_in_files_ui.rc +11 -0
  82. data/plugins/find_in_files/find_in_files_widgets.rb +485 -0
  83. data/plugins/find_in_files/plugin.yaml +23 -0
  84. data/plugins/find_in_files/ui/config_widget.rb +58 -0
  85. data/plugins/find_in_files/ui/config_widget.ui +41 -0
  86. data/plugins/find_in_files/ui/find_in_files_widget.rb +260 -0
  87. data/plugins/find_in_files/ui/find_in_files_widget.ui +324 -0
  88. data/plugins/project_browser/plugin.yaml +10 -0
  89. data/plugins/project_browser/project_browser.rb +245 -0
  90. data/plugins/rake/plugin.yaml +39 -0
  91. data/plugins/rake/rake.png +0 -0
  92. data/plugins/rake/rake.rb +567 -0
  93. data/plugins/rake/rake_extension.rb +153 -0
  94. data/plugins/rake/rake_widgets.rb +615 -0
  95. data/plugins/rake/rakeui.rc +27 -0
  96. data/plugins/rake/ui/add_quick_task_widget.rb +71 -0
  97. data/plugins/rake/ui/add_quick_task_widget.ui +59 -0
  98. data/plugins/rake/ui/choose_task_widget.rb +77 -0
  99. data/plugins/rake/ui/choose_task_widget.ui +72 -0
  100. data/plugins/rake/ui/config_widget.rb +127 -0
  101. data/plugins/rake/ui/config_widget.ui +123 -0
  102. data/plugins/rake/ui/project_widget.rb +217 -0
  103. data/plugins/rake/ui/project_widget.ui +246 -0
  104. data/plugins/rspec/plugin.yaml +30 -0
  105. data/plugins/rspec/rspec.png +0 -0
  106. data/plugins/rspec/rspec.rb +945 -0
  107. data/plugins/rspec/rspec.svg +90 -0
  108. data/plugins/rspec/rspecui.rc +20 -0
  109. data/plugins/rspec/ruber_rspec_formatter.rb +312 -0
  110. data/plugins/rspec/ui/rspec_project_widget.rb +170 -0
  111. data/plugins/rspec/ui/rspec_project_widget.ui +193 -0
  112. data/plugins/ruby_development/plugin.yaml +27 -0
  113. data/plugins/ruby_development/ruby_development.png +0 -0
  114. data/plugins/ruby_development/ruby_development.rb +453 -0
  115. data/plugins/ruby_development/ruby_developmentui.rc +19 -0
  116. data/plugins/ruby_development/ui/project_widget.rb +112 -0
  117. data/plugins/ruby_development/ui/project_widget.ui +108 -0
  118. data/plugins/ruby_runner/config_widget.rb +116 -0
  119. data/plugins/ruby_runner/plugin.yaml +26 -0
  120. data/plugins/ruby_runner/project_widget.rb +62 -0
  121. data/plugins/ruby_runner/ruby.png +0 -0
  122. data/plugins/ruby_runner/ruby_interpretersui.rc +26 -0
  123. data/plugins/ruby_runner/ruby_runner.rb +411 -0
  124. data/plugins/ruby_runner/ui/config_widget.rb +92 -0
  125. data/plugins/ruby_runner/ui/config_widget.ui +91 -0
  126. data/plugins/ruby_runner/ui/project_widget.rb +60 -0
  127. data/plugins/ruby_runner/ui/project_widget.ui +48 -0
  128. data/plugins/ruby_runner/ui/ruby_runnner_plugin_option_widget.rb +59 -0
  129. data/plugins/ruby_runner/ui/ruby_runnner_plugin_option_widget.ui +44 -0
  130. data/plugins/state/plugin.yaml +28 -0
  131. data/plugins/state/state.rb +520 -0
  132. data/plugins/state/ui/config_widget.rb +92 -0
  133. data/plugins/state/ui/config_widget.ui +89 -0
  134. data/plugins/syntax_checker/plugin.yaml +18 -0
  135. data/plugins/syntax_checker/syntax_checker.rb +662 -0
  136. data/ruber.desktop +10 -0
  137. data/spec/annotation_model_spec.rb +174 -0
  138. data/spec/common.rb +119 -0
  139. data/spec/component_manager_spec.rb +1259 -0
  140. data/spec/document_list_spec.rb +626 -0
  141. data/spec/document_project_spec.rb +373 -0
  142. data/spec/document_spec.rb +779 -0
  143. data/spec/editor_view_spec.rb +167 -0
  144. data/spec/external_program_plugin_spec.rb +676 -0
  145. data/spec/filtered_output_widget_spec.rb +642 -0
  146. data/spec/gui_states_handler_spec.rb +304 -0
  147. data/spec/kde_config_option_backend_spec.rb +214 -0
  148. data/spec/kde_sugar_spec.rb +101 -0
  149. data/spec/ktexteditor_wrapper_spec.rb +305 -0
  150. data/spec/output_widget_spec.rb +1703 -0
  151. data/spec/plugin_spec.rb +1393 -0
  152. data/spec/plugin_specification_reader_spec.rb +1765 -0
  153. data/spec/plugin_specification_spec.rb +401 -0
  154. data/spec/project_backend_spec.rb +172 -0
  155. data/spec/project_files_list_spec.rb +401 -0
  156. data/spec/project_list_spec.rb +511 -0
  157. data/spec/project_spec.rb +990 -0
  158. data/spec/qt_sugar_spec.rb +328 -0
  159. data/spec/settings_container_spec.rb +617 -0
  160. data/spec/settings_dialog_manager_spec.rb +773 -0
  161. data/spec/settings_dialog_spec.rb +419 -0
  162. data/spec/state_spec.rb +991 -0
  163. data/spec/utils_spec.rb +406 -0
  164. data/spec/workspace_spec.rb +869 -0
  165. data/spec/yaml_option_backend_spec.rb +246 -0
  166. metadata +284 -0
@@ -0,0 +1,117 @@
1
+ =begin
2
+ ** Form generated from reading ui file 'project_files_widget.ui'
3
+ **
4
+ ** Created: ven ott 29 17:39:04 2010
5
+ ** by: Qt User Interface Compiler version 4.7.0
6
+ **
7
+ ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
+ =end
9
+
10
+ class Ui_ProjectFilesWidget
11
+ attr_reader :verticalLayout
12
+ attr_reader :groupBox
13
+ attr_reader :gridLayout
14
+ attr_reader :label
15
+ attr_reader :extensions
16
+ attr_reader :label_2
17
+ attr_reader :include_rules
18
+ attr_reader :groupBox_2
19
+ attr_reader :gridLayout_2
20
+ attr_reader :label_3
21
+ attr_reader :exclude_rules
22
+
23
+ def setupUi(projectFilesWidget)
24
+ if projectFilesWidget.objectName.nil?
25
+ projectFilesWidget.objectName = "projectFilesWidget"
26
+ end
27
+ projectFilesWidget.resize(518, 576)
28
+ @verticalLayout = Qt::VBoxLayout.new(projectFilesWidget)
29
+ @verticalLayout.objectName = "verticalLayout"
30
+ @groupBox = Qt::GroupBox.new(projectFilesWidget)
31
+ @groupBox.objectName = "groupBox"
32
+ @gridLayout = Qt::GridLayout.new(@groupBox)
33
+ @gridLayout.objectName = "gridLayout"
34
+ @label = Qt::Label.new(@groupBox)
35
+ @label.objectName = "label"
36
+
37
+ @gridLayout.addWidget(@label, 0, 0, 1, 1)
38
+
39
+ @extensions = KDE::LineEdit.new(@groupBox)
40
+ @extensions.objectName = "extensions"
41
+
42
+ @gridLayout.addWidget(@extensions, 0, 1, 1, 1)
43
+
44
+ @label_2 = Qt::Label.new(@groupBox)
45
+ @label_2.objectName = "label_2"
46
+ @sizePolicy = Qt::SizePolicy.new(Qt::SizePolicy::Preferred, Qt::SizePolicy::Fixed)
47
+ @sizePolicy.setHorizontalStretch(0)
48
+ @sizePolicy.setVerticalStretch(0)
49
+ @sizePolicy.heightForWidth = @label_2.sizePolicy.hasHeightForWidth
50
+ @label_2.sizePolicy = @sizePolicy
51
+
52
+ @gridLayout.addWidget(@label_2, 1, 0, 1, 1)
53
+
54
+ @include_rules = Ruber::ProjectFilesRuleChooser.new(@groupBox)
55
+ @include_rules.objectName = "include_rules"
56
+ @include_rules.minimumSize = Qt::Size.new(350, 200)
57
+ @include_rules.focusPolicy = Qt::StrongFocus
58
+
59
+ @gridLayout.addWidget(@include_rules, 2, 0, 1, 2)
60
+
61
+
62
+ @verticalLayout.addWidget(@groupBox)
63
+
64
+ @groupBox_2 = Qt::GroupBox.new(projectFilesWidget)
65
+ @groupBox_2.objectName = "groupBox_2"
66
+ @gridLayout_2 = Qt::GridLayout.new(@groupBox_2)
67
+ @gridLayout_2.objectName = "gridLayout_2"
68
+ @label_3 = Qt::Label.new(@groupBox_2)
69
+ @label_3.objectName = "label_3"
70
+ @sizePolicy.heightForWidth = @label_3.sizePolicy.hasHeightForWidth
71
+ @label_3.sizePolicy = @sizePolicy
72
+
73
+ @gridLayout_2.addWidget(@label_3, 0, 0, 1, 1)
74
+
75
+ @exclude_rules = Ruber::ProjectFilesRuleChooser.new(@groupBox_2)
76
+ @exclude_rules.objectName = "exclude_rules"
77
+ @exclude_rules.minimumSize = Qt::Size.new(350, 200)
78
+ @exclude_rules.focusPolicy = Qt::StrongFocus
79
+
80
+ @gridLayout_2.addWidget(@exclude_rules, 1, 0, 1, 1)
81
+
82
+
83
+ @verticalLayout.addWidget(@groupBox_2)
84
+
85
+ @label.buddy = @extensions
86
+ @label_2.buddy = @include_rules
87
+ @label_3.buddy = @include_rules
88
+
89
+ retranslateUi(projectFilesWidget)
90
+
91
+ Qt::MetaObject.connectSlotsByName(projectFilesWidget)
92
+ end # setupUi
93
+
94
+ def setup_ui(projectFilesWidget)
95
+ setupUi(projectFilesWidget)
96
+ end
97
+
98
+ def retranslateUi(projectFilesWidget)
99
+ projectFilesWidget.windowTitle = Qt::Application.translate("ProjectFilesWidget", "Form", nil, Qt::Application::UnicodeUTF8)
100
+ @groupBox.title = Qt::Application.translate("ProjectFilesWidget", "Files to include", nil, Qt::Application::UnicodeUTF8)
101
+ @label.text = Qt::Application.translate("ProjectFilesWidget", "Extensions", nil, Qt::Application::UnicodeUTF8)
102
+ @label_2.text = Qt::Application.translate("ProjectFilesWidget", "&Rules", nil, Qt::Application::UnicodeUTF8)
103
+ @groupBox_2.title = Qt::Application.translate("ProjectFilesWidget", "Files to exclude", nil, Qt::Application::UnicodeUTF8)
104
+ @label_3.text = Qt::Application.translate("ProjectFilesWidget", "&Rules", nil, Qt::Application::UnicodeUTF8)
105
+ end # retranslateUi
106
+
107
+ def retranslate_ui(projectFilesWidget)
108
+ retranslateUi(projectFilesWidget)
109
+ end
110
+
111
+ end
112
+
113
+ module Ui
114
+ class ProjectFilesWidget < Ui_ProjectFilesWidget
115
+ end
116
+ end # module Ui
117
+
@@ -0,0 +1,123 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ui version="4.0">
3
+ <class>ProjectFilesWidget</class>
4
+ <widget class="QWidget" name="ProjectFilesWidget">
5
+ <property name="geometry">
6
+ <rect>
7
+ <x>0</x>
8
+ <y>0</y>
9
+ <width>518</width>
10
+ <height>576</height>
11
+ </rect>
12
+ </property>
13
+ <property name="windowTitle">
14
+ <string>Form</string>
15
+ </property>
16
+ <layout class="QVBoxLayout" name="verticalLayout">
17
+ <item>
18
+ <widget class="QGroupBox" name="groupBox">
19
+ <property name="title">
20
+ <string>Files to include</string>
21
+ </property>
22
+ <layout class="QGridLayout" name="gridLayout">
23
+ <item row="0" column="0">
24
+ <widget class="QLabel" name="label">
25
+ <property name="text">
26
+ <string>Extensions</string>
27
+ </property>
28
+ <property name="buddy">
29
+ <cstring>extensions</cstring>
30
+ </property>
31
+ </widget>
32
+ </item>
33
+ <item row="0" column="1">
34
+ <widget class="KLineEdit" name="extensions"/>
35
+ </item>
36
+ <item row="1" column="0">
37
+ <widget class="QLabel" name="label_2">
38
+ <property name="sizePolicy">
39
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
40
+ <horstretch>0</horstretch>
41
+ <verstretch>0</verstretch>
42
+ </sizepolicy>
43
+ </property>
44
+ <property name="text">
45
+ <string>&amp;Rules</string>
46
+ </property>
47
+ <property name="buddy">
48
+ <cstring>include_rules</cstring>
49
+ </property>
50
+ </widget>
51
+ </item>
52
+ <item row="2" column="0" colspan="2">
53
+ <widget class="Ruber::ProjectFilesRuleChooser" name="include_rules" native="true">
54
+ <property name="minimumSize">
55
+ <size>
56
+ <width>350</width>
57
+ <height>200</height>
58
+ </size>
59
+ </property>
60
+ <property name="focusPolicy">
61
+ <enum>Qt::StrongFocus</enum>
62
+ </property>
63
+ </widget>
64
+ </item>
65
+ </layout>
66
+ </widget>
67
+ </item>
68
+ <item>
69
+ <widget class="QGroupBox" name="groupBox_2">
70
+ <property name="title">
71
+ <string>Files to exclude</string>
72
+ </property>
73
+ <layout class="QGridLayout" name="gridLayout_2">
74
+ <item row="0" column="0">
75
+ <widget class="QLabel" name="label_3">
76
+ <property name="sizePolicy">
77
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
78
+ <horstretch>0</horstretch>
79
+ <verstretch>0</verstretch>
80
+ </sizepolicy>
81
+ </property>
82
+ <property name="text">
83
+ <string>&amp;Rules</string>
84
+ </property>
85
+ <property name="buddy">
86
+ <cstring>include_rules</cstring>
87
+ </property>
88
+ </widget>
89
+ </item>
90
+ <item row="1" column="0">
91
+ <widget class="Ruber::ProjectFilesRuleChooser" name="exclude_rules" native="true">
92
+ <property name="minimumSize">
93
+ <size>
94
+ <width>350</width>
95
+ <height>200</height>
96
+ </size>
97
+ </property>
98
+ <property name="focusPolicy">
99
+ <enum>Qt::StrongFocus</enum>
100
+ </property>
101
+ </widget>
102
+ </item>
103
+ </layout>
104
+ </widget>
105
+ </item>
106
+ </layout>
107
+ </widget>
108
+ <customwidgets>
109
+ <customwidget>
110
+ <class>KLineEdit</class>
111
+ <extends>QLineEdit</extends>
112
+ <header>klineedit.h</header>
113
+ </customwidget>
114
+ <customwidget>
115
+ <class>Ruber::ProjectFilesRuleChooser</class>
116
+ <extends>QWidget</extends>
117
+ <header>ruber_projectfilesrulechooser.h</header>
118
+ <container>1</container>
119
+ </customwidget>
120
+ </customwidgets>
121
+ <resources/>
122
+ <connections/>
123
+ </ui>
@@ -0,0 +1,673 @@
1
+ =begin
2
+ Copyright (C) 2010 by Stefano Crocco
3
+ stefano.crocco@alice.it
4
+
5
+ This program is free software; you can redistribute it andor modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation; either version 2 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the
17
+ Free Software Foundation, Inc.,
18
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
+ =end
20
+
21
+ require 'yaml'
22
+
23
+ module Qt
24
+
25
+ NilObject = Object.new{self.object_name = 'nil object'}
26
+
27
+ class Base
28
+
29
+ def nil_object?
30
+ # if the object doesn't inherit from Qt::Object, meta_object will raise
31
+ # an exception
32
+ self.meta_object
33
+ self.equal? NilObject
34
+ end
35
+
36
+ =begin rdoc
37
+ :call-seq:
38
+ obj.named_connect(sig, name){||...}
39
+
40
+ It works as Qt::Base#connect, except for the fact that it associates a name
41
+ with the connection. This way, you can use <tt>Qt::base#named_disconnect</tt>
42
+ to disconnect the block from the signal.
43
+
44
+ This is implemented by tracking the object internally created by Qt to manage
45
+ the connection and assigning it a name, so that it can then be found using
46
+ <tt>find_child</tt>.
47
+
48
+ <b>Note:</b> this method assumes that only one object of class
49
+ <tt>Qt::SignalBlockInvocation</tt> is created by +connect+. If it isn't so,
50
+ +RuntimeError+ will be raised.
51
+ =end
52
+ def named_connect signal, name, &blk
53
+ old_children = find_children(Qt::SignalBlockInvocation)
54
+ # old_children = find_children(Qt::Object).select{|c| c.class == Qt::SignalBlockInvocation}
55
+ res = self.connect(signal, &blk)
56
+ return nil unless res
57
+ # new_children = find_children(Qt::Object).select{|c| c.class == Qt::SignalBlockInvocation} - old_children
58
+ new_children = find_children(Qt::SignalBlockInvocation) - old_children
59
+ unless new_children.size == 1
60
+ raise RuntimeError, "Wrong number of new children: #{new_children.size} instead of 1"
61
+ end
62
+ new_children.first.object_name = name
63
+ true
64
+ end
65
+
66
+ =begin rdoc
67
+ Breaks the connection with name _name_ (which should have been created using
68
+ <tt>named_connect</tt>)
69
+ =end
70
+ def named_disconnect name
71
+ rec = find_child Qt::SignalBlockInvocation, name
72
+ disconnect self, nil, rec, nil
73
+ end
74
+
75
+ end
76
+
77
+ class Point
78
+
79
+ yaml_as "tag:ruby.yaml.org,2002:Qt::Point"
80
+
81
+ def self.yaml_new cls, tag, val
82
+ x, y= val['x'], val['y']
83
+ Qt::Point.new(x, y)
84
+ end
85
+
86
+ def to_yaml opts = {}
87
+ YAML.quick_emit(self, opts) do |out|
88
+ out.map(taguri, to_yaml_style) do |map|
89
+ map.add 'x', self.x
90
+ map.add 'y', self.y
91
+ end
92
+ end
93
+ end
94
+
95
+ def _dump _
96
+ "#{x};#{self.y}"
97
+ end
98
+
99
+ def self._load str
100
+ x, y = str.split ';'
101
+ self.new x.to_i, y.to_i
102
+ end
103
+
104
+ end
105
+
106
+ class PointF
107
+
108
+ yaml_as "tag:ruby.yaml.org,2002:Qt::PointF"
109
+
110
+ def self.yaml_new cls, tag, val
111
+ x, y= val['x'], val['y']
112
+ Qt::PointF.new(x.to_f, y.to_f)
113
+ end
114
+
115
+ def to_yaml opts = {}
116
+ YAML.quick_emit(self, opts) do |out|
117
+ out.map(taguri, to_yaml_style) do |map|
118
+ loc = Qt::Locale.c
119
+ loc.number_options = Qt::Locale::OmitGroupSeparator
120
+ map.add 'x', loc.to_string( self.x )
121
+ map.add 'y', loc.to_string( self.y )
122
+ end
123
+ end
124
+ end
125
+
126
+ def _dump _
127
+ loc = Qt::Locale.c
128
+ loc.number_options = Qt::Locale::OmitGroupSeparator
129
+ sx = loc.to_string( self.x )
130
+ sy = loc.to_string( self.y )
131
+ "#{sx};#{sy}"
132
+ end
133
+
134
+ def self._load str
135
+ x, y = str.split ';'
136
+ self.new x.to_f, y.to_f
137
+ end
138
+
139
+ end
140
+
141
+ class Size
142
+
143
+ yaml_as "tag:ruby.yaml.org,2002:Qt::Size"
144
+
145
+ def self.yaml_new cls, tag, val
146
+ width, height= val['width'], val['height']
147
+ Qt::Size.new(width, height)
148
+ end
149
+
150
+ def to_yaml opts = {}
151
+ YAML.quick_emit(self, opts) do |out|
152
+ out.map(taguri, to_yaml_style) do |map|
153
+ map.add 'width', width
154
+ map.add 'height', height
155
+ end
156
+ end
157
+ end
158
+
159
+ def _dump _
160
+ "#{width};#{height}"
161
+ end
162
+
163
+ def self._load str
164
+ w, h = str.split ';'
165
+ self.new w.to_i, h.to_i
166
+ end
167
+
168
+
169
+ end
170
+
171
+ class SizeF
172
+
173
+ yaml_as "tag:ruby.yaml.org,2002:Qt::SizeF"
174
+
175
+ def self.yaml_new cls, tag, val
176
+ width, height= val['width'], val['height']
177
+ Qt::SizeF.new(width.to_f, height.to_f)
178
+ end
179
+
180
+ def to_yaml opts = {}
181
+ YAML.quick_emit(self, opts) do |out|
182
+ out.map(taguri, to_yaml_style) do |map|
183
+ loc = Qt::Locale.c
184
+ loc.number_options = Qt::Locale::OmitGroupSeparator
185
+ map.add 'width', loc.to_string(width)
186
+ map.add 'height', loc.to_string(height)
187
+ end
188
+ end
189
+ end
190
+
191
+ def _dump _
192
+ loc = Qt::Locale.c
193
+ loc.number_options = Qt::Locale::OmitGroupSeparator
194
+ sw = loc.to_string width
195
+ sh = loc.to_string height
196
+ "#{sw};#{sh}"
197
+ end
198
+
199
+ def self._load str
200
+ w, h = str.split ';'
201
+ self.new w.to_f, h.to_f
202
+ end
203
+
204
+ end
205
+
206
+ class Rect
207
+
208
+ yaml_as "tag:ruby.yaml.org,2002:Qt::Rect"
209
+
210
+ def self.yaml_new cls, tag, val
211
+ left, top, width, height= val['left'], val['top'], val['width'],
212
+ val['height']
213
+ self.new(left, top, width, height)
214
+ end
215
+
216
+ def to_yaml opts = {}
217
+ YAML.quick_emit(self, opts) do |out|
218
+ out.map(taguri, to_yaml_style) do |map|
219
+ map.add 'left', left
220
+ map.add 'top', top
221
+ map.add 'width', width
222
+ map.add 'height', height
223
+ end
224
+ end
225
+ end
226
+
227
+ def _dump _
228
+ "#{left};#{top};#{width};#{height}"
229
+ end
230
+
231
+ def self._load str
232
+ l, t, w, h = str.split ';'
233
+ self.new l.to_i, t.to_i, w.to_i, h.to_i
234
+ end
235
+
236
+ end
237
+
238
+ class RectF
239
+
240
+ yaml_as "tag:ruby.yaml.org,2002:Qt::RectF"
241
+
242
+ def self.yaml_new cls, tag, val
243
+ left, top, width, height= val['left'], val['top'], val['width'],
244
+ val['height']
245
+ Qt::RectF.new(left.to_f, top.to_f, width.to_f, height.to_f)
246
+ end
247
+
248
+ def to_yaml opts = {}
249
+ YAML.quick_emit(self, opts) do |out|
250
+ out.map(taguri, to_yaml_style) do |map|
251
+ loc = Qt::Locale.c
252
+ loc.number_options = Qt::Locale::OmitGroupSeparator
253
+ map.add 'left', loc.to_string(left)
254
+ map.add 'top', loc.to_string(top)
255
+ map.add 'width', loc.to_string(width)
256
+ map.add 'height', loc.to_string(height)
257
+ end
258
+ end
259
+ end
260
+
261
+ def _dump _
262
+ loc = Qt::Locale.c
263
+ loc.number_options = Qt::Locale::OmitGroupSeparator
264
+ sl = loc.to_string left
265
+ st = loc.to_string top
266
+ sw = loc.to_string width
267
+ sh = loc.to_string height
268
+ "#{sl};#{st};#{sw};#{sh}"
269
+ end
270
+
271
+ def self._load str
272
+ l, t, w, h = str.split ';'
273
+ self.new l.to_f, t.to_f, w.to_f, h.to_f
274
+ end
275
+
276
+ end
277
+
278
+ class Color
279
+ yaml_as "tag:ruby.yaml.org,2002:Qt::Color"
280
+
281
+ def self.yaml_new cls, tag, val
282
+ r, g, b= val['red'], val['green'], val['blue']
283
+ Qt::Color.new(r, g, b)
284
+ end
285
+
286
+ def to_yaml opts = {}
287
+ YAML.quick_emit(self, opts) do |out|
288
+ out.map(taguri, to_yaml_style) do |map|
289
+ map.add 'red', red
290
+ map.add 'green', green
291
+ map.add 'blue', blue
292
+ end
293
+ end
294
+ end
295
+
296
+ def _dump _
297
+ "#{red};#{green};#{blue}"
298
+ end
299
+
300
+ def self._load str
301
+ r, g, b = str.split ';'
302
+ self.new r.to_i, g.to_i, b.to_i
303
+ end
304
+
305
+ end
306
+
307
+ class Date
308
+ yaml_as "tag:ruby.yaml.org,2002:Qt::Date"
309
+
310
+ def self.yaml_new cls, tag, val
311
+ y, m, d = val['year'], val['month'], val['day']
312
+ Qt::Date.new(y, m, d)
313
+ end
314
+
315
+ def to_yaml opts = {}
316
+ YAML.quick_emit(self, opts) do |out|
317
+ out.map(taguri, to_yaml_style) do |map|
318
+ map.add 'year', year
319
+ map.add 'month', month
320
+ map.add 'day', day
321
+ end
322
+ end
323
+ end
324
+
325
+ def _dump _
326
+ "#{year};#{month};#{day}"
327
+ end
328
+
329
+ def self._load str
330
+ y, m, d = str.split ';'
331
+ self.new(y.to_i, m.to_i, d.to_i)
332
+ end
333
+
334
+ end
335
+
336
+ class DateTime
337
+ yaml_as "tag:ruby.yaml.org,2002:Qt::DateTime"
338
+
339
+ def self.yaml_new cls, tag, val
340
+ date, time, spec = val['date'], val['time'], val['time_spec']
341
+ Qt::DateTime.new date, time, spec
342
+ end
343
+
344
+ def to_yaml opts = {}
345
+ YAML.quick_emit(self, opts) do |out|
346
+ out.map(taguri, to_yaml_style) do |map|
347
+ map.add 'date', date
348
+ map.add 'time', time
349
+ map.add 'time_spec', time_spec
350
+ end
351
+ end
352
+ end
353
+
354
+ def _dump _
355
+ Marshal.dump [date, time, time_spec]
356
+ end
357
+
358
+ def self._load str
359
+ date, time, time_spec = Marshal.load str
360
+ self.new date, time, time_spec
361
+ end
362
+
363
+ end
364
+
365
+ class Font
366
+ yaml_as "tag:ruby.yaml.org,2002:Qt::Font"
367
+
368
+ def self.yaml_new cls, tag, val
369
+ res = Qt::Font.new
370
+ res.from_string val
371
+ res
372
+ end
373
+
374
+ def to_yaml opts = {}
375
+ YAML.quick_emit(self, opts) do |out|
376
+ out.scalar taguri, to_string, :plain
377
+ end
378
+ end
379
+
380
+ def _dump _
381
+ to_string
382
+ end
383
+
384
+ def self._load str
385
+ res = Qt::Font.new
386
+ res.from_string str
387
+ res
388
+ end
389
+
390
+ end
391
+
392
+ class Time
393
+ yaml_as "tag:ruby.yaml.org,2002:Qt::Time"
394
+
395
+ def self.yaml_new cls, tag, val
396
+ if val['valid']
397
+ Qt::Time.new val['hours'], val['minutes'], val['seconds'], val['msec']
398
+ else Qt::Time.new
399
+ end
400
+ end
401
+
402
+ def to_yaml opts = {}
403
+ YAML.quick_emit(self, opts) do |out|
404
+ out.map(taguri, to_yaml_style) do |map|
405
+ map.add 'valid', valid?
406
+ if valid?
407
+ map.add 'hours', hour
408
+ map.add 'minutes', minute
409
+ map.add 'seconds', second
410
+ map.add 'msec', msec
411
+ end
412
+ end
413
+ end
414
+ end
415
+
416
+ def _dump _
417
+ if valid? then "#{hour};#{minute};#{second};#{msec}"
418
+ else ""
419
+ end
420
+ end
421
+
422
+ def self._load str
423
+ if str.empty? then self.new
424
+ else
425
+ h, m, s, ms = str.split ';'
426
+ self.new h.to_i, m.to_i, s.to_i, ms.to_i
427
+ end
428
+ end
429
+
430
+ end
431
+
432
+ class Url
433
+ yaml_as "tag:ruby.yaml.org,2002:Qt::Url"
434
+
435
+ def self.yaml_new cls, tag, val
436
+ Qt::Url.new val
437
+ end
438
+
439
+ def to_yaml opts = {}
440
+ YAML.quick_emit(self, opts) do |out|
441
+ out.scalar taguri, to_string, :plain
442
+ end
443
+ end
444
+
445
+ def _dump _
446
+ to_string
447
+ end
448
+
449
+ def self._load str
450
+ self.new str
451
+ end
452
+
453
+ end
454
+
455
+ class StandardItemModel
456
+
457
+ include QtEnumerable
458
+
459
+ =begin rdoc
460
+ If given a block, calls it once for each top level item. This means that items
461
+ in the same row but in different columns will each cause a separate block execution.
462
+
463
+ If a block isn't given, returns an +Enumerator+ which does the same as above.
464
+ =end
465
+ def each
466
+ if block_given?
467
+ rowCount.times do |i|
468
+ columnCount.times do |j|
469
+ it = item(i,j)
470
+ yield it if it
471
+ end
472
+ end
473
+ else self.to_enum
474
+ end
475
+ end
476
+
477
+ =begin rdoc
478
+ If given a block, calls it once for each top level row, passing it an array containing
479
+ the items in the row. If the number of columns varies from row to row, the arrays
480
+ corresponding to the ones with less items will have *nil* instead of the missing
481
+ items.
482
+
483
+ If a block isn't given, returns an +Enumerator+ which does the same as above.
484
+ =end
485
+ def each_row
486
+ if block_given?
487
+ rowCount.times do |r|
488
+ a = []
489
+ columnCount.times{|c| a << item(r, c)}
490
+ yield a
491
+ end
492
+ else self.to_enum(:each_row)
493
+ end
494
+ end
495
+
496
+ end
497
+
498
+ class SortFilterProxyModel
499
+
500
+ include QtEnumerable
501
+
502
+ =begin rdoc
503
+ Calls the block for each top-level item
504
+ =end
505
+ def each
506
+ rowCount.times do |r|
507
+ columnCount.times{|c| yield index(r,c)}
508
+ end
509
+ end
510
+
511
+ end
512
+
513
+ class StandardItem
514
+
515
+ include QtEnumerable
516
+
517
+ =begin rdoc
518
+ Iterates on all child items. If no block is given, returns an Enumerator
519
+
520
+ <b>Note: </b>this method iterates only on those items which are directly child
521
+ of +self+; it's not recursive.
522
+ =end
523
+ def each
524
+ if block_given?
525
+ rowCount.times do |i|
526
+ columnCount.times do |j|
527
+ c = child i, j
528
+ yield c if c
529
+ end
530
+ end
531
+ else self.to_enum
532
+ end
533
+ end
534
+
535
+ =begin rdoc
536
+ Passes an array containing the items in each of the children rows. Returns an
537
+ Enumerator if called without a block
538
+ =end
539
+ def each_row
540
+ if block_given?
541
+ rowCount.times do |i|
542
+ a = []
543
+ columnCount.times{|j| a << child( i,j)}
544
+ yield a
545
+ end
546
+ else to_enum
547
+ end
548
+ end
549
+
550
+ # Returns true if the check state is <tt>Qt::Checked</tt> or <tt>Qt::PartiallyChecked</tt>
551
+ def checked?
552
+ check_state != Qt::Unchecked
553
+ end
554
+
555
+ # Returns *true* if the check_state is <tt>Qt::Checked</tt> and *false* otherwise
556
+ def fully_checked?
557
+ self.check_state == Qt::Checked
558
+ end
559
+
560
+ =begin rdoc
561
+ Sets the check state to <tt>Qt::Unchecked</tt> if _value_ is +false+ or +nil+
562
+ and to <tt>Qt::Checked</tt> otherwise
563
+ =end
564
+ def checked= value
565
+ self.check_state = (value ? Qt::Checked : Qt::Unchecked)
566
+ end
567
+
568
+ end
569
+
570
+ class Variant
571
+
572
+ def to_sym
573
+ to_string.to_sym
574
+ end
575
+
576
+ =begin rdoc
577
+ Redefinition of <tt>to_bool</tt> it's needed because otherwise the Object#to_bool
578
+ method defined in <tt>facets/boolean</tt> is used, instead of calling method_missing.
579
+
580
+ By explicitly define a <tt>to_bool</method> and having it call <tt>method_missing</tt>,
581
+ the problem is solved
582
+ =end
583
+ def to_bool
584
+ method_missing :to_bool
585
+ end
586
+
587
+ end
588
+
589
+ class MetaObject
590
+
591
+ def each_signal
592
+ if block_given?
593
+ method_count.times do |i|
594
+ m = method i
595
+ yield m if m.method_type == Qt::MetaMethod::Signal
596
+ end
597
+ else self.enum_for(:each_signal)
598
+ end
599
+ end
600
+
601
+ def each_slot
602
+ if block_given?
603
+ method_count.times do |i|
604
+ m = method i
605
+ yield m if m.method_type == Qt::MetaMethod::Slot
606
+ end
607
+ else self.enum_for(:each_slot)
608
+ end
609
+ end
610
+
611
+ def each_method
612
+ if block_given?
613
+ method_count.times{|i| yield method i}
614
+ else self.enum_for(:each_method)
615
+ end
616
+ end
617
+
618
+ end
619
+
620
+ class Qt::StackedWidget
621
+
622
+ include QtEnumerable
623
+
624
+ =begin rdoc
625
+ Calls the block for each widget in the stack, or returns an enumerator if no block
626
+ is given
627
+ =end
628
+ def each
629
+ if block_given?
630
+ count.times{|i| yield widget(i)}
631
+ else to_enum
632
+ end
633
+ end
634
+
635
+ def empty?
636
+ self.count == 0
637
+ end
638
+
639
+ end
640
+
641
+ end
642
+
643
+ =begin rdoc
644
+ Qt::StandardItemModel-derived class which allow to set flags for all the items.
645
+ To do so, simply set the global_flags attribute to the desired flags.
646
+ =end
647
+ class GlobalFlagStandardItemModel < Qt::StandardItemModel
648
+
649
+ =begin rdoc
650
+ The flags which should be returned by every call to flags.
651
+ =end
652
+ attr_accessor :global_flags
653
+
654
+ =begin rdoc
655
+ Creates a new GlobalFlagStandardItemModel. The global_flags attribute for the new
656
+ model will be set to nil. This means that the flags method will behave exactly as
657
+ the Qt::StandardItemModel#flags method.
658
+ =end
659
+ def initialize parent = nil
660
+ super
661
+ @global_flags = nil
662
+ end
663
+
664
+ =begin rdoc
665
+ Returns the flags associated with the index _idx_. If returns the value contained
666
+ in the global_flags attribute if it is not nil, otherwise it will call
667
+ Qt::StandardItemModel#flags and return that value
668
+ =end
669
+ def flags idx
670
+ @global_flags || super
671
+ end
672
+
673
+ end