Public Member Functions

Koo::Fields::AbstractFieldWidget::AbstractFieldWidget Class Reference

AbstractFieldWidget is the base class for all field widgets in Koo. More...

List of all members.

Public Member Functions

def __init__
 Creates a new AbstractFieldWidget and receives the following parameters parent: The QWidget parent of this QWidget view: Holds the reference to the view the widget is in attributes: Holds some extra attributes such as read-only and others.
def initGui
 This function is called the first time the widget is shown.
def setToDefault
 Sets the default value to the field.
def setAsDefault
 Opens the FieldPreferencesDialog to set the current value as default for this field.
def setReadOnly
 This function is called when the widget has to be Read-Only.
def isReadOnly
 This function returns True if the field is read-only.
def refresh
 Updates the background color depending on widget state.
def colorWidget
 Use it in your widget to return the widget in which you want the color indicating the obligatory, normal, ...
def menuEntries
 Use this function to return the menuEntries your widget wants to show just before the context menu is shown.
def setColor
 Sets the background color to the widget returned by colorWidget().
def installPopupMenu
 Installs the eventFilter on the given widget so the popup menu will be shown on ContextMenu event.
def eventFilter
 Reimplements eventFilter to show the context menu and store information when the widget loses the focus.
def showPopupMenu
 Shows a popup menu with default and widget specific entries.
def modified
 Call this function/slot when your widget changes the value.
def showValue
 Override this function.
def clear
 Override this function.
def display
 This function displays the current value of the field in the record in the widget.
def load
 Sets the current record for the widget.
def storeValue
 Stores information in the widget to the record.
def store
 Stores information in the widget to the record.

Detailed Description

AbstractFieldWidget is the base class for all field widgets in Koo.

In order to create a new field widget, that is: a widget that appears in a auto-generated form you need to inherit from this class and implement some of it's functions.

The Widget handles a field from a record. You can access the record using the property 'record' and the field name using the property 'name'.

Definition at line 47 of file AbstractFieldWidget.py.


Member Function Documentation

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::clear (   self  ) 

Override this function.

It will be used whenever there is no model or have created a new record.

Definition at line 271 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::colorWidget (   self  ) 

Use it in your widget to return the widget in which you want the color indicating the obligatory, normal, ...

etc flags to be set. By default colorWidget() returns self.

Definition at line 199 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::display (   self  ) 

This function displays the current value of the field in the record in the widget.

Do not reimplement this function, override clear() and showValue() instead

Definition at line 278 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::eventFilter (   self,
  target,
  event 
)

Reimplements eventFilter to show the context menu and store information when the widget loses the focus.

This function will be used on the widget you give to installPopupMenu.

Definition at line 227 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::initGui (   self  ) 

This function is called the first time the widget is shown.

It can be used by widgets to initialize GUI elements that are slow to execute. The advantage of using this function is that if the user never sees the widget (because it's in another tab, for example), it will never be called, improving form loading time.

It's ensured that this function is called before any call to showValue() or storeValue() happens.

Definition at line 136 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::installPopupMenu (   self,
  widget 
)

Installs the eventFilter on the given widget so the popup menu will be shown on ContextMenu event.

Also data on the widget will be stored in the record when the widget receives the FocusOut event.

Definition at line 221 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::isReadOnly (   self  ) 

This function returns True if the field is read-only.

False otherwise.

Definition at line 187 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::load (   self,
  record 
)

Sets the current record for the widget.

Definition at line 301 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::menuEntries (   self  ) 

Use this function to return the menuEntries your widget wants to show just before the context menu is shown.

Return a list of tuples in the form: [ (_('Menu text'), function/slot to connect the entry, True (for enabled) or False (for disabled) )]

Definition at line 205 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::modified (   self  ) 

Call this function/slot when your widget changes the value.

This is needed for the onchange option in the server modules. Usually you'll call it on lostFocus if there's a TextBox or on selection, etc.

Definition at line 259 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::refresh (   self  ) 

Updates the background color depending on widget state.

Possible states are: invalid, readonly, required and normal.

Definition at line 193 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::setAsDefault (   self  ) 

Opens the FieldPreferencesDialog to set the current value as default for this field.

Definition at line 153 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::setColor (   self,
  name 
)

Sets the background color to the widget returned by colorWidget().

name should contain the current state ('invalid', 'readonly', 'required' or 'normal')

The appropiate color for each state is stored in self.colors dictionary.

Definition at line 212 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::setReadOnly (   self,
  ro 
)

This function is called when the widget has to be Read-Only.

When implementing a new widget, please use setEnabled( not ro ) instead of read-only. The gray color gives information to the user so she knows the field can't be modified

Definition at line 182 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::setToDefault (   self  ) 

Sets the default value to the field.

Note that this requires a call to the server.

Definition at line 142 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::showPopupMenu (   self,
  parent,
  position 
)

Shows a popup menu with default and widget specific entries.

Definition at line 238 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::showValue (   self  ) 

Override this function.

This will be called by display() when it wants the value to be shown in the widget

Definition at line 266 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::store (   self  ) 

Stores information in the widget to the record.

This is the function you should call when you want the field to store information back into the model. This function may NOT store information if it has not changed.

Definition at line 314 of file AbstractFieldWidget.py.

def Koo::Fields::AbstractFieldWidget::AbstractFieldWidget::storeValue (   self  ) 

Stores information in the widget to the record.

Reimplement this function in your widget.

Definition at line 307 of file AbstractFieldWidget.py.


The documentation for this class was generated from the following file:
Generated by Doxygen