qtext 0.6.2 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/config/hoe.rb +1 -1
- data/lib/qtext/extensions.rb +45 -32
- data/lib/qtext/version.rb +1 -1
- metadata +7 -5
data/History.txt
CHANGED
data/config/hoe.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'qtext/version'
|
2
2
|
|
3
|
-
AUTHOR = '
|
3
|
+
AUTHOR = 'John Anderson' # can also be an array of Authors
|
4
4
|
EMAIL = "panic@semiosix.com"
|
5
5
|
DESCRIPTION = "description of gem"
|
6
6
|
GEM_NAME = 'qtext' # what ppl will type to install your gem
|
data/lib/qtext/extensions.rb
CHANGED
@@ -57,8 +57,16 @@ module Qt
|
|
57
57
|
# Return the value of the block
|
58
58
|
def override_cursor( cursor_constant, &block )
|
59
59
|
Qt::Application.setOverrideCursor( Qt::Cursor.new( cursor_constant ) )
|
60
|
-
|
60
|
+
exception = nil
|
61
|
+
begin
|
62
|
+
retval = yield
|
63
|
+
rescue Exception => e
|
64
|
+
#~ puts e.message
|
65
|
+
#~ puts e.backtrace
|
66
|
+
exception = e
|
67
|
+
end
|
61
68
|
Qt::Application.restoreOverrideCursor
|
69
|
+
Kernel.raise exception unless exception.nil?
|
62
70
|
retval
|
63
71
|
end
|
64
72
|
end
|
@@ -106,6 +114,26 @@ module Qt
|
|
106
114
|
|
107
115
|
# can't alias this because it doesn't work with Qt bindings
|
108
116
|
def size; self.count; end
|
117
|
+
|
118
|
+
def first
|
119
|
+
self.at(0)
|
120
|
+
end
|
121
|
+
|
122
|
+
def last
|
123
|
+
self.at(count-1)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
class ItemSelectionModel
|
128
|
+
# return a set of indexes with the given column index and the rows
|
129
|
+
# from the selection
|
130
|
+
def row_indexes( column = 0 )
|
131
|
+
row_set = selected_indexes.inject(Set.new) do |set,index|
|
132
|
+
set << index.row
|
133
|
+
end
|
134
|
+
|
135
|
+
row_set.map{|row| model.create_index( row, column ) }
|
136
|
+
end
|
109
137
|
end
|
110
138
|
|
111
139
|
class ItemSelectionRange
|
@@ -158,6 +186,10 @@ module Qt
|
|
158
186
|
# new_index = index.choppy { |i| i.row += 1 }
|
159
187
|
# new_index = index.choppy :row => 16
|
160
188
|
# same_index = index.choppy
|
189
|
+
#
|
190
|
+
# If the column value is not a Numeric, a method called field_column
|
191
|
+
# will be called on the model with column value. field_column should return
|
192
|
+
# the column index.
|
161
193
|
def choppy( *args, &block )
|
162
194
|
return ModelIndex.invalid unless self.valid?
|
163
195
|
|
@@ -176,6 +208,11 @@ module Qt
|
|
176
208
|
raise TypeError.new( "incorrect args #{args.inspect}" )
|
177
209
|
end
|
178
210
|
|
211
|
+
# convert a column name to a column index
|
212
|
+
unless stash.column.is_a?( Numeric )
|
213
|
+
stash.column = model.field_column( stash.column )
|
214
|
+
end
|
215
|
+
|
179
216
|
# return an invalid index if it's out of bounds,
|
180
217
|
# or the choppy'd index if it's OK.
|
181
218
|
if stash.row >= model.row_count || stash.column >= model.column_count
|
@@ -189,24 +226,6 @@ module Qt
|
|
189
226
|
# Make keystrokes events easier to work with. For <tt>Qt::Key_Whatever</tt>
|
190
227
|
# events, KeyEvent instances will now respond to <tt>whatever?</tt>
|
191
228
|
class KeyEvent
|
192
|
-
# override otherwise the new method_missing fails
|
193
|
-
# to call the old_method_missing
|
194
|
-
def modifiers
|
195
|
-
old_method_missing( :modifiers )
|
196
|
-
end
|
197
|
-
|
198
|
-
# override otherwise the new method_missing fails
|
199
|
-
# to call the old_method_missing
|
200
|
-
def key
|
201
|
-
old_method_missing( :key )
|
202
|
-
end
|
203
|
-
|
204
|
-
# override otherwise the new method_missing fails
|
205
|
-
# to call the old_method_missing
|
206
|
-
def text
|
207
|
-
old_method_missing( :text )
|
208
|
-
end
|
209
|
-
|
210
229
|
# is the control key pressed?
|
211
230
|
def ctrl?
|
212
231
|
modifiers & Qt::ControlModifier.to_i == Qt::ControlModifier.to_i
|
@@ -215,15 +234,15 @@ module Qt
|
|
215
234
|
alias_method :old_method_missing, :method_missing
|
216
235
|
|
217
236
|
# Provide a shortcut for the Qt::Key_Whatever constants. Just say event.whatever?
|
218
|
-
def method_missing( sym, *args )
|
237
|
+
def method_missing( sym, *args, &block )
|
219
238
|
begin
|
220
239
|
if sym.to_s[-1] == "?"[0]
|
221
240
|
key?( sym.to_s[0..-2] )
|
222
241
|
else
|
223
|
-
old_method_missing( sym, args )
|
242
|
+
old_method_missing( sym, *args, &block )
|
224
243
|
end
|
225
244
|
rescue Exception => e
|
226
|
-
old_method_missing( sym, args )
|
245
|
+
old_method_missing( sym, *args, &block )
|
227
246
|
end
|
228
247
|
end
|
229
248
|
|
@@ -255,23 +274,17 @@ module Qt
|
|
255
274
|
end
|
256
275
|
|
257
276
|
class TabWidget
|
258
|
-
|
259
|
-
def
|
260
|
-
|
261
|
-
(0...self.count).each do |i|
|
262
|
-
yield( self.widget(i) )
|
263
|
-
end
|
277
|
+
# return the collection of tabs.
|
278
|
+
def tabs
|
279
|
+
tabs = (0...count).map{|i| self.widget( i ) }
|
264
280
|
end
|
265
|
-
alias_method :each, :each_tab
|
266
|
-
# can't alias this because it doesn't work with Qt bindings
|
267
|
-
def size; self.count; end
|
268
281
|
|
269
282
|
def []( index )
|
270
283
|
self.widget( index )
|
271
284
|
end
|
272
285
|
|
273
286
|
def clear
|
274
|
-
remove_tab(
|
287
|
+
remove_tab( count - 1 ) while count > 0
|
275
288
|
end
|
276
289
|
end
|
277
290
|
|
data/lib/qtext/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qtext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- John Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-02 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -62,6 +62,8 @@ files:
|
|
62
62
|
- test/test_widget.rb
|
63
63
|
has_rdoc: true
|
64
64
|
homepage: http://qtext.rubyforge.org
|
65
|
+
licenses: []
|
66
|
+
|
65
67
|
post_install_message: ""
|
66
68
|
rdoc_options:
|
67
69
|
- --main
|
@@ -83,9 +85,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
85
|
requirements: []
|
84
86
|
|
85
87
|
rubyforge_project: qtext
|
86
|
-
rubygems_version: 1.3.
|
88
|
+
rubygems_version: 1.3.5
|
87
89
|
signing_key:
|
88
|
-
specification_version:
|
90
|
+
specification_version: 3
|
89
91
|
summary: description of gem
|
90
92
|
test_files:
|
91
93
|
- test/test_model_index_extensions.rb
|