clevic 0.8.0 → 0.11.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 (52) hide show
  1. data/History.txt +9 -0
  2. data/Manifest.txt +13 -10
  3. data/README.txt +6 -9
  4. data/Rakefile +35 -24
  5. data/TODO +29 -17
  6. data/bin/clevic +84 -37
  7. data/config/hoe.rb +7 -3
  8. data/lib/clevic.rb +2 -4
  9. data/lib/clevic/browser.rb +37 -49
  10. data/lib/clevic/cache_table.rb +55 -165
  11. data/lib/clevic/db_options.rb +32 -21
  12. data/lib/clevic/default_view.rb +66 -0
  13. data/lib/clevic/delegates.rb +51 -67
  14. data/lib/clevic/dirty.rb +101 -0
  15. data/lib/clevic/extensions.rb +24 -38
  16. data/lib/clevic/field.rb +400 -99
  17. data/lib/clevic/item_delegate.rb +32 -33
  18. data/lib/clevic/model_builder.rb +315 -148
  19. data/lib/clevic/order_attribute.rb +53 -0
  20. data/lib/clevic/record.rb +57 -57
  21. data/lib/clevic/search_dialog.rb +71 -67
  22. data/lib/clevic/sql_dialects.rb +33 -0
  23. data/lib/clevic/table_model.rb +73 -120
  24. data/lib/clevic/table_searcher.rb +165 -0
  25. data/lib/clevic/table_view.rb +140 -100
  26. data/lib/clevic/ui/.gitignore +1 -0
  27. data/lib/clevic/ui/browser_ui.rb +55 -56
  28. data/lib/clevic/ui/search_dialog_ui.rb +50 -51
  29. data/lib/clevic/version.rb +2 -2
  30. data/lib/clevic/view.rb +89 -0
  31. data/models/accounts_models.rb +12 -9
  32. data/models/minimal_models.rb +4 -2
  33. data/models/times_models.rb +41 -25
  34. data/models/times_sqlite_models.rb +1 -145
  35. data/models/values_models.rb +15 -16
  36. data/test/test_cache_table.rb +138 -0
  37. data/test/test_helper.rb +131 -0
  38. data/test/test_model_index_extensions.rb +22 -0
  39. data/test/test_order_attribute.rb +62 -0
  40. data/test/test_sql_dialects.rb +77 -0
  41. data/test/test_table_searcher.rb +188 -0
  42. metadata +36 -20
  43. data/bin/import-times +0 -128
  44. data/config/jamis.rb +0 -589
  45. data/env.sh +0 -1
  46. data/lib/active_record/dirty.rb +0 -87
  47. data/lib/clevic/field_builder.rb +0 -42
  48. data/website/index.html +0 -170
  49. data/website/index.txt +0 -17
  50. data/website/screenshot.png +0 -0
  51. data/website/stylesheets/screen.css +0 -131
  52. data/website/template.html.erb +0 -41
@@ -0,0 +1 @@
1
+ *_ui.rb
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  ** Form generated from reading ui file 'browser.ui'
3
3
  **
4
- ** Created: Fri Aug 8 22:32:38 2008
5
- ** by: Qt User Interface Compiler version 4.3.2
4
+ ** Created: Sun Aug 10 20:25:20 2008
5
+ ** by: Qt User Interface Compiler version 4.3.3
6
6
  **
7
7
  ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
8
  =end
@@ -17,7 +17,7 @@ class Ui_Browser
17
17
  attr_reader :action_previous
18
18
  attr_reader :action_new_window
19
19
  attr_reader :main_widget
20
- attr_reader :qvboxLayout
20
+ attr_reader :vboxLayout
21
21
  attr_reader :statusbar
22
22
  attr_reader :menubar
23
23
  attr_reader :menu_file
@@ -26,48 +26,52 @@ class Ui_Browser
26
26
  attr_reader :menu_model
27
27
 
28
28
  def setupUi(browser)
29
- browser.setObjectName("browser")
30
- browser.setWindowIcon(Qt::Icon.new("icon.png"))
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
31
35
  @action_open = Qt::Action.new(browser)
32
- @action_open.setObjectName("action_open")
33
- @action_open.setVisible(false)
36
+ @action_open.objectName = "action_open"
37
+ @action_open.visible = false
34
38
  @action_close = Qt::Action.new(browser)
35
- @action_close.setObjectName("action_close")
36
- @action_close.setVisible(false)
39
+ @action_close.objectName = "action_close"
40
+ @action_close.visible = false
37
41
  @action_recent = Qt::Action.new(browser)
38
- @action_recent.setObjectName("action_recent")
39
- @action_recent.setVisible(false)
42
+ @action_recent.objectName = "action_recent"
43
+ @action_recent.visible = false
40
44
  @action_dump = Qt::Action.new(browser)
41
- @action_dump.setObjectName("action_dump")
45
+ @action_dump.objectName = "action_dump"
42
46
  @action_refresh = Qt::Action.new(browser)
43
- @action_refresh.setObjectName("action_refresh")
47
+ @action_refresh.objectName = "action_refresh"
44
48
  @action_next = Qt::Action.new(browser)
45
- @action_next.setObjectName("action_next")
49
+ @action_next.objectName = "action_next"
46
50
  @action_previous = Qt::Action.new(browser)
47
- @action_previous.setObjectName("action_previous")
51
+ @action_previous.objectName = "action_previous"
48
52
  @action_new_window = Qt::Action.new(browser)
49
- @action_new_window.setObjectName("action_new_window")
50
- @action_new_window.setVisible(false)
53
+ @action_new_window.objectName = "action_new_window"
54
+ @action_new_window.visible = false
51
55
  @main_widget = Qt::Widget.new(browser)
52
- @main_widget.setObjectName("main_widget")
53
- @qvboxLayout = Qt::VBoxLayout.new(@main_widget)
54
- @qvboxLayout.setObjectName("qvboxLayout")
55
- browser.setCentralWidget(@main_widget)
56
+ @main_widget.objectName = "main_widget"
57
+ @vboxLayout = Qt::VBoxLayout.new(@main_widget)
58
+ @vboxLayout.objectName = "vboxLayout"
59
+ browser.centralWidget = @main_widget
56
60
  @statusbar = Qt::StatusBar.new(browser)
57
- @statusbar.setObjectName("statusbar")
58
- browser.setStatusBar(@statusbar)
61
+ @statusbar.objectName = "statusbar"
62
+ browser.statusBar = @statusbar
59
63
  @menubar = Qt::MenuBar.new(browser)
60
- @menubar.setObjectName("menubar")
61
- @menubar.setGeometry(Qt::Rect.new(0, 0, 727, 31))
64
+ @menubar.objectName = "menubar"
65
+ @menubar.geometry = Qt::Rect.new(0, 0, 727, 31)
62
66
  @menu_file = Qt::Menu.new(@menubar)
63
- @menu_file.setObjectName("menu_file")
64
- @menu_file.setEnabled(false)
67
+ @menu_file.objectName = "menu_file"
68
+ @menu_file.enabled = false
65
69
  @menu_edit = Qt::Menu.new(@menubar)
66
- @menu_edit.setObjectName("menu_edit")
70
+ @menu_edit.objectName = "menu_edit"
67
71
  @menu_search = Qt::Menu.new(@menubar)
68
- @menu_search.setObjectName("menu_search")
72
+ @menu_search.objectName = "menu_search"
69
73
  @menu_model = Qt::Menu.new(@menubar)
70
- @menu_model.setObjectName("menu_model")
74
+ @menu_model.objectName = "menu_model"
71
75
  browser.setMenuBar(@menubar)
72
76
 
73
77
  @menubar.addAction(@menu_file.menuAction())
@@ -85,11 +89,6 @@ class Ui_Browser
85
89
 
86
90
  retranslateUi(browser)
87
91
 
88
- size = Qt::Size.new(727, 740)
89
- size = size.expandedTo(browser.minimumSizeHint())
90
- browser.resize(size)
91
-
92
-
93
92
  Qt::MetaObject.connectSlotsByName(browser)
94
93
  end # setupUi
95
94
 
@@ -98,27 +97,27 @@ class Ui_Browser
98
97
  end
99
98
 
100
99
  def retranslateUi(browser)
101
- @action_open.setText(Qt::Application.translate("Browser", "&Open", nil, Qt::Application::UnicodeUTF8))
102
- @action_close.setText(Qt::Application.translate("Browser", "&Close", nil, Qt::Application::UnicodeUTF8))
103
- @action_recent.setText(Qt::Application.translate("Browser", "&Recent", nil, Qt::Application::UnicodeUTF8))
104
- @action_dump.setText(Qt::Application.translate("Browser", "&Dump", nil, Qt::Application::UnicodeUTF8))
105
- @action_dump.setShortcut(Qt::Application.translate("Browser", "Alt+Shift+D", nil, Qt::Application::UnicodeUTF8))
106
- @action_refresh.setText(Qt::Application.translate("Browser", "&Refresh", nil, Qt::Application::UnicodeUTF8))
107
- @action_refresh.setIconText(Qt::Application.translate("Browser", "Refresh current table from database", nil, Qt::Application::UnicodeUTF8))
108
- @action_refresh.setToolTip(Qt::Application.translate("Browser", "Refresh current table from database", nil, Qt::Application::UnicodeUTF8))
109
- @action_refresh.setShortcut(Qt::Application.translate("Browser", "Ctrl+R", nil, Qt::Application::UnicodeUTF8))
110
- @action_next.setText(Qt::Application.translate("Browser", "&Next", nil, Qt::Application::UnicodeUTF8))
111
- @action_next.setIconText(Qt::Application.translate("Browser", "Next", nil, Qt::Application::UnicodeUTF8))
112
- @action_next.setToolTip(Qt::Application.translate("Browser", "Next Model", nil, Qt::Application::UnicodeUTF8))
113
- @action_next.setShortcut(Qt::Application.translate("Browser", "Ctrl+Tab", nil, Qt::Application::UnicodeUTF8))
114
- @action_previous.setText(Qt::Application.translate("Browser", "&Previous", nil, Qt::Application::UnicodeUTF8))
115
- @action_previous.setToolTip(Qt::Application.translate("Browser", "Previous Model", nil, Qt::Application::UnicodeUTF8))
116
- @action_previous.setShortcut(Qt::Application.translate("Browser", "Ctrl+Shift+Backtab", nil, Qt::Application::UnicodeUTF8))
117
- @action_new_window.setText(Qt::Application.translate("Browser", "&New Window", nil, Qt::Application::UnicodeUTF8))
118
- @menu_file.setTitle(Qt::Application.translate("Browser", "&File", nil, Qt::Application::UnicodeUTF8))
119
- @menu_edit.setTitle(Qt::Application.translate("Browser", "&Edit", nil, Qt::Application::UnicodeUTF8))
120
- @menu_search.setTitle(Qt::Application.translate("Browser", "&Search", nil, Qt::Application::UnicodeUTF8))
121
- @menu_model.setTitle(Qt::Application.translate("Browser", "&Table", nil, Qt::Application::UnicodeUTF8))
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)
122
121
  end # retranslateUi
123
122
 
124
123
  def retranslate_ui(browser)
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
  ** Form generated from reading ui file 'search_dialog.ui'
3
3
  **
4
- ** Created: Sun Aug 3 22:07:49 2008
5
- ** by: Qt User Interface Compiler version 4.3.2
4
+ ** Created: Wed Jul 23 11:45:29 2008
5
+ ** by: Qt User Interface Compiler version 4.3.3
6
6
  **
7
7
  ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
8
  =end
@@ -20,58 +20,57 @@ class Ui_SearchDialog
20
20
  attr_reader :backwards
21
21
 
22
22
  def setupUi(searchDialog)
23
- searchDialog.setObjectName("searchDialog")
24
- searchDialog.setWindowModality(Qt::WindowModal)
25
- searchDialog.setWindowIcon(Qt::Icon.new("../../hilfer/bin/hilfer-icon.png"))
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
26
30
  @button_box = Qt::DialogButtonBox.new(searchDialog)
27
- @button_box.setObjectName("button_box")
28
- @button_box.setGeometry(Qt::Rect.new(30, 240, 261, 32))
29
- @button_box.setOrientation(Qt::Horizontal)
30
- @button_box.setStandardButtons(Qt::DialogButtonBox::Cancel|Qt::DialogButtonBox::NoButton|Qt::DialogButtonBox::Ok)
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
31
35
  @selected_rows = Qt::CheckBox.new(searchDialog)
32
- @selected_rows.setObjectName("selected_rows")
33
- @selected_rows.setEnabled(false)
34
- @selected_rows.setGeometry(Qt::Rect.new(30, 280, 191, 21))
36
+ @selected_rows.objectName = "selected_rows"
37
+ @selected_rows.enabled = false
38
+ @selected_rows.geometry = Qt::Rect.new(30, 280, 191, 21)
35
39
  @selected_columns = Qt::CheckBox.new(searchDialog)
36
- @selected_columns.setObjectName("selected_columns")
37
- @selected_columns.setEnabled(false)
38
- @selected_columns.setGeometry(Qt::Rect.new(30, 310, 191, 21))
40
+ @selected_columns.objectName = "selected_columns"
41
+ @selected_columns.enabled = false
42
+ @selected_columns.geometry = Qt::Rect.new(30, 310, 191, 21)
39
43
  @search_label = Qt::Label.new(searchDialog)
40
- @search_label.setObjectName("search_label")
41
- @search_label.setGeometry(Qt::Rect.new(20, 10, 51, 21))
42
- @search_label.setTextFormat(Qt::PlainText)
44
+ @search_label.objectName = "search_label"
45
+ @search_label.geometry = Qt::Rect.new(20, 10, 51, 21)
46
+ @search_label.textFormat = Qt::PlainText
43
47
  @search_combo = Qt::ComboBox.new(searchDialog)
44
- @search_combo.setObjectName("search_combo")
45
- @search_combo.setGeometry(Qt::Rect.new(90, 10, 201, 25))
46
- @search_combo.setFocusPolicy(Qt::StrongFocus)
47
- @search_combo.setEditable(true)
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
48
52
  @from_start = Qt::CheckBox.new(searchDialog)
49
- @from_start.setObjectName("from_start")
50
- @from_start.setGeometry(Qt::Rect.new(90, 50, 191, 21))
53
+ @from_start.objectName = "from_start"
54
+ @from_start.geometry = Qt::Rect.new(90, 50, 191, 21)
51
55
  @regex = Qt::CheckBox.new(searchDialog)
52
- @regex.setObjectName("regex")
53
- @regex.setGeometry(Qt::Rect.new(90, 80, 191, 21))
56
+ @regex.objectName = "regex"
57
+ @regex.geometry = Qt::Rect.new(90, 80, 191, 21)
54
58
  @whole_words = Qt::CheckBox.new(searchDialog)
55
- @whole_words.setObjectName("whole_words")
56
- @whole_words.setGeometry(Qt::Rect.new(90, 110, 191, 21))
59
+ @whole_words.objectName = "whole_words"
60
+ @whole_words.geometry = Qt::Rect.new(90, 110, 191, 21)
57
61
  @forwards = Qt::RadioButton.new(searchDialog)
58
- @forwards.setObjectName("forwards")
59
- @forwards.setGeometry(Qt::Rect.new(90, 140, 171, 26))
60
- @forwards.setChecked(true)
62
+ @forwards.objectName = "forwards"
63
+ @forwards.geometry = Qt::Rect.new(90, 140, 171, 26)
64
+ @forwards.checked = true
61
65
  @backwards = Qt::RadioButton.new(searchDialog)
62
- @backwards.setObjectName("backwards")
63
- @backwards.setGeometry(Qt::Rect.new(90, 170, 176, 26))
64
- @search_label.setBuddy(@search_combo)
65
- Qt::Widget::setTabOrder(@search_combo, @selected_columns)
66
- Qt::Widget::setTabOrder(@selected_columns, @selected_rows)
67
- Qt::Widget::setTabOrder(@selected_rows, @button_box)
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)
68
72
 
69
73
  retranslateUi(searchDialog)
70
-
71
- size = Qt::Size.new(307, 400)
72
- size = size.expandedTo(searchDialog.minimumSizeHint())
73
- searchDialog.resize(size)
74
-
75
74
  Qt::Object.connect(@button_box, SIGNAL('accepted()'), searchDialog, SLOT('accept()'))
76
75
  Qt::Object.connect(@button_box, SIGNAL('rejected()'), searchDialog, SLOT('reject()'))
77
76
 
@@ -83,15 +82,15 @@ class Ui_SearchDialog
83
82
  end
84
83
 
85
84
  def retranslateUi(searchDialog)
86
- searchDialog.setWindowTitle(Qt::Application.translate("SearchDialog", "Search", nil, Qt::Application::UnicodeUTF8))
87
- @selected_rows.setText(Qt::Application.translate("SearchDialog", "Selected Rows", nil, Qt::Application::UnicodeUTF8))
88
- @selected_columns.setText(Qt::Application.translate("SearchDialog", "Selected Columns", nil, Qt::Application::UnicodeUTF8))
89
- @search_label.setText(Qt::Application.translate("SearchDialog", "Search", nil, Qt::Application::UnicodeUTF8))
90
- @from_start.setText(Qt::Application.translate("SearchDialog", "From &Start", nil, Qt::Application::UnicodeUTF8))
91
- @regex.setText(Qt::Application.translate("SearchDialog", "&Regular Expression", nil, Qt::Application::UnicodeUTF8))
92
- @whole_words.setText(Qt::Application.translate("SearchDialog", "&Whole Words", nil, Qt::Application::UnicodeUTF8))
93
- @forwards.setText(Qt::Application.translate("SearchDialog", "&Forwards", nil, Qt::Application::UnicodeUTF8))
94
- @backwards.setText(Qt::Application.translate("SearchDialog", "&Backwards", nil, Qt::Application::UnicodeUTF8))
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)
95
94
  end # retranslateUi
96
95
 
97
96
  def retranslate_ui(searchDialog)
@@ -1,8 +1,8 @@
1
1
  module Clevic #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 8
5
- TINY = 0
4
+ MINOR = 11
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,89 @@
1
+ require 'set'
2
+ require 'clevic/model_builder.rb'
3
+
4
+ module Clevic
5
+ # This contains the definition of a particular view of an entity.
6
+ # See Clevic::ModelBuilder.
7
+ class View
8
+ @order = []
9
+ def self.order
10
+ @order
11
+ end
12
+
13
+ # Handle situations where the array passed to
14
+ # Clevic::View.order = has ActiveRecord::Base
15
+ # objects in it. In other words, if there is one, pass back it's
16
+ # default view class rather than the ActiveRecord::Base subclass.
17
+ def self.order=( array )
18
+ @order = array.map do |x|
19
+ if x.ancestors.include?( ActiveRecord::Base )
20
+ x.default_view_class
21
+ else
22
+ x
23
+ end
24
+ end
25
+ end
26
+
27
+ def self.entity_class( *args )
28
+ if args.size == 0
29
+ @entity_class || raise( "entity_class not specified for #{name}" )
30
+ else
31
+ @entity_class = args.first
32
+ end
33
+ end
34
+
35
+ def self.entity_class=( some_class )
36
+ @entity_class = some_class
37
+ end
38
+
39
+ def self.widget_name( *args )
40
+ if args.size == 0
41
+ # the class name by default
42
+ @widget_name || name
43
+ else
44
+ @widget_name = args.first
45
+ end
46
+ end
47
+
48
+ # For descendants to override easily
49
+ def entity_class
50
+ self.class.entity_class
51
+ end
52
+
53
+ # The title to display, eg in a tab
54
+ def title
55
+ self.class.name
56
+ end
57
+
58
+ # used for the Qt object_name when ModelBuilder is constructing a widget
59
+ # here so it can be overridden by descendants
60
+ def widget_name
61
+ self.class.widget_name
62
+ end
63
+
64
+ def model_builder( &block )
65
+ @model_builder ||= ModelBuilder.new( self )
66
+ @model_builder.exec_ui_block( &block )
67
+ end
68
+
69
+ # return a default UI constructed from model metadata
70
+ def define_ui
71
+ model_builder do
72
+ default_ui
73
+ end
74
+ end
75
+
76
+ # define view/model specific actions
77
+ def define_actions( table_view, action_builder )
78
+ end
79
+
80
+ # define data changed events
81
+ def notify_data_changed( table_view, top_left_model_index, bottom_right_model_index )
82
+ end
83
+
84
+ # be notified of key presses
85
+ def notify_key_press( table_view, key_press_event, current_model_index )
86
+ end
87
+
88
+ end
89
+ end
@@ -12,10 +12,12 @@ Clevic::DbOptions.connect( $options ) do
12
12
  username 'accounts'
13
13
  end
14
14
 
15
- class Entry < Clevic::Record
15
+ class Entry < ActiveRecord::Base
16
16
  belongs_to :debit, :class_name => 'Account', :foreign_key => 'debit_id'
17
17
  belongs_to :credit, :class_name => 'Account', :foreign_key => 'credit_id'
18
-
18
+
19
+ include Clevic::Record
20
+
19
21
  define_ui do
20
22
  plain :date, :sample => '88-WWW-99'
21
23
  distinct :description, :conditions => "now() - date <= '1 year'", :sample => 'm' * 26
@@ -45,7 +47,7 @@ class Entry < Clevic::Record
45
47
  # copy the values for the credit and debit fields
46
48
  # from the previous similar entry
47
49
  def self.update_credit_debit( current_index, view )
48
- return if !current_index.valid?
50
+ return unless current_index.valid?
49
51
  current_field = current_index.attribute
50
52
  if current_field == :description
51
53
  # most recent entry, ordered in reverse
@@ -61,28 +63,29 @@ class Entry < Clevic::Record
61
63
  current_index.entity.category = similar.category
62
64
 
63
65
  # emit signal to update view from top_left to bottom_right
64
- model = current_index.model
65
- top_left_index = model.create_index( current_index.row, 0 )
66
- bottom_right_index = model.create_index( current_index.row, view.builder.fields.size )
66
+ top_left_index = current_index.choppy( :column => 0 )
67
+ bottom_right_index = current_index.choppy( :column => view.model.column_count - 1 )
67
68
  view.dataChanged( top_left_index, bottom_right_index )
68
69
 
69
70
  # move edit cursor to amount field
70
71
  view.selection_model.clear
71
- view.override_next_index( model.create_index( current_index.row, view.builder.index( :amount ) ) )
72
+ view.override_next_index( current_index.choppy( :column => view.field_column( :amount ) ) )
72
73
  end
73
74
  end
74
75
  end
75
76
  end
76
77
 
77
- class Account < Clevic::Record
78
+ class Account < ActiveRecord::Base
78
79
  has_many :debits, :class_name => 'Entry', :foreign_key => 'debit_id'
79
80
  has_many :credits, :class_name => 'Entry', :foreign_key => 'credit_id'
80
81
 
82
+ include Clevic::Record
83
+
81
84
  # define how fields are displayed
82
85
  define_ui do
83
86
  plain :name
84
87
  restricted :vat, :label => 'VAT', :set => %w{ yes no all }
85
- plain :account_type
88
+ restricted :account_type, :set => %w{Account Asset Assets Expenses Income Liability Opening Balance Personal Tax VAT}
86
89
  plain :pastel_number, :alignment => Qt::AlignRight, :label => 'Pastel'
87
90
  plain :fringe, :format => "%.1f"
88
91
  plain :active