Class: Clevic::Delegate
- Includes:
- FieldValuer
- Defined in:
- lib/clevic/delegate.rb,
lib/clevic/qt/delegate.rb,
lib/clevic/swing/delegate.rb
Overview
This has both a field and an entity, so it’s a perfect candidate for including FieldValuer, which it does.
Direct Known Subclasses
BooleanDelegate, ComboDelegate, TagDelegate, TextAreaDelegate, TextDelegate
Instance Attribute Summary collapse
-
#entity ⇒ Object
This is the ORM entity instance for which this delegate is editing a single field.
-
#field ⇒ Object
readonly
the Clevic::Field instance which this delegate edits.
-
#parent ⇒ Object
The parent widget of this delegate / this delegate’s widget.
Instance Method Summary collapse
- #attribute ⇒ Object
-
#editorEvent(event, model, style_option_view_item, model_index) ⇒ Object
This catches the event that begins the edit process.
- #entity_class ⇒ Object
-
#full_edit ⇒ Object
change the visual state of the editor to the biggest / most space-consuming it can be.
-
#initialize(field) ⇒ Delegate
constructor
A new instance of Delegate.
- #inspect ⇒ Object
-
#is_combo? ⇒ Boolean
assume this is not a combo delegate.
-
#minimal_edit ⇒ Object
change the visual state of the editor to the smallest / least space-consuming it can be.
-
#native ⇒ Object
Return something useful if this should use the default GUI framework mechanism for table editing.
-
#needs_pre_selection? ⇒ Boolean
workaround for broken JTable editing starts.
-
#show_message(msg, &block) ⇒ Object
FIXME this must actually show a message, and the Qt code must use it too.
-
#updateEditorGeometry(editor, style_option_view_item, model_index) ⇒ Object
Figure out where to put the editor widget, taking into account the sizes of the headers TODO most of the subclasses are probably the same as this.
Methods included from FieldValuer
#attribute_value, #attribute_value=, #display_value, #edit_value, #edit_value=, #find_related, #raw_value, #text_value=, #tooltip, valuer, #valuer, #writer
Constructor Details
#initialize(field) ⇒ Delegate
Returns a new instance of Delegate.
10 11 12 13 |
# File 'lib/clevic/delegate.rb', line 10 def initialize( field ) super() @field = field end |
Instance Attribute Details
#entity ⇒ Object
This is the ORM entity instance for which this delegate is editing a single field. It needs to be the entire entity so we can set the edited field value on it.
18 19 20 |
# File 'lib/clevic/delegate.rb', line 18 def entity @entity end |
#field ⇒ Object (readonly)
the Clevic::Field instance which this delegate edits.
24 25 26 |
# File 'lib/clevic/delegate.rb', line 24 def field @field end |
#parent ⇒ Object
The parent widget of this delegate / this delegate’s widget
21 22 23 |
# File 'lib/clevic/delegate.rb', line 21 def parent @parent end |
Instance Method Details
#attribute ⇒ Object
26 27 28 |
# File 'lib/clevic/delegate.rb', line 26 def attribute field.attribute end |
#editorEvent(event, model, style_option_view_item, model_index) ⇒ Object
This catches the event that begins the edit process.
15 16 17 18 19 |
# File 'lib/clevic/qt/delegate.rb', line 15 def editorEvent( event, model, style_option_view_item, model_index ) # See qt Clevic::TableView parent.respond_to?( "before_edit_index=" ) && parent.before_edit_index = model_index super end |
#entity_class ⇒ Object
30 31 32 |
# File 'lib/clevic/delegate.rb', line 30 def entity_class field.entity_class end |
#full_edit ⇒ Object
change the visual state of the editor to the biggest / most space-consuming it can be. This grew out of combo boxes having a drop-down that can show or hide.
42 43 |
# File 'lib/clevic/delegate.rb', line 42 def full_edit end |
#inspect ⇒ Object
37 38 39 |
# File 'lib/clevic/swing/delegate.rb', line 37 def inspect "<#{self.class.name} native=#{native} needs_pre_selection=#{needs_pre_selection?}>" end |
#is_combo? ⇒ Boolean
assume this is not a combo delegate. That will come later.
35 36 37 |
# File 'lib/clevic/delegate.rb', line 35 def is_combo? false end |
#minimal_edit ⇒ Object
change the visual state of the editor to the smallest / least space-consuming it can be. This grew out of combo boxes having a drop-down that can show or hide.
48 49 |
# File 'lib/clevic/delegate.rb', line 48 def minimal_edit end |
#native ⇒ Object
Return something useful if this should use the default GUI framework mechanism for table editing. Default is false, so native framework won’t be used. For Java/Swing, this would return the a class object indicating the type of data, eg java.lang.Boolean, or java.lang.String or something from JTable.setDefaultEditor
33 34 35 |
# File 'lib/clevic/swing/delegate.rb', line 33 def native false end |
#needs_pre_selection? ⇒ Boolean
workaround for broken JTable editing starts
24 25 26 |
# File 'lib/clevic/swing/delegate.rb', line 24 def needs_pre_selection? false end |
#show_message(msg, &block) ⇒ Object
FIXME this must actually show a message, and the Qt code must use it too
13 14 15 16 17 18 19 20 21 |
# File 'lib/clevic/swing/delegate.rb', line 13 def ( msg, &block ) if block_given? @message_receivers << block else @message_receivers.each do |receiver| receiver.call( msg ) end end end |
#updateEditorGeometry(editor, style_option_view_item, model_index) ⇒ Object
Figure out where to put the editor widget, taking into account the sizes of the headers TODO most of the subclasses are probably the same as this
7 8 9 10 11 12 |
# File 'lib/clevic/qt/delegate.rb', line 7 def updateEditorGeometry( editor, style_option_view_item, model_index ) rect = style_option_view_item.rect rect.set_width( [editor.size_hint.width,rect.width].max ) rect.set_height( editor.size_hint.height ) editor.set_geometry( rect ) end |