weft-qda 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- WEFT_VERSION_STRING = '1.0.0'
1
+ WEFT_VERSION_STRING = '1.0.1'
@@ -213,6 +213,15 @@ module Backend::SQLite
213
213
  raise unless rename_magic
214
214
  magic_rename(doc.title)
215
215
  retry
216
+ # something went wrong with SQLite
217
+ rescue ::SQLite::Exceptions::SQLException => err
218
+ msg = err.message
219
+ if msg =~ /too much data/
220
+ msg = "Document too large to be imported and saved"
221
+ elsif msg =~ /syntax error/
222
+ msg = "Document not in plain text format"
223
+ end
224
+ raise QDA::Backend::BackendError, msg
216
225
  end
217
226
  alias :save_doc :save_document
218
227
 
@@ -72,6 +72,8 @@ module Filters
72
72
  warn 'PDFtotext Version 3 not found in path; ' <<
73
73
  'PDF Filters will not be available'
74
74
  end
75
+ rescue RuntimeError # strange error E_SUCCESS raised in Win98
76
+ warn 'Error running PDFtotext; PDF Filters will not be available'
75
77
  end
76
78
 
77
79
  def read(file)
@@ -115,4 +117,4 @@ module Filters
115
117
  Filters.register_filter(self) if defined?(PDFReader::PDF_TO_TEXT_EXEC)
116
118
  end
117
119
  end
118
- end
120
+ end
@@ -94,7 +94,10 @@ class Query
94
94
  end
95
95
 
96
96
  def calculate()
97
- cat = @app.get_category(@identifier, false) # Will raise NotFoundError
97
+ # TODO - Should raise NotFoundError?
98
+ cat = @app.get_category(@identifier, false)
99
+ raise NotFoundError if not cat
100
+
98
101
  @app.get_text_at_category( cat )
99
102
  rescue NotFoundError => err
100
103
  raise CalculationError,
@@ -296,7 +296,8 @@ module QDA
296
296
  @app.save_reverse_index(doc.dbid, indexer.words, prog)
297
297
  end
298
298
  prog.finish()
299
- rescue FilterError, UserAbortedException, IOError => err
299
+ rescue FilterError, UserAbortedException,
300
+ IOError, QDA::Backend::BackendError => err
300
301
  prog.finish() if prog
301
302
  app.delete_document(doc) if doc && doc.dbid
302
303
  ErrorDialog.display( "Document not imported", err.to_s() )
@@ -196,6 +196,12 @@ module QDA::GUI
196
196
  destination = get_item_data( to )
197
197
  # if for some reason these tree ids didn't correspond to categories...
198
198
  return dont_move(from) unless movee and destination
199
+
200
+ # ensure that the relevant categories are fully loaded inc codes
201
+ movee = @client.app.get_category( movee.dbid )
202
+ # include children
203
+ destination = @client.app.get_category( destination.dbid, true )
204
+
199
205
  # don't move root nodes
200
206
  return dont_move(from) if not movee.parent
201
207
  # ignore if no move - target is same as current parent
@@ -21,9 +21,41 @@ module QDA::GUI
21
21
  [ get_insertion_point() - lines,
22
22
  get_insertion_point() + get_string_selection().length - lines ]
23
23
  end
24
+
25
+ # call this with a block that alters the appearance or content of
26
+ # the text control - this includes call to set_style(), highlight()
27
+ # as well as changing text content. It reduces flicker and keeps the
28
+ # viewable area positioned correctly.
29
+ def save_position()
30
+ freeze()
31
+ saved_pos = get_scroll_pos(Wx::VERTICAL)
32
+
33
+ # calculate how many pixels it moves when we nudge the scrollbar
34
+ # down a 'line'
35
+ scroll_lines(1)
36
+ pos_down = saved_pos - get_scroll_pos(Wx::VERTICAL)
37
+ # calculate how many pixels it moves when we nudge the scrollbar
38
+ # up a 'line'
39
+ scroll_lines(-1)
40
+ pos_up = saved_pos - get_scroll_pos(Wx::VERTICAL)
41
+
42
+ # how long is a 'line'
43
+ movement = 0 - pos_down + pos_up
44
+ yield
45
+ show_position(0)
46
+ if movement > 0
47
+ scroll_lines(saved_pos / movement)
48
+ end
49
+ thaw()
50
+ end
24
51
  else
25
52
  # GTK and Mac OS X
26
53
  NEWLINE_CORRECTION_FACTOR = 0
54
+ # a no-op - scroll_pos always returns 0 on Linux?
55
+ def save_position()
56
+ yield
57
+ end
58
+
27
59
  # a no-op
28
60
  def true_point(point)
29
61
  point
@@ -65,31 +97,7 @@ module QDA::GUI
65
97
  index + adjustment
66
98
  end
67
99
 
68
- # call this with a block that alters the appearance or content of
69
- # the text control - this includes call to set_style(), highlight()
70
- # as well as changing text content. It reduces flicker and keeps the
71
- # viewable area positioned correctly.
72
- def save_position()
73
- freeze()
74
- saved_pos = get_scroll_pos(Wx::VERTICAL)
75
- # calculate how many pixels it moves when we nudge the scrollbar
76
- # down a 'line'
77
- scroll_lines(1)
78
- pos_down = saved_pos - get_scroll_pos(Wx::VERTICAL)
79
- # calculate how many pixels it moves when we nudge the scrollbar
80
- # up a 'line'
81
- scroll_lines(-1)
82
- pos_up = saved_pos - get_scroll_pos(Wx::VERTICAL)
83
-
84
- # how long is a 'line'
85
- movement = 0 - pos_down + pos_up
86
- yield
87
- show_position(0)
88
- if movement > 0
89
- scroll_lines(saved_pos / movement)
90
- end
91
- thaw()
92
- end
100
+
93
101
  end
94
102
 
95
103
 
@@ -48,10 +48,24 @@ class CrashReportDialog < Wx::Dialog
48
48
  Config::CONFIG['MINOR'],
49
49
  Config::CONFIG['TEENY'] ].join('.'),
50
50
  'rs2exe' => rs2exe,
51
- 'backtrace' => ( [ err.inspect ] +
52
- err.backtrace ).join("\n") }
51
+ 'backtrace' => sanitised_backtrace_string(@err) }
53
52
  end
54
-
53
+
54
+ # return a stringified version of the exception backtrace, removing
55
+ # any information about the containing filesystem
56
+ def sanitised_backtrace_string(exception)
57
+ backtrace = [ err.inspect ] + err.backtrace
58
+
59
+ # check where the libraries are being loaded from
60
+ lib_dir = File.expand_path( File.join( File.dirname(__FILE__),
61
+ '..', '..', '..') )
62
+ lib_dir_rx = /#{Regexp.escape(lib_dir)}/
63
+
64
+ # remove this information from backtrace
65
+ backtrace.map! { | line | line.sub(lib_dir_rx, '') }
66
+ backtrace.join("\n")
67
+ end
68
+
55
69
  def crash_details_string
56
70
  %w[when weft_version os config
57
71
  ruby_version rs2exe backtrace].inject('') do | str, key |
@@ -114,9 +114,14 @@ module QDA
114
114
  end
115
115
 
116
116
  def on_save_memo(e)
117
+ old_name, old_memo = @cat.name, @cat.memo
117
118
  @cat.memo = @memo_box.value
118
119
  @cat.name = @name_field.value
119
120
  Wx::BusyCursor.busy { @client.app.save_category( @cat ) }
121
+ rescue NotUniqueNameError
122
+ ErrorDialog.display( Lang::DUPLICATE_CATEGORY_NAME_TITLE,
123
+ Lang::DUPLICATE_CATEGORY_NAME_WARNING )
124
+ @cat.name, @cat.memo = old_name, old_memo
120
125
  end
121
126
 
122
127
  def on_change_page(e)
@@ -27,7 +27,7 @@ module QDA::GUI
27
27
  evt_grid_label_left_click() { | evt | on_label_clicked(evt) }
28
28
  evt_grid_cell_left_dclick() { | evt | on_cell_dclicked(evt) }
29
29
  # the controls panel
30
- main_sizer.add(@grid, 1, Wx::GROW|Wx::ALL, 4)
30
+
31
31
  # butt_panel = Wx::Panel.new(panel, -1)
32
32
  butt_box_label = Wx::StaticBox.new(panel, -1, 'Select categories')
33
33
  bott_sizer = Wx::StaticBoxSizer.new(butt_box_label,
@@ -56,6 +56,7 @@ module QDA::GUI
56
56
  main_sizer.add(bott_sizer, 0,
57
57
  Wx::GROW|Wx::ADJUST_MINSIZE|Wx::ALL, 4)
58
58
 
59
+
59
60
  # the numbers row
60
61
  num_box_label = Wx::StaticBox.new(panel, -1,
61
62
  Lang::DISPLAY_OPTIONS_LABEL)
@@ -63,8 +64,8 @@ module QDA::GUI
63
64
  Wx::HORIZONTAL)
64
65
 
65
66
  # num_cbox = Wx::CheckBox.new(num_panel, -1, 'Show numbers')
66
- num_sizer.add( Wx::StaticText.new(panel, -1, 'Count what?'),
67
- 0, Wx::ALL|Wx::ALIGN_RIGHT, 4)
67
+ # num_sizer.add( Wx::StaticText.new(panel, -1, 'Count what?'),
68
+ # 0, Wx::ALL|Wx::ALIGN_RIGHT, 4)
68
69
  @num_list = Wx::Choice.new(panel, -1)
69
70
  @num_list.append('Number of documents')
70
71
  @num_list.append('Number of passages')
@@ -74,9 +75,10 @@ module QDA::GUI
74
75
  num_sizer.add(@num_list, 0, Wx::ALL, 4)
75
76
 
76
77
  main_sizer.add( num_sizer, 0,
77
- Wx::GROW|Wx::ADJUST_MINSIZE|Wx::ALL,
78
- 4)
79
-
78
+ Wx::GROW|Wx::ADJUST_MINSIZE|Wx::ALL, 4)
79
+ main_sizer.add(@grid, 1, Wx::GROW|Wx::ALL, 4)
80
+
81
+
80
82
  panel.set_sizer(main_sizer)
81
83
  main_sizer.set_size_hints(panel)
82
84
 
@@ -55,6 +55,9 @@ module QDA::GUI
55
55
  funcs[i].string_selection = 'CONTAINS WORD'
56
56
  args[i].show( 1 )
57
57
  args[i].visible_item.value = func.word
58
+ else
59
+ Kernel.raise ArgumentError,
60
+ "Unexpected function value #{func.inspect} in query"
58
61
  end
59
62
 
60
63
 
@@ -339,10 +339,11 @@ class TestCode < Test::Unit::TestCase
339
339
 
340
340
  tbl_2 = CodingTable.new()
341
341
  result = tbl_2.merge(tbl)
342
- assert( tbl_2.key?(3) )
343
- assert_equal(1, tbl_2.num_of_docs)
344
- assert_equal(6, tbl_2.num_of_chars)
345
- assert_equal(1, tbl_2.num_of_codes)
342
+ # assert( tbl_2.key?(3) )
343
+ assert_equal(0, tbl_2.num_of_docs)
344
+ assert_equal(1, result.num_of_docs)
345
+ assert_equal(6, result.num_of_chars)
346
+ assert_equal(1, result.num_of_codes)
346
347
  end
347
348
 
348
349
  def test_fragment_table
@@ -22,7 +22,18 @@ class FakeClient < Wx::App
22
22
  @app = QDA::Application.new( QDA::Backend::SQLite )
23
23
  @app.start(:dbfile => sample_file('empty.qdp') )
24
24
  def @app.get_category(arg, maybe = nil)
25
- return QDA::Category.new(arg, nil)
25
+ case arg
26
+ when String
27
+ cat = QDA::Category.new(arg, nil)
28
+ def cat.dbid()
29
+ __id__
30
+ end
31
+ when Integer
32
+ cat = ObjectSpace._id2ref(arg)
33
+ else
34
+ raise ArgumentError, "Can't fetch #{arg}"
35
+ end
36
+ cat
26
37
  end
27
38
  end
28
39
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: weft-qda
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2006-02-17
6
+ version: 1.0.1
7
+ date: 2006-04-26
8
8
  summary: GUI Qualitative Data Analysis Tool.
9
9
  require_paths:
10
10
  - lib