clevic 0.13.0.b1 → 0.13.0.b2

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.
data/Manifest.txt CHANGED
@@ -27,121 +27,16 @@ test/test_order_attribute.rb
27
27
  test/test_sql_dialects.rb
28
28
  test/test_table_model.rb
29
29
  test/test_table_searcher.rb
30
+ lib/clevic.rb
30
31
  lib/clevic/qt/ui/browser.ui
31
32
  lib/clevic/qt/ui/search_dialog_ui.rb
32
33
  lib/clevic/qt/ui/search_dialog.ui
33
34
  lib/clevic/qt/ui/browser_ui.rb
35
+ lib/clevic/qt/model_builder.rb
34
36
  lib/clevic/qt/table_model.rb
35
37
  lib/clevic/qt/text_area_delegate.rb
36
38
  lib/clevic/qt/browser.rb
37
- lib/clevic/qt/action_builder.rb
38
- lib/clevic/qt/field.rb
39
- lib/clevic/qt/set_delegate.rb
40
- lib/clevic/qt/item_delegate.rb
41
- lib/clevic/qt/clipboard.rb
42
- lib/clevic/qt/text_delegate.rb
43
- lib/clevic/qt/distinct_delegate.rb
44
- lib/clevic/qt/boolean_delegate.rb
45
- lib/clevic/qt/table_view.rb
46
- lib/clevic/qt/search_dialog.rb
47
- lib/clevic/qt/combo_delegate.rb
48
- lib/clevic/qt/extensions.rb
49
- lib/clevic/qt/delegates.rb
50
- lib/clevic/qt/relational_delegate.rb
51
- lib/clevic/table_view_paste.rb
52
- lib/clevic/sequel_ar_adapter.rb
53
- lib/clevic/model_builder.rb
54
- lib/clevic/rails_models_loaders.rb
55
- lib/clevic/sequel_length_validation.rb
56
- lib/clevic/cache_table.rb
57
- lib/clevic/table_model.rb
58
- lib/clevic/icons
59
- lib/clevic/icons/icon.png
60
- lib/clevic/qt.rb
61
- lib/clevic/swing
62
- lib/clevic/swing/ui
63
- lib/clevic/swing/ui/src
64
- lib/clevic/swing/ui/src/SearchDialog.form
65
- lib/clevic/swing/ui/src/SearchDialog.java
66
- lib/clevic/swing/ui/src/resources
67
- lib/clevic/swing/ui/src/resources/SearchDialog.properties
68
- lib/clevic/swing/ui/src/TagEditor.form
69
- lib/clevic/swing/ui/src/TagEditor.java
70
- lib/clevic/swing/ui/dist
71
- lib/clevic/swing/ui/dist/lib
72
- lib/clevic/swing/ui/dist/lib/swing-layout-1.0.3.jar
73
- lib/clevic/swing/ui/dist/README.TXT
74
- lib/clevic/swing/ui/nbproject
75
- lib/clevic/swing/ui/nbproject/genfiles.properties
76
- lib/clevic/swing/ui/nbproject/build-impl.xml
77
- lib/clevic/swing/ui/nbproject/project.xml
78
- lib/clevic/swing/ui/nbproject/project.properties
79
- lib/clevic/swing/ui/nbproject/private
80
- lib/clevic/swing/ui/nbproject/private/private.properties
81
- lib/clevic/swing/ui/nbproject/private/config.properties
82
- lib/clevic/swing/ui/nbproject/private/private.xml
83
- lib/clevic/swing/ui/build.xml
84
- lib/clevic/swing/ui/manifest.mf
85
- lib/clevic/swing/table_model.rb
86
- lib/clevic/swing/text_area_delegate.rb
87
- lib/clevic/swing/browser.rb
88
- lib/clevic/swing/cell_renderer.rb
89
- lib/clevic/swing/tag_editor.rb
90
- lib/clevic/swing/action_builder.rb
91
- lib/clevic/swing/field.rb
92
- lib/clevic/swing/set_delegate.rb
93
- lib/clevic/swing/clipboard.rb
94
- lib/clevic/swing/text_delegate.rb
95
- lib/clevic/swing/tag_delegate.rb
96
- lib/clevic/swing/selection_model.rb
97
- lib/clevic/swing/distinct_delegate.rb
98
- lib/clevic/swing/boolean_delegate.rb
99
- lib/clevic/swing/confirm_dialog.rb
100
- lib/clevic/swing/table_view.rb
101
- lib/clevic/swing/search_dialog.rb
102
- lib/clevic/swing/combo_delegate.rb
103
- lib/clevic/swing/swing_table_index.rb
104
- lib/clevic/swing/table_view_focus.rb
105
- lib/clevic/swing/cell_editor.rb
106
- lib/clevic/swing/extensions.rb
107
- lib/clevic/swing/delegate.rb
108
- lib/clevic/swing/action.rb
109
- lib/clevic/swing/relational_delegate.rb
110
- lib/clevic/swing/row_header.rb
111
- lib/clevic/ar_methods.rb
112
- lib/clevic/swing.rb
113
- lib/clevic/action_builder.rb
114
- lib/clevic/order_attribute.rb
115
- lib/clevic/dirty.rb
116
- lib/clevic/field.rb
117
- lib/clevic/attribute_list.rb
118
- lib/clevic/record.rb
119
- lib/clevic/sampler.rb
120
- lib/clevic/model_column.rb
121
- lib/clevic/table_searcher.rb
122
- lib/clevic/table_view.rb
123
- lib/clevic/field_valuer.rb
124
- lib/clevic/sequel_naked.rb
125
- lib/clevic/table_index.rb
126
- lib/clevic/view.rb
127
- lib/clevic/sequel_meta.rb
128
- lib/clevic/extensions.rb
129
- lib/clevic/delegate.rb
130
- lib/clevic/sql_dialects.rb
131
- lib/clevic/default_view.rb
132
- lib/clevic/many_field.rb
133
- lib/clevic/filter_command.rb
134
- lib/clevic/version.rb
135
- lib/clevic/generic_format.rb
136
- lib/clevic/emitter.rb
137
- lib/clevic/qt/ui/browser.ui
138
- lib/clevic/qt/ui/.gitignore
139
- lib/clevic/qt/ui/search_dialog_ui.rb
140
- lib/clevic/qt/ui/search_dialog.ui
141
- lib/clevic/qt/ui/browser_ui.rb
142
- lib/clevic/qt/table_model.rb
143
- lib/clevic/qt/text_area_delegate.rb
144
- lib/clevic/qt/browser.rb
39
+ lib/clevic/qt/accept_reject.rb
145
40
  lib/clevic/qt/action_builder.rb
146
41
  lib/clevic/qt/field.rb
147
42
  lib/clevic/qt/set_delegate.rb
@@ -181,6 +76,7 @@ lib/clevic/swing/ui/nbproject/private/config.properties
181
76
  lib/clevic/swing/ui/nbproject/private/private.xml
182
77
  lib/clevic/swing/ui/build.xml
183
78
  lib/clevic/swing/ui/manifest.mf
79
+ lib/clevic/swing/model_builder.rb
184
80
  lib/clevic/swing/table_model.rb
185
81
  lib/clevic/swing/text_area_delegate.rb
186
82
  lib/clevic/swing/browser.rb
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ $hoe = Hoe.new('clevic', Clevic::VERSION::STRING) do |p|
7
7
  p.developer('John Anderson', 'panic@semiosix.com')
8
8
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
9
  p.rubyforge_name = p.name # TODO this is default value
10
- p.description = "SQL table GUI with Qt, Swing, Sequel"
10
+ p.description = "SQL table GUI with Qt / Java Swing and Sequel"
11
11
  p.extra_deps = [
12
12
  ['activesupport','>= 2.0.2'],
13
13
  ['fastercsv', '>=1.2.3'],
data/TODO CHANGED
@@ -1,4 +1,5 @@
1
1
  use Sequel::Dataset for filtering instead of find options
2
+ can't use find on certain fields, ie code in adjustments
2
3
 
3
4
  export to CSV
4
5
  Accounts not landing after Ditto with auto-fill-in
data/lib/clevic.rb ADDED
@@ -0,0 +1,13 @@
1
+ # This provides enough to define UIs.
2
+
3
+ module Clevic
4
+ def self.base_entity_class
5
+ Sequel::Model
6
+ end
7
+ end
8
+
9
+ require 'clevic/sequel_ar_adapter.rb'
10
+ require 'clevic/sequel_length_validation.rb'
11
+ require 'clevic/record.rb'
12
+ require 'clevic/view.rb'
13
+ require 'clevic/sequel_meta.rb'
@@ -49,7 +49,7 @@ class CacheTable < Array
49
49
  # If no order attributes are specified, the primary key will be used.
50
50
  # TODO what about compound primary keys?
51
51
  def order_attributes
52
- # This is sorted in @options[:order], so use that for the search
52
+ # This is sorted in @find_options[:order], so use that for the search
53
53
  if @order_attributes.nil?
54
54
  @order_attributes = find_options[:order].to_s.split( /, */ ).map{|x| OrderAttribute.new(@entity_class, x)}
55
55
 
@@ -438,13 +438,13 @@ class ModelBuilder
438
438
  # an ordinary field, edited in place with a text box
439
439
  def plain( attribute, options = {}, &block )
440
440
  read_only_default!( attribute, options )
441
- field = @fields[attribute] = Clevic::Field.new( attribute.to_sym, entity_class, options, &block )
442
- field.delegate =
443
- if field.meta.type == :boolean
444
- BooleanDelegate.new( field )
445
- else
446
- TextDelegate.new( field )
447
- end
441
+ field = Clevic::Field.new( attribute.to_sym, entity_class, options, &block )
442
+
443
+ # plain_delegate will be defined in a framework-specific file.
444
+ # This is becoming a kind of poor man's inheritance. I don't
445
+ # think I like that.
446
+ field.delegate = plain_delegate( field )
447
+ @fields[attribute] = field
448
448
  end
449
449
 
450
450
  # an ordinary field like plain, except that a larger edit area can be used
data/lib/clevic/qt.rb CHANGED
@@ -7,6 +7,8 @@ require 'pathname'
7
7
  # require these first, so TableModel and TableView get the correct ancestors
8
8
  require 'clevic/qt/table_model.rb'
9
9
  require 'clevic/qt/table_view.rb'
10
+
11
+ # all other files in the qt subdirectory
10
12
  ( Pathname.new( __FILE__ ).parent + 'qt' ).children.grep( /.rb$/ ).each do |child|
11
13
  require child.to_s
12
14
  end
@@ -15,21 +17,3 @@ end
15
17
  require 'clevic/table_model'
16
18
  require 'clevic/table_view'
17
19
  require 'clevic.rb'
18
-
19
- module Clevic
20
-
21
- def self.tahoma
22
- if @font.nil?
23
- @font =
24
- begin
25
- found = java.awt.GraphicsEnvironment.local_graphics_environment.all_fonts.select {|f| f.font_name == "Tahoma"}.first
26
- found.deriveFont( 13.0 )
27
- java.awt.Font.new( 'DialogInput', java.awt.Font::PLAIN, 13 )
28
- rescue
29
- java.awt.Font.new( 'DialogInput', java.awt.Font::PLAIN, 13 )
30
- end
31
- end
32
- @font
33
- end
34
-
35
- end
@@ -0,0 +1,12 @@
1
+ # Qt-specific accept/reject. Including class must provide #result
2
+ module Clevic
3
+ module AcceptReject
4
+ def accepted?
5
+ [ Qt::Dialog::Accepted, Qt::MessageBox::Yes, Qt::MessageBox::Ok ].include?( result )
6
+ end
7
+
8
+ def rejected?
9
+ [ Qt::Dialog::Rejected, Qt::MessageBox::No, Qt::MessageBox::Cancel ].include?( result )
10
+ end
11
+ end
12
+ end
@@ -2,6 +2,7 @@ require 'set'
2
2
 
3
3
  require 'qtext/flags.rb'
4
4
  require 'clevic/table_index.rb'
5
+ require 'clevic/qt/accept_reject'
5
6
 
6
7
  # convenience methods
7
8
  module Qt
@@ -41,12 +42,6 @@ module Qt
41
42
 
42
43
  # implement accepted? and rejected? for TableView#confirm_dialog and friends
43
44
  class MessageBox
44
- def accepted?
45
- [ Qt::Dialog::Accepted, Qt::MessageBox::Yes, Qt::MessageBox::Ok ].include?( result )
46
- end
47
-
48
- def rejected?
49
- [ Qt::Dialog::Rejected, Qt::MessageBox::No, Qt::MessageBox::Cancel ].include?( result )
50
- end
45
+ include Clevic::AcceptReject
51
46
  end
52
47
  end
@@ -0,0 +1,9 @@
1
+ module Clevic
2
+
3
+ class ModelBuilder
4
+ # no special delegate needed for Qt
5
+ def plain_delegate( field )
6
+ end
7
+ end
8
+
9
+ end
@@ -1,14 +1,18 @@
1
1
  require 'Qt4'
2
2
  require 'clevic/qt/ui/search_dialog_ui.rb'
3
3
  require 'qtext/flags.rb'
4
+ require 'clevic/qt/accept_reject.rb'
4
5
 
5
6
  module Clevic
6
7
 
7
8
  class SearchDialog
9
+ include AcceptReject
8
10
  include QtFlags
11
+
9
12
  attr_reader :match_flags, :layout
13
+ attr_accessor :result
10
14
 
11
- def initialize
15
+ def initialize( parent )
12
16
  @layout = Ui_SearchDialog.new
13
17
  @dialog = Qt::Dialog.new
14
18
  @layout.setupUi( @dialog )
@@ -52,14 +56,14 @@ module Clevic
52
56
  def exec( text = '' )
53
57
  search_combo.edit_text = text.to_s
54
58
  search_combo.set_focus
55
- retval = @dialog.exec
59
+ self.result = @dialog.exec
56
60
 
57
61
  # remember previous searches
58
62
  if search_combo.find_text( search_combo.current_text ) == -1
59
63
  search_combo.add_item( search_combo.current_text )
60
64
  end
61
65
 
62
- retval
66
+ self
63
67
  end
64
68
 
65
69
  def search_text
@@ -136,11 +136,13 @@ class TableModel < Qt::AbstractTableModel
136
136
  when qt_background_role
137
137
  if orientation == Qt::Vertical
138
138
  item = collection[section]
139
- case
140
- when !item.errors.empty?
141
- Qt::Color.new( 'orange' )
142
- when item.changed?
143
- Qt::Color.new( 'yellow' )
139
+ unless item.nil?
140
+ case
141
+ when !item.errors.empty?
142
+ Qt::Color.new( 'orange' )
143
+ when item.changed?
144
+ Qt::Color.new( 'yellow' )
145
+ end
144
146
  end
145
147
  end
146
148
 
@@ -236,20 +238,19 @@ class TableModel < Qt::AbstractTableModel
236
238
  end
237
239
 
238
240
  begin
239
- index.attribute_value =
240
241
  case
241
- when value.class.name == 'Qt::Date'
242
- Date.new( value.year, value.month, value.day )
242
+ when variant.class.name == 'Qt::Date'
243
+ index.attribute_value = Date.new( variant.year, variant.month, variant.day )
243
244
 
244
- when value.class.name == 'Qt::Time'
245
- Time.new( value.hour, value.min, value.sec )
245
+ when variant.class.name == 'Qt::Time'
246
+ index.attribute_value = Time.new( variant.hour, variant.min, variant.sec )
246
247
 
247
248
  else
248
- translate_to_db_object( index, variant.value )
249
+ index.edit_value = variant.value
249
250
  end
250
251
 
251
252
  # value conversion was successful
252
- data_changed( table_index )
253
+ data_changed( index )
253
254
  true
254
255
  rescue Exception => e
255
256
  puts e.backtrace.join( "\n" )
@@ -261,7 +262,7 @@ class TableModel < Qt::AbstractTableModel
261
262
 
262
263
  when qt_checkstate_role
263
264
  if index.meta.type == :boolean
264
- index.entity.toggle( index.attribute )
265
+ index.attribute_value = !index.attribute_value
265
266
  true
266
267
  else
267
268
  false
@@ -42,8 +42,15 @@ class TableView < Qt::TableView
42
42
  # TODO might be useful to allow movable vertical rows,
43
43
  # but need to change the shortcut ideas of next and previous rows
44
44
  self.vertical_header.movable = false
45
+ self.vertical_header.default_alignment = Qt::AlignTop | Qt::AlignRight
45
46
  self.sorting_enabled = false
46
47
 
48
+ # set fonts
49
+ Qt::Font.new( font.family, font.point_size * 5 / 6 ).tap do |fnt|
50
+ self.font = fnt
51
+ self.horizontal_header.font = fnt
52
+ end
53
+
47
54
  self.context_menu_policy = Qt::ActionsContextMenu
48
55
  end
49
56
 
@@ -93,28 +100,38 @@ class TableView < Qt::TableView
93
100
  self.set_column_width( col, column_size( col, sample ).width )
94
101
  end
95
102
 
103
+ def metrics
104
+ @metrics = Qt::FontMetrics.new( font )
105
+ end
106
+
96
107
  # set the size of the column from the string value of the data
97
108
  # mostly copied from qheaderview.cpp:2301
98
109
  def column_size( col, data )
99
110
  opt = Qt::StyleOptionHeader.new
100
111
 
101
112
  # fetch font size
102
- fnt = font
103
- fnt.bold = true
104
- opt.fontMetrics = Qt::FontMetrics.new( fnt )
113
+ opt.fontMetrics = metrics
114
+ opt.rect = opt.fontMetrics.bounding_rect( data.to_s )
105
115
 
106
116
  # set data
107
117
  opt.text = data.to_s
108
118
 
109
- # icon size. Not needed
110
- #~ variant = d->model->headerData(logicalIndex, d->orientation, Qt::DecorationRole);
111
- #~ opt.icon = qvariant_cast<QIcon>(variant);
112
- #~ if (opt.icon.isNull())
113
- #~ opt.icon = qvariant_cast<QPixmap>(variant);
119
+ opt.section =
120
+ case
121
+ when col == 0
122
+ Qt::StyleOptionHeader::Beginning
123
+
124
+ when col > 0 && col < model.fields.size - 1
125
+ Qt::StyleOptionHeader::Middle
126
+
127
+ when col == model.fields.size - 1
128
+ Qt::StyleOptionHeader::End
129
+ end
130
+
131
+ size = Qt::Size.new( opt.fontMetrics.width( data.to_s ), opt.fontMetrics.height )
114
132
 
115
- size = Qt::Size.new( 100, 30 )
116
133
  # final parameter could be header section
117
- style.sizeFromContents( Qt::Style::CT_HeaderSection, opt, size );
134
+ style.sizeFromContents( Qt::Style::CT_HeaderSection, opt, size )
118
135
  end
119
136
 
120
137
  # make sure row size is correct
@@ -124,7 +141,8 @@ class TableView < Qt::TableView
124
141
  @model = model
125
142
 
126
143
  # make sure we get nice spacing
127
- vertical_header.default_section_size = vertical_header.minimum_section_size
144
+ vertical_header.default_section_size = metrics.height
145
+ vertical_header.minimum_section_size = metrics.height
128
146
  super
129
147
 
130
148
  # set delegates
@@ -233,6 +251,8 @@ class TableView < Qt::TableView
233
251
  super
234
252
  save_current_row if @hiding
235
253
  rescue
254
+ puts $!.message
255
+ puts $!.backtrace
236
256
  show_error "Error saving data from #{editor.inspect}: #{$!.message}"
237
257
  end
238
258
 
@@ -0,0 +1,133 @@
1
+ =begin
2
+ ** Form generated from reading ui file 'browser.ui'
3
+ **
4
+ ** Created: Mon Jan 24 21:13:34 2011
5
+ ** by: Qt User Interface Compiler version 4.5.1
6
+ **
7
+ ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
+ =end
9
+
10
+ class Ui_Browser
11
+ attr_reader :action_open
12
+ attr_reader :action_close
13
+ attr_reader :action_recent
14
+ attr_reader :action_dump
15
+ attr_reader :action_refresh
16
+ attr_reader :action_next
17
+ attr_reader :action_previous
18
+ attr_reader :action_new_window
19
+ attr_reader :main_widget
20
+ attr_reader :vboxLayout
21
+ attr_reader :statusbar
22
+ attr_reader :menubar
23
+ attr_reader :menu_file
24
+ attr_reader :menu_edit
25
+ attr_reader :menu_search
26
+ attr_reader :menu_model
27
+
28
+ def setupUi(browser)
29
+ if browser.objectName.nil?
30
+ browser.objectName = "browser"
31
+ end
32
+ browser.resize(727, 740)
33
+ icon = Qt::Icon.new("icon.png")
34
+ browser.windowIcon = icon
35
+ @action_open = Qt::Action.new(browser)
36
+ @action_open.objectName = "action_open"
37
+ @action_open.visible = false
38
+ @action_close = Qt::Action.new(browser)
39
+ @action_close.objectName = "action_close"
40
+ @action_close.visible = false
41
+ @action_recent = Qt::Action.new(browser)
42
+ @action_recent.objectName = "action_recent"
43
+ @action_recent.visible = false
44
+ @action_dump = Qt::Action.new(browser)
45
+ @action_dump.objectName = "action_dump"
46
+ @action_refresh = Qt::Action.new(browser)
47
+ @action_refresh.objectName = "action_refresh"
48
+ @action_next = Qt::Action.new(browser)
49
+ @action_next.objectName = "action_next"
50
+ @action_previous = Qt::Action.new(browser)
51
+ @action_previous.objectName = "action_previous"
52
+ @action_new_window = Qt::Action.new(browser)
53
+ @action_new_window.objectName = "action_new_window"
54
+ @action_new_window.visible = false
55
+ @main_widget = Qt::Widget.new(browser)
56
+ @main_widget.objectName = "main_widget"
57
+ @vboxLayout = Qt::VBoxLayout.new(@main_widget)
58
+ @vboxLayout.objectName = "vboxLayout"
59
+ browser.centralWidget = @main_widget
60
+ @statusbar = Qt::StatusBar.new(browser)
61
+ @statusbar.objectName = "statusbar"
62
+ browser.statusBar = @statusbar
63
+ @menubar = Qt::MenuBar.new(browser)
64
+ @menubar.objectName = "menubar"
65
+ @menubar.geometry = Qt::Rect.new(0, 0, 727, 31)
66
+ @menu_file = Qt::Menu.new(@menubar)
67
+ @menu_file.objectName = "menu_file"
68
+ @menu_file.enabled = false
69
+ @menu_edit = Qt::Menu.new(@menubar)
70
+ @menu_edit.objectName = "menu_edit"
71
+ @menu_search = Qt::Menu.new(@menubar)
72
+ @menu_search.objectName = "menu_search"
73
+ @menu_model = Qt::Menu.new(@menubar)
74
+ @menu_model.objectName = "menu_model"
75
+ browser.setMenuBar(@menubar)
76
+
77
+ @menubar.addAction(@menu_file.menuAction())
78
+ @menubar.addAction(@menu_edit.menuAction())
79
+ @menubar.addAction(@menu_search.menuAction())
80
+ @menubar.addAction(@menu_model.menuAction())
81
+ @menu_file.addAction(@action_open)
82
+ @menu_file.addAction(@action_close)
83
+ @menu_file.addAction(@action_recent)
84
+ @menu_file.addAction(@action_new_window)
85
+ @menu_model.addAction(@action_next)
86
+ @menu_model.addAction(@action_previous)
87
+ @menu_model.addAction(@action_dump)
88
+ @menu_model.addSeparator()
89
+
90
+ retranslateUi(browser)
91
+
92
+ Qt::MetaObject.connectSlotsByName(browser)
93
+ end # setupUi
94
+
95
+ def setup_ui(browser)
96
+ setupUi(browser)
97
+ end
98
+
99
+ def retranslateUi(browser)
100
+ @action_open.text = Qt::Application.translate("Browser", "&Open", nil, Qt::Application::UnicodeUTF8)
101
+ @action_close.text = Qt::Application.translate("Browser", "&Close", nil, Qt::Application::UnicodeUTF8)
102
+ @action_recent.text = Qt::Application.translate("Browser", "&Recent", nil, Qt::Application::UnicodeUTF8)
103
+ @action_dump.text = Qt::Application.translate("Browser", "&Dump", nil, Qt::Application::UnicodeUTF8)
104
+ @action_dump.shortcut = Qt::Application.translate("Browser", "Alt+Shift+D", nil, Qt::Application::UnicodeUTF8)
105
+ @action_refresh.text = Qt::Application.translate("Browser", "&Refresh", nil, Qt::Application::UnicodeUTF8)
106
+ @action_refresh.iconText = Qt::Application.translate("Browser", "Refresh current table from database", nil, Qt::Application::UnicodeUTF8)
107
+ @action_refresh.toolTip = Qt::Application.translate("Browser", "Refresh current table from database", nil, Qt::Application::UnicodeUTF8)
108
+ @action_refresh.shortcut = Qt::Application.translate("Browser", "Ctrl+R", nil, Qt::Application::UnicodeUTF8)
109
+ @action_next.text = Qt::Application.translate("Browser", "&Next", nil, Qt::Application::UnicodeUTF8)
110
+ @action_next.iconText = Qt::Application.translate("Browser", "Next", nil, Qt::Application::UnicodeUTF8)
111
+ @action_next.toolTip = Qt::Application.translate("Browser", "Next Model", nil, Qt::Application::UnicodeUTF8)
112
+ @action_next.shortcut = Qt::Application.translate("Browser", "Ctrl+Tab", nil, Qt::Application::UnicodeUTF8)
113
+ @action_previous.text = Qt::Application.translate("Browser", "&Previous", nil, Qt::Application::UnicodeUTF8)
114
+ @action_previous.toolTip = Qt::Application.translate("Browser", "Previous Model", nil, Qt::Application::UnicodeUTF8)
115
+ @action_previous.shortcut = Qt::Application.translate("Browser", "Ctrl+Shift+Backtab", nil, Qt::Application::UnicodeUTF8)
116
+ @action_new_window.text = Qt::Application.translate("Browser", "&New Window", nil, Qt::Application::UnicodeUTF8)
117
+ @menu_file.title = Qt::Application.translate("Browser", "&File", nil, Qt::Application::UnicodeUTF8)
118
+ @menu_edit.title = Qt::Application.translate("Browser", "&Edit", nil, Qt::Application::UnicodeUTF8)
119
+ @menu_search.title = Qt::Application.translate("Browser", "&Search", nil, Qt::Application::UnicodeUTF8)
120
+ @menu_model.title = Qt::Application.translate("Browser", "&Table", nil, Qt::Application::UnicodeUTF8)
121
+ end # retranslateUi
122
+
123
+ def retranslate_ui(browser)
124
+ retranslateUi(browser)
125
+ end
126
+
127
+ end
128
+
129
+ module Ui
130
+ class Browser < Ui_Browser
131
+ end
132
+ end # module Ui
133
+
@@ -0,0 +1,106 @@
1
+ =begin
2
+ ** Form generated from reading ui file 'search_dialog.ui'
3
+ **
4
+ ** Created: Mon Jan 24 21:13:34 2011
5
+ ** by: Qt User Interface Compiler version 4.5.1
6
+ **
7
+ ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
+ =end
9
+
10
+ class Ui_SearchDialog
11
+ attr_reader :button_box
12
+ attr_reader :selected_rows
13
+ attr_reader :selected_columns
14
+ attr_reader :search_label
15
+ attr_reader :search_combo
16
+ attr_reader :from_start
17
+ attr_reader :regex
18
+ attr_reader :whole_words
19
+ attr_reader :forwards
20
+ attr_reader :backwards
21
+
22
+ def setupUi(searchDialog)
23
+ if searchDialog.objectName.nil?
24
+ searchDialog.objectName = "searchDialog"
25
+ end
26
+ searchDialog.windowModality = Qt::WindowModal
27
+ searchDialog.resize(307, 400)
28
+ icon = Qt::Icon.new("../../hilfer/bin/hilfer-icon.png")
29
+ searchDialog.windowIcon = icon
30
+ @button_box = Qt::DialogButtonBox.new(searchDialog)
31
+ @button_box.objectName = "button_box"
32
+ @button_box.geometry = Qt::Rect.new(30, 240, 261, 32)
33
+ @button_box.orientation = Qt::Horizontal
34
+ @button_box.standardButtons = Qt::DialogButtonBox::Cancel|Qt::DialogButtonBox::NoButton|Qt::DialogButtonBox::Ok
35
+ @selected_rows = Qt::CheckBox.new(searchDialog)
36
+ @selected_rows.objectName = "selected_rows"
37
+ @selected_rows.enabled = false
38
+ @selected_rows.geometry = Qt::Rect.new(30, 280, 191, 21)
39
+ @selected_columns = Qt::CheckBox.new(searchDialog)
40
+ @selected_columns.objectName = "selected_columns"
41
+ @selected_columns.enabled = false
42
+ @selected_columns.geometry = Qt::Rect.new(30, 310, 191, 21)
43
+ @search_label = Qt::Label.new(searchDialog)
44
+ @search_label.objectName = "search_label"
45
+ @search_label.geometry = Qt::Rect.new(20, 10, 51, 21)
46
+ @search_label.textFormat = Qt::PlainText
47
+ @search_combo = Qt::ComboBox.new(searchDialog)
48
+ @search_combo.objectName = "search_combo"
49
+ @search_combo.geometry = Qt::Rect.new(90, 10, 201, 25)
50
+ @search_combo.focusPolicy = Qt::StrongFocus
51
+ @search_combo.editable = true
52
+ @from_start = Qt::CheckBox.new(searchDialog)
53
+ @from_start.objectName = "from_start"
54
+ @from_start.geometry = Qt::Rect.new(90, 50, 191, 21)
55
+ @regex = Qt::CheckBox.new(searchDialog)
56
+ @regex.objectName = "regex"
57
+ @regex.geometry = Qt::Rect.new(90, 80, 191, 21)
58
+ @whole_words = Qt::CheckBox.new(searchDialog)
59
+ @whole_words.objectName = "whole_words"
60
+ @whole_words.geometry = Qt::Rect.new(90, 110, 191, 21)
61
+ @forwards = Qt::RadioButton.new(searchDialog)
62
+ @forwards.objectName = "forwards"
63
+ @forwards.geometry = Qt::Rect.new(90, 140, 171, 26)
64
+ @forwards.checked = true
65
+ @backwards = Qt::RadioButton.new(searchDialog)
66
+ @backwards.objectName = "backwards"
67
+ @backwards.geometry = Qt::Rect.new(90, 170, 176, 26)
68
+ @search_label.buddy = @search_combo
69
+ Qt::Widget.setTabOrder(@search_combo, @selected_columns)
70
+ Qt::Widget.setTabOrder(@selected_columns, @selected_rows)
71
+ Qt::Widget.setTabOrder(@selected_rows, @button_box)
72
+
73
+ retranslateUi(searchDialog)
74
+ Qt::Object.connect(@button_box, SIGNAL('accepted()'), searchDialog, SLOT('accept()'))
75
+ Qt::Object.connect(@button_box, SIGNAL('rejected()'), searchDialog, SLOT('reject()'))
76
+
77
+ Qt::MetaObject.connectSlotsByName(searchDialog)
78
+ end # setupUi
79
+
80
+ def setup_ui(searchDialog)
81
+ setupUi(searchDialog)
82
+ end
83
+
84
+ def retranslateUi(searchDialog)
85
+ searchDialog.windowTitle = Qt::Application.translate("SearchDialog", "Search", nil, Qt::Application::UnicodeUTF8)
86
+ @selected_rows.text = Qt::Application.translate("SearchDialog", "Selected Rows", nil, Qt::Application::UnicodeUTF8)
87
+ @selected_columns.text = Qt::Application.translate("SearchDialog", "Selected Columns", nil, Qt::Application::UnicodeUTF8)
88
+ @search_label.text = Qt::Application.translate("SearchDialog", "Search", nil, Qt::Application::UnicodeUTF8)
89
+ @from_start.text = Qt::Application.translate("SearchDialog", "From &Start", nil, Qt::Application::UnicodeUTF8)
90
+ @regex.text = Qt::Application.translate("SearchDialog", "&Regular Expression", nil, Qt::Application::UnicodeUTF8)
91
+ @whole_words.text = Qt::Application.translate("SearchDialog", "&Whole Words", nil, Qt::Application::UnicodeUTF8)
92
+ @forwards.text = Qt::Application.translate("SearchDialog", "&Forwards", nil, Qt::Application::UnicodeUTF8)
93
+ @backwards.text = Qt::Application.translate("SearchDialog", "&Backwards", nil, Qt::Application::UnicodeUTF8)
94
+ end # retranslateUi
95
+
96
+ def retranslate_ui(searchDialog)
97
+ retranslateUi(searchDialog)
98
+ end
99
+
100
+ end
101
+
102
+ module Ui
103
+ class SearchDialog < Ui_SearchDialog
104
+ end
105
+ end # module Ui
106
+
data/lib/clevic/swing.rb CHANGED
@@ -10,6 +10,8 @@ require 'java'
10
10
  # require these first, so TableModel and TableView get the correct ancestors
11
11
  require 'clevic/swing/table_model.rb'
12
12
  require 'clevic/swing/table_view.rb'
13
+
14
+ # all other files in the swing subdirectory
13
15
  ( Pathname.new( __FILE__ ).parent + 'swing' ).children.grep( /.rb$/ ).each do |child|
14
16
  require child.to_s
15
17
  end
@@ -0,0 +1,15 @@
1
+ module Clevic
2
+
3
+ class ModelBuilder
4
+ # Not sure if this is the right place to put it, but
5
+ # try here and see if it works out.
6
+ def plain_delegate( field )
7
+ if field.meta.type == :boolean
8
+ BooleanDelegate.new( field )
9
+ else
10
+ TextDelegate.new( field )
11
+ end
12
+ end
13
+ end
14
+
15
+ end
@@ -117,7 +117,8 @@ class TableModel
117
117
  add_new_item if collection.empty? && auto_new?
118
118
  end
119
119
 
120
- # save the AR model at the given index, if it's dirty
120
+ # save the model at the given index, if it's dirty
121
+ # TODO Sequel uses modified?
121
122
  def save( index )
122
123
  item = collection[index.row]
123
124
  return false if item.nil?
@@ -130,7 +131,7 @@ class TableModel
130
131
  false
131
132
  end
132
133
  else
133
- # AR model not changed
134
+ # model not changed
134
135
  true
135
136
  end
136
137
  rescue
@@ -151,7 +152,7 @@ class TableModel
151
152
  # TODO could handle dataset creation better
152
153
  def search( start_index, search_criteria )
153
154
  ordered_dataset = entity_class.dataset.order( *cache_table.order_attributes.map{|oa| oa.attribute.to_sym.send( oa.direction ) } )
154
- searcher = Clevic::TableSearcher.new(
155
+ searcher = TableSearcher.new(
155
156
  ordered_dataset,
156
157
  search_criteria,
157
158
  start_index.field
@@ -159,9 +160,10 @@ class TableModel
159
160
  entity = searcher.search( start_index.entity )
160
161
 
161
162
  # return matched indexes
162
- if entity != nil
163
+ unless entity.nil?
163
164
  found_row = collection.index_for_entity( entity )
164
- [ create_index( found_row, start_index.column ) ]
165
+ raise "found_row should find something" if found_row.nil?
166
+ [ create_index( found_row, start_index.column, 0 ) ]
165
167
  else
166
168
  []
167
169
  end
@@ -87,7 +87,6 @@ class TableView
87
87
 
88
88
  # list of actions in the edit menu
89
89
  list( :edit ) do
90
- #~ new_action :action_cut, 'Cu&t', :shortcut => 'Ctrl-X'
91
90
  action :action_save, '&Save', :shortcut => 'Ctrl+S', :method => :save_current_rows
92
91
  #~ action :action_cut, 'Cu&t', :shortcut => 'Ctrl+X', :method => :cut_current_selection
93
92
  action :action_copy, '&Copy', :shortcut => 'Ctrl+C', :method => :copy_current_selection
@@ -263,7 +262,7 @@ class TableView
263
262
  end
264
263
 
265
264
  def search_dialog
266
- @search_dialog ||= SearchDialog.new( nil )
265
+ @search_dialog ||= SearchDialog.new( self )
267
266
  end
268
267
 
269
268
  # display a search dialog, and find the entered text
@@ -3,7 +3,7 @@ module Clevic #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 13
5
5
  TINY = 0
6
- PRE = 'b1'
6
+ PRE = 'b2'
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].join('.')
9
9
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clevic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 165
4
+ hash: 163
5
5
  prerelease: 7
6
6
  segments:
7
7
  - 0
8
8
  - 13
9
9
  - 0
10
10
  - b
11
- - 1
12
- version: 0.13.0.b1
11
+ - 2
12
+ version: 0.13.0.b2
13
13
  platform: ruby
14
14
  authors:
15
15
  - John Anderson
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-01-20 00:00:00 +02:00
20
+ date: 2011-01-24 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -196,7 +196,7 @@ dependencies:
196
196
  version: 1.8.0
197
197
  type: :development
198
198
  version_requirements: *id011
199
- description: SQL table GUI with Qt, Swing, Sequel
199
+ description: SQL table GUI with Qt / Java Swing and Sequel
200
200
  email:
201
201
  - panic@semiosix.com
202
202
  executables:
@@ -237,13 +237,16 @@ files:
237
237
  - test/test_sql_dialects.rb
238
238
  - test/test_table_model.rb
239
239
  - test/test_table_searcher.rb
240
+ - lib/clevic.rb
240
241
  - lib/clevic/qt/ui/browser.ui
241
242
  - lib/clevic/qt/ui/search_dialog_ui.rb
242
243
  - lib/clevic/qt/ui/search_dialog.ui
243
244
  - lib/clevic/qt/ui/browser_ui.rb
245
+ - lib/clevic/qt/model_builder.rb
244
246
  - lib/clevic/qt/table_model.rb
245
247
  - lib/clevic/qt/text_area_delegate.rb
246
248
  - lib/clevic/qt/browser.rb
249
+ - lib/clevic/qt/accept_reject.rb
247
250
  - lib/clevic/qt/action_builder.rb
248
251
  - lib/clevic/qt/field.rb
249
252
  - lib/clevic/qt/set_delegate.rb
@@ -283,6 +286,7 @@ files:
283
286
  - lib/clevic/swing/ui/nbproject/private/private.xml
284
287
  - lib/clevic/swing/ui/build.xml
285
288
  - lib/clevic/swing/ui/manifest.mf
289
+ - lib/clevic/swing/model_builder.rb
286
290
  - lib/clevic/swing/table_model.rb
287
291
  - lib/clevic/swing/text_area_delegate.rb
288
292
  - lib/clevic/swing/browser.rb
@@ -335,7 +339,6 @@ files:
335
339
  - lib/clevic/version.rb
336
340
  - lib/clevic/generic_format.rb
337
341
  - lib/clevic/emitter.rb
338
- - lib/clevic/qt/ui/.gitignore
339
342
  has_rdoc: true
340
343
  homepage: http://clevic.rubyforge.org
341
344
  licenses: []
@@ -374,10 +377,10 @@ signing_key:
374
377
  specification_version: 3
375
378
  summary: Database framework and Model/View GUI for data capture and editing of tables in a pre-existing relational DBMS
376
379
  test_files:
380
+ - test/test_sql_dialects.rb
381
+ - test/test_order_attribute.rb
382
+ - test/test_table_searcher.rb
377
383
  - test/test_model_index_extensions.rb
378
- - test/test_cache_table.rb
379
384
  - test/test_table_model.rb
380
- - test/test_table_searcher.rb
381
- - test/test_order_attribute.rb
382
385
  - test/test_helper.rb
383
- - test/test_sql_dialects.rb
386
+ - test/test_cache_table.rb
@@ -1 +0,0 @@
1
- *_ui.rb