qtext 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dfe64329c4fb2c401403072b0eae2ad28a336c77
4
+ data.tar.gz: a1bf928c812c6694b2968fe59525825c1bf4a90c
5
+ SHA512:
6
+ metadata.gz: 3c453b9747d5dcc88d4e7f47042ac0a370d08f47d19fb7c635f31e464ab578195a74c474ab6121fff2963cc239e425ce90a083e653e87c8a45c6318854ce3f7d
7
+ data.tar.gz: 55acf85c952e78c40aba1c8cb6b9efc0a0916391fde0dfa96d97ffd6e03dc15f490e60f86cf8b10288462205e543fd7e165658ff643e01b53157028bf17d8d70
@@ -1,3 +1,7 @@
1
+ == 0.6.9
2
+ * fix error in ActionBuilder.included
3
+ * tests broken
4
+
1
5
  == 0.6.8
2
6
  * Remove Hoe dependency
3
7
  * Update gather dependency
@@ -21,7 +25,7 @@
21
25
  == 0.6.0
22
26
  * add Qt::Widget.signal class method which adds some signal emitting and
23
27
  handling methods.
24
- * remove Qt::Widget.construct and construct_exec because they're already part
28
+ * remove Qt::Widget.construct and construct_exec because they're already part
25
29
  of Qt::Widget.new
26
30
  * Documentation
27
31
  * Some testing
data/README.txt CHANGED
@@ -4,7 +4,7 @@ http://rubyforge.org/projects/qtext
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- Some extensions to qt4-qtruby to make it more rubyish.
7
+ Some extensions to qtruby to make it more rubyish.
8
8
 
9
9
  == FEATURES
10
10
  - ActionBuilder module to simplify creating Action objects for inclusion into menus.
@@ -18,13 +18,14 @@ Some extensions to qt4-qtruby to make it more rubyish.
18
18
 
19
19
  == SYNOPSIS:
20
20
 
21
- require 'qtext'
21
+ require 'qtext'
22
22
 
23
23
  == REQUIREMENTS:
24
24
 
25
25
  - qtruby4
26
26
  - Shoulda if you want to run tests
27
- - ActiveSupport. Only needed in Header for humanize.
27
+ - something that supplies String#humanize (activesupport or sequel)
28
+
28
29
  == INSTALL:
29
30
 
30
31
  sudo gem install qtext
data/Rakefile CHANGED
@@ -5,7 +5,6 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  task :default => 'test:run'
8
- task 'gem:release' => 'test:run'
9
8
 
10
9
  ensure_in_path 'lib'
11
10
  require 'qtext/version.rb'
@@ -71,11 +71,11 @@ If this method is not defined, it will be created in the including class as an e
71
71
  module ActionBuilder
72
72
  # raise a RuntimeError if the including class/module does not define add_action
73
73
  def self.included( including_module )
74
- shortlist = including_module.instance_methods.grep /action/i
74
+ shortlist = including_module.instance_methods.grep(/action/i).map{|meth_name| meth_name.to_sym}
75
75
  # add_action is actually an method_missing lookup for addAction, so
76
76
  # search for both.
77
- unless shortlist.any? {|x| %w{add_action addAction}.include?( x )}
78
- raise NotImplementedError( "#{including_module.class.name} must have an add_action method" )
77
+ unless shortlist.any? {|x| %i{add_action addAction}.include?( x )}
78
+ raise NotImplementedError, "#{including_module.name} must have an add_action method"
79
79
  end
80
80
  end
81
81
 
@@ -2,7 +2,7 @@ module QtExt #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 6
5
- TINY = 8
5
+ TINY = 9
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,29 +1,29 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- require 'sequel/core'
4
- require 'sequel/extensions/inflector'
5
-
6
- module Sequel; end
7
-
8
- class TestKeyEvent < Test::Unit::TestCase
9
-
10
- #~ Qt::NoModifier 0x00000000 No modifier key is pressed.
11
- #~ Qt::ShiftModifier 0x02000000 A Shift key on the keyboard is pressed.
12
- #~ Qt::ControlModifier 0x04000000 A Ctrl key on the keyboard is pressed.
13
- #~ Qt::AltModifier 0x08000000 An Alt key on the keyboard is pressed.
14
- #~ Qt::MetaModifier 0x10000000 A Meta key on the keyboard is pressed.
15
- #~ Qt::KeypadModifier 0x20000000 A keypad button is pressed.
16
- #~ Qt::GroupSwitchModifier
17
- def setup
18
- @key_event = Qt::KeyEvent.new( Qt::Event::KeyPress, Qt::Key_Down, Qt::NoModifier )
19
- end
20
-
21
- def test_camelize
22
- assert "somstring".respond_to?( :camelize ), "String has no camelize method"
23
- end
24
-
25
- should 'have the key? methods' do
26
- assert @key_event.key? 'down'
27
- assert @key_event.down?, "Key is not Qt::Key_Down"
28
- end
29
- end
1
+ require_relative 'test_helper.rb'
2
+
3
+ require 'sequel/core'
4
+ require 'sequel/extensions/inflector'
5
+
6
+ module Sequel; end
7
+
8
+ class TestKeyEvent < Test::Unit::TestCase
9
+
10
+ #~ Qt::NoModifier 0x00000000 No modifier key is pressed.
11
+ #~ Qt::ShiftModifier 0x02000000 A Shift key on the keyboard is pressed.
12
+ #~ Qt::ControlModifier 0x04000000 A Ctrl key on the keyboard is pressed.
13
+ #~ Qt::AltModifier 0x08000000 An Alt key on the keyboard is pressed.
14
+ #~ Qt::MetaModifier 0x10000000 A Meta key on the keyboard is pressed.
15
+ #~ Qt::KeypadModifier 0x20000000 A keypad button is pressed.
16
+ #~ Qt::GroupSwitchModifier
17
+ def setup
18
+ @key_event = Qt::KeyEvent.new( Qt::Event::KeyPress, Qt::Key_Down, Qt::NoModifier )
19
+ end
20
+
21
+ def test_camelize
22
+ assert "somstring".respond_to?( :camelize ), "String has no camelize method"
23
+ end
24
+
25
+ should 'have the key? methods' do
26
+ assert @key_event.key? 'down'
27
+ assert @key_event.down?, "Key is not Qt::Key_Down"
28
+ end
29
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require_relative 'test_helper.rb'
2
2
 
3
3
  class TestModelIndex < Test::Unit::TestCase
4
4
  def setup
@@ -10,24 +10,24 @@ class TestModelIndex < Test::Unit::TestCase
10
10
  end
11
11
  @zero_index = @model.create_index(0,0)
12
12
  end
13
-
13
+
14
14
  def teardown
15
15
  end
16
-
16
+
17
17
  should "be valid" do
18
18
  assert @zero_index.valid?
19
19
  end
20
-
20
+
21
21
  should_eventually "be invalid" do
22
22
  mi = @model.create_index( @model.row_count+1, @model.column_count+1 )
23
23
  assert !mi.valid?
24
24
  end
25
-
25
+
26
26
  should 'be an invalid copy of an invalid index' do
27
27
  choppy = Qt::ModelIndex.invalid.choppy
28
28
  assert !choppy.valid?
29
29
  end
30
-
30
+
31
31
  should "be a valid exact copy" do
32
32
  choppy = @zero_index.choppy
33
33
  assert choppy.valid?
@@ -36,11 +36,11 @@ class TestModelIndex < Test::Unit::TestCase
36
36
  should 'be an invalid copy' do
37
37
  choppy = @zero_index.choppy( :row => @model.row_count )
38
38
  assert !choppy.valid?, "choppy: #{choppy.inspect}"
39
-
39
+
40
40
  choppy = @zero_index.choppy( :column => @model.column_count )
41
41
  assert !choppy.valid?
42
42
  end
43
-
43
+
44
44
  should 'be a copy with a changed row and column, from hash' do
45
45
  choppy = @zero_index.choppy( :row => 1, :column => 2)
46
46
  assert_equal 1, choppy.row, choppy.inspect
@@ -57,23 +57,23 @@ class TestModelIndex < Test::Unit::TestCase
57
57
  assert_equal 1, choppy.row
58
58
  assert_equal 2, choppy.column
59
59
  end
60
-
60
+
61
61
  should 'be a copy with changed row and column, from parameters' do
62
62
  choppy = @zero_index.choppy(3,0)
63
63
  assert choppy.valid?
64
64
  assert_equal 3, choppy.row
65
65
  assert_equal 0, choppy.column
66
66
  end
67
-
67
+
68
68
  should 'raise an exception because parameters are wrong' do
69
69
  assert_raise TypeError do
70
70
  @zero_index.choppy( 3 )
71
71
  end
72
72
  end
73
-
73
+
74
74
  should 'be a copy with decremented row and column, from block' do
75
75
  two_index = @model.create_index(2,2)
76
-
76
+
77
77
  choppy = two_index.choppy do |i|
78
78
  i.row -= 1
79
79
  i.column -= 2
@@ -1,85 +1,86 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
- require 'qtext/object_table_model.rb'
3
- require 'Qt4'
4
-
5
- class TestObjectTableModel < Test::Unit::TestCase
6
- Thing = Struct.new( :name, :value, :location, :price, :ignored ) do
7
- include TreeViewable
8
- end
9
-
10
- def setup
11
- @data = [
12
- Thing.new( "Screwdriver", 'high', 'toolbox', 10.96, 'not' ),
13
- Thing.new( "Thermometer", '15 degrees', 'bathroom', 0.01, 'here' ),
14
- Thing.new( "Bed", 'large', 'bedroom' ),
15
- Thing.new( "Approximation", 'useful', 'maths', 'none', 'all' )
16
- ]
17
- @data[3].children = @data
18
- @model = ObjectTableModel.new( :data => @data, :headers => [ :name, :value, :location, Header.new( :attribute => :price, :alignment => Qt::AlignRight ) ] )
19
- @main_window = Qt::MainWindow.new
20
- #~ @view = Qt::TableView.new( @main_window ) { |tv| tv.model = @model }
21
- @view = Qt::TreeView.new( @main_window ) { |tv| tv.model = @model }
22
- @main_window.central_widget = @view
23
- end
24
-
25
- should 'have children for data[3]' do
26
- assert_equal 4, @data[3].children.size
27
- end
28
-
29
- should 'have a 4 x 4 size' do
30
- assert_equal 4, @model.rowCount
31
- assert_equal 4, @model.row_count
32
- assert_equal 4, @model.columnCount
33
- assert_equal 4, @model.column_count
34
- end
35
-
36
- should 'have 0x0 size for children models at a given index' do
37
- index = @model.create_index(1,1)
38
- assert_equal 0, @model.row_count( index )
39
- assert_equal 0, @model.column_count( index )
40
- end
41
-
42
- should 'return correct data' do
43
- @data.each_with_index do |item,i|
44
- Thing.members.each_with_index do |member,j|
45
- next if j >= 4
46
- model_index = @model.create_index(i,j)
47
- assert_equal item[member], @model.data( model_index ).value
48
- end
49
- end
50
- end
51
-
52
- should 'return nil for invalid index' do
53
- assert_equal Qt::Variant.invalid, @model.data( Qt::ModelIndex.invalid )
54
- end
55
-
56
- should 'have price aligned right' do
57
- assert_equal Qt::AlignLeft.to_i, @model.data( @model.create_index(0,0), Qt::TextAlignmentRole ).to_i & Qt::AlignLeft.to_i
58
- assert_equal Qt::AlignLeft.to_i, @model.data( @model.create_index(0,1), Qt::TextAlignmentRole ).to_i & Qt::AlignLeft.to_i
59
- assert_equal Qt::AlignRight.to_i, @model.data( @model.create_index(0,3), Qt::TextAlignmentRole ).to_i & Qt::AlignRight.to_i
60
- end
61
-
62
- should 'have a nil parent' do
63
- assert_nil @model.parent
64
- end
65
-
66
- should 'have parent == @model' do
67
- model = ObjectTableModel.new( :parent => @model, :data => @data, :headers => [ :name, :value, :location, Header.new( :attribute => :price, :alignment => Qt::AlignRight ) ] )
68
- assert_equal @model, model.parent
69
- end
70
-
71
- context 'tree view' do
72
- should 'have children' do
73
- model_index = @model.create_index(3,0)
74
- assert_equal 4, @model.row_count( model_index )
75
- end
76
- end
77
-
78
- def dont_test_show_window
79
- @main_window.window_title = 'Test ObjectTableModel'
80
- @main_window.move( 150, 0 )
81
- @main_window.show
82
- #~ $app.exec
83
- end
84
-
85
- end
1
+ require_relative 'test_helper.rb'
2
+
3
+ require 'qtext/object_table_model.rb'
4
+ require 'Qt4'
5
+
6
+ class TestObjectTableModel < Test::Unit::TestCase
7
+ Thing = Struct.new( :name, :value, :location, :price, :ignored ) do
8
+ include TreeViewable
9
+ end
10
+
11
+ def setup
12
+ @data = [
13
+ Thing.new( "Screwdriver", 'high', 'toolbox', 10.96, 'not' ),
14
+ Thing.new( "Thermometer", '15 degrees', 'bathroom', 0.01, 'here' ),
15
+ Thing.new( "Bed", 'large', 'bedroom' ),
16
+ Thing.new( "Approximation", 'useful', 'maths', 'none', 'all' )
17
+ ]
18
+ @data[3].children = @data
19
+ @model = ObjectTableModel.new( :data => @data, :headers => [ :name, :value, :location, Header.new( :attribute => :price, :alignment => Qt::AlignRight ) ] )
20
+ @main_window = Qt::MainWindow.new
21
+ #~ @view = Qt::TableView.new( @main_window ) { |tv| tv.model = @model }
22
+ @view = Qt::TreeView.new( @main_window ) { |tv| tv.model = @model }
23
+ @main_window.central_widget = @view
24
+ end
25
+
26
+ should 'have children for data[3]' do
27
+ assert_equal 4, @data[3].children.size
28
+ end
29
+
30
+ should 'have a 4 x 4 size' do
31
+ assert_equal 4, @model.rowCount
32
+ assert_equal 4, @model.row_count
33
+ assert_equal 4, @model.columnCount
34
+ assert_equal 4, @model.column_count
35
+ end
36
+
37
+ should 'have 0x0 size for children models at a given index' do
38
+ index = @model.create_index(1,1)
39
+ assert_equal 0, @model.row_count( index )
40
+ assert_equal 0, @model.column_count( index )
41
+ end
42
+
43
+ should 'return correct data' do
44
+ @data.each_with_index do |item,i|
45
+ Thing.members.each_with_index do |member,j|
46
+ next if j >= 4
47
+ model_index = @model.create_index(i,j)
48
+ assert_equal item[member], @model.data( model_index ).value
49
+ end
50
+ end
51
+ end
52
+
53
+ should 'return nil for invalid index' do
54
+ assert_equal Qt::Variant.invalid, @model.data( Qt::ModelIndex.invalid )
55
+ end
56
+
57
+ should 'have price aligned right' do
58
+ assert_equal Qt::AlignLeft.to_i, @model.data( @model.create_index(0,0), Qt::TextAlignmentRole ).to_i & Qt::AlignLeft.to_i
59
+ assert_equal Qt::AlignLeft.to_i, @model.data( @model.create_index(0,1), Qt::TextAlignmentRole ).to_i & Qt::AlignLeft.to_i
60
+ assert_equal Qt::AlignRight.to_i, @model.data( @model.create_index(0,3), Qt::TextAlignmentRole ).to_i & Qt::AlignRight.to_i
61
+ end
62
+
63
+ should 'have a nil parent' do
64
+ assert_nil @model.parent
65
+ end
66
+
67
+ should 'have parent == @model' do
68
+ model = ObjectTableModel.new( :parent => @model, :data => @data, :headers => [ :name, :value, :location, Header.new( :attribute => :price, :alignment => Qt::AlignRight ) ] )
69
+ assert_equal @model, model.parent
70
+ end
71
+
72
+ context 'tree view' do
73
+ should 'have children' do
74
+ model_index = @model.create_index(3,0)
75
+ assert_equal 4, @model.row_count( model_index )
76
+ end
77
+ end
78
+
79
+ def dont_test_show_window
80
+ @main_window.window_title = 'Test ObjectTableModel'
81
+ @main_window.move( 150, 0 )
82
+ @main_window.show
83
+ #~ $app.exec
84
+ end
85
+
86
+ end
@@ -1,104 +1,104 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class Thok < Qt::Widget
4
- signal :whatever
5
- end
6
-
7
- class TestWidget < Test::Unit::TestCase
8
-
9
- def setup
10
- @thok = Thok.new
11
- end
12
-
13
- should 'have a whatever_signal method' do
14
- assert_equal 1, @thok.methods.grep( /^whatever_signal$/ ).size
15
- assert_raise ArgumentError do
16
- @thok.whatever_signal( 'hello' )
17
- end
18
-
19
- assert_nothing_raised do
20
- @thok.whatever_signal( 'hello'.to_variant )
21
- end
22
- end
23
-
24
- should 'have a whatever emitter' do
25
- assert_equal 1, @thok.methods.grep( /^whatever$/ ).size
26
- assert_nothing_raised { @thok.whatever }
27
- assert_nothing_raised { @thok.whatever 1 }
28
- assert_nothing_raised { @thok.whatever 1,2,3 }
29
- assert_nothing_raised { @thok.whatever [4,5,6] }
30
- end
31
-
32
- should 'have an on_whatever handler' do
33
- assert_equal 1, @thok.methods.grep( /^on_whatever$/ ).size
34
- end
35
-
36
- context 'on_whatever handler' do
37
- should 'handle nil args' do
38
- @thok.on_whatever do |arg|
39
- assert_nil arg
40
- end
41
- @thok.whatever
42
- @thok.whatever( nil )
43
- end
44
-
45
- should 'handle single args' do
46
- @thok.on_whatever do |arg|
47
- assert_not_nil arg
48
- assert_not_equal Array, arg.class
49
- end
50
- @thok.whatever 1
51
- @thok.whatever 'hello'
52
- end
53
-
54
- should_eventually 'handle objects' do
55
- NVP = Struct.new :name, :value
56
- nvp = NVP.new
57
- nvp.name = 'how'
58
- nvp.value = 'that'
59
- @thok.on_whatever do |arg|
60
- assert_not_nil arg
61
- assert_equal NVP, arg.class
62
- end
63
- @thok.whatever nvp
64
- end
65
-
66
- should 'handle arg lists' do
67
- @thok.on_whatever do |arg1,arg2|
68
- assert_not_nil arg1
69
- assert_not_nil arg2
70
- assert_not_equal Array, arg1.class
71
- assert_not_equal Array, arg2.class
72
- end
73
- @thok.whatever 1,2
74
- @thok.whatever 'hello','there'
75
- end
76
-
77
- should 'handle a single array' do
78
- @thok.on_whatever do |ary|
79
- assert_not_nil ary
80
- assert_equal Array, ary.class
81
- assert_equal 3, ary.size
82
- assert_equal [4,5,6], ary
83
- end
84
- @thok.whatever [4,5,6]
85
- end
86
-
87
- should_eventually 'handle multiple arrays' do
88
- @thok.on_whatever do |ary1,ary2|
89
- assert_not_nil ary1
90
- assert_not_nil ary2
91
- assert_equal Array, ary1.class
92
- assert_equal Array, ary2.class
93
- assert_equal 3, ary1.size
94
- assert_equal 3, ary2.size
95
- # fails here because ary1 is an array of variants
96
- puts "ary1: #{ary1.inspect}"
97
- assert_equal [4,5,6], ary1
98
- assert_equal [7,8,9], ary2
99
- end
100
- @thok.whatever( [4,5,6], [7,8,9] )
101
- end
102
- end
103
-
104
- end
1
+ require_relative 'test_helper.rb'
2
+
3
+ class Thok < Qt::Widget
4
+ signal :whatever
5
+ end
6
+
7
+ class TestWidget < Test::Unit::TestCase
8
+
9
+ def setup
10
+ @thok = Thok.new
11
+ end
12
+
13
+ should 'have a whatever_signal method' do
14
+ assert_equal 1, @thok.methods.grep( /^whatever_signal$/ ).size
15
+ assert_raise ArgumentError do
16
+ @thok.whatever_signal( 'hello' )
17
+ end
18
+
19
+ assert_nothing_raised do
20
+ @thok.whatever_signal( 'hello'.to_variant )
21
+ end
22
+ end
23
+
24
+ should 'have a whatever emitter' do
25
+ assert_equal 1, @thok.methods.grep( /^whatever$/ ).size
26
+ assert_nothing_raised { @thok.whatever }
27
+ assert_nothing_raised { @thok.whatever 1 }
28
+ assert_nothing_raised { @thok.whatever 1,2,3 }
29
+ assert_nothing_raised { @thok.whatever [4,5,6] }
30
+ end
31
+
32
+ should 'have an on_whatever handler' do
33
+ assert_equal 1, @thok.methods.grep( /^on_whatever$/ ).size
34
+ end
35
+
36
+ context 'on_whatever handler' do
37
+ should 'handle nil args' do
38
+ @thok.on_whatever do |arg|
39
+ assert_nil arg
40
+ end
41
+ @thok.whatever
42
+ @thok.whatever( nil )
43
+ end
44
+
45
+ should 'handle single args' do
46
+ @thok.on_whatever do |arg|
47
+ assert_not_nil arg
48
+ assert_not_equal Array, arg.class
49
+ end
50
+ @thok.whatever 1
51
+ @thok.whatever 'hello'
52
+ end
53
+
54
+ should_eventually 'handle objects' do
55
+ NVP = Struct.new :name, :value
56
+ nvp = NVP.new
57
+ nvp.name = 'how'
58
+ nvp.value = 'that'
59
+ @thok.on_whatever do |arg|
60
+ assert_not_nil arg
61
+ assert_equal NVP, arg.class
62
+ end
63
+ @thok.whatever nvp
64
+ end
65
+
66
+ should 'handle arg lists' do
67
+ @thok.on_whatever do |arg1,arg2|
68
+ assert_not_nil arg1
69
+ assert_not_nil arg2
70
+ assert_not_equal Array, arg1.class
71
+ assert_not_equal Array, arg2.class
72
+ end
73
+ @thok.whatever 1,2
74
+ @thok.whatever 'hello','there'
75
+ end
76
+
77
+ should 'handle a single array' do
78
+ @thok.on_whatever do |ary|
79
+ assert_not_nil ary
80
+ assert_equal Array, ary.class
81
+ assert_equal 3, ary.size
82
+ assert_equal [4,5,6], ary
83
+ end
84
+ @thok.whatever [4,5,6]
85
+ end
86
+
87
+ should_eventually 'handle multiple arrays' do
88
+ @thok.on_whatever do |ary1,ary2|
89
+ assert_not_nil ary1
90
+ assert_not_nil ary2
91
+ assert_equal Array, ary1.class
92
+ assert_equal Array, ary2.class
93
+ assert_equal 3, ary1.size
94
+ assert_equal 3, ary2.size
95
+ # fails here because ary1 is an array of variants
96
+ puts "ary1: #{ary1.inspect}"
97
+ assert_equal [4,5,6], ary1
98
+ assert_equal [7,8,9], ary2
99
+ end
100
+ @thok.whatever( [4,5,6], [7,8,9] )
101
+ end
102
+ end
103
+
104
+ end