kexi

KexiFormView Class Reference

#include <kexiformview.h>

Inheritance diagram for KexiFormView:

KexiDataAwareView KexiViewBase KexiActionProxy List of all members.

Detailed Description

The KexiFormView lass provides a data-driven (record-based) form view .

The KexiFormView can display data provided "by hand" or from KexiDB-compatible database source.

This class provides a single view used inside KexiDialogBase. It takes care of saving/loading form, of enabling actions when needed. One KexiFormView object is instantiated for data view mode and a second KexiFormView object is instantiated for design view mode.

See also:
KexiDataTable

Definition at line 51 of file kexiformview.h.


Public Types

 ResizeAuto = 0
 ResizeDefault = ResizeAuto
 ResizeFixed = 1
 NoResize = 2
enum  ResizeMode { ResizeAuto = 0, ResizeDefault = ResizeAuto, ResizeFixed = 1, NoResize = 2 }

Public Slots

virtual void show ()
void insertAutoFields (const QString &sourceMimeType, const QString &sourceName, const QStringList &fields, const QPoint &pos=QPoint(-1,-1))

Public Member Functions

 KexiFormView (KexiMainWindow *mainWin, QWidget *parent, const char *name=0, bool dbAware=true)
virtual ~KexiFormView ()
virtual QSize preferredSizeHint (const QSize &otherSize)
int resizeMode () const
KFormDesigner::Formform () const
void setUnsavedLocalBLOB (QWidget *widget, KexiBLOBBuffer::Id_t id)

Protected Slots

void slotPropertySetSwitched (KoProperty::Set *b, bool forceReload=false)
void slotDirty (KFormDesigner::Form *f, bool isDirty)
void slotFocus (bool in)
void slotHandleDragMoveEvent (QDragMoveEvent *e)
void slotHandleDropEvent (QDropEvent *e)

Protected Member Functions

virtual tristate beforeSwitchTo (int mode, bool &dontStore)
virtual tristate afterSwitchFrom (int mode)
virtual KoProperty::Set * propertySet ()
virtual KexiDB::SchemaDatastoreNewData (const KexiDB::SchemaData &sdata, bool &cancel)
virtual tristate storeData (bool dontAsk=false)
KexiFormPart::TempDatatempData () const
KexiFormPartformPart () const
void setForm (KFormDesigner::Form *f)
void initForm ()
void loadForm ()
void updateAutoFieldsDataSource ()
virtual void resizeEvent (QResizeEvent *)
void initDataSource ()
virtual void setFocusInternal ()
void updateTabStopsOrder ()
void deleteQuery ()
void updateDataSourcePage ()

Protected Attributes

KexiDBFormm_dbform
KexiFormScrollViewm_scrollView
KoProperty::Set * m_propertySet
QString m_previousDataSourceString
int m_resizeMode
KexiDB::QuerySchemam_query
bool m_queryIsOwned
KexiDB::Cursorm_cursor
int m_delayedFormContentsResizeOnShow
QGuardedPtr< QWidget > m_setFocusInternalOnce
QRect m_widgetGeometryForRecentInsertAutoFields
QMap< QWidget *, KexiBLOBBuffer::Id_tm_unsavedLocalBLOBs

Constructor & Destructor Documentation

KexiFormView::KexiFormView ( KexiMainWindow mainWin,
QWidget *  parent,
const char *  name = 0,
bool  dbAware = true 
)

Todo:
define KEXI_SHOW_SPLITTER_WIDGET

Todo:
skip this if ther're no borders

Definition at line 60 of file kexiformview.cpp.


Member Function Documentation

tristate KexiFormView::afterSwitchFrom ( int  mode  )  [protected, virtual]

called by KexiDialogBase::switchToViewMode() right after dialog is switched to new mode By default does nothing. Reimplement this if you need to do something after switching to this view.

Returns:
true if you accept or false if a error occupied and view shouldn't change If there is no error but switching should be just cancelled (probably after showing some info messages), you need to return cancelled.

Reimplemented from KexiViewBase.

Definition at line 377 of file kexiformview.cpp.

tristate KexiFormView::beforeSwitchTo ( int  mode,
bool &  dontStore 
) [protected, virtual]

called by KexiDialogBase::switchToViewMode() right before dialog is switched to new mode By default does nothing. Reimplement this if you need to do something before switching to this view.

Returns:
true if you accept or false if a error occupied and view shouldn't change If there is no error but switching should be just cancelled (probably after showing some info messages), you need to return cancelled. Set dontStore to true (it's false by default) if you want to avoid data storing by storeData() or storeNewData().

Reimplemented from KexiViewBase.

Definition at line 349 of file kexiformview.cpp.

void KexiFormView::deleteQuery (  )  [protected]

Definition at line 180 of file kexiformview.cpp.

void KexiFormView::initDataSource (  )  [protected]

Definition at line 478 of file kexiformview.cpp.

void KexiFormView::initForm (  )  [protected]

Definition at line 209 of file kexiformview.cpp.

void KexiFormView::insertAutoFields ( const QString &  sourceMimeType,
const QString &  sourceName,
const QStringList &  fields,
const QPoint &  pos = QPoint(-1,-1) 
) [slot]

Inserts autofields onto the form at pos position. sourceMimeType can be "kexi/table" or "kexi/query", sourceName is a name of a table or query, fields is a list of fields to insert (one or more) Fields are inserted using standard KFormDesigner::InsertWidgetCommand framework, so undo/redo is available for this operation.

If multiple fields are provided, they will be aligned vertically. If pos is QPoint(-1,-1) (the default), position is computed automatically based on a position last inserted field using this method. If this method has not been called yet, position of QPoint(40, 40) will be set.

Called by:

todo unnamed query colums are not supported

todo add autolabel using field's caption or name

todo this is hardcoded!

todo this name can be invalid for expressions: if so, fall back to a default class' prefix!

addToActiveForm

execFlagForSubCommands

Definition at line 985 of file kexiformview.cpp.

QSize KexiFormView::preferredSizeHint ( const QSize &  otherSize  )  [virtual]

Returns:
preferred size hint, that can be used to resize the view. It is computed using maximum of (a) otherSize and (b) current KMDI dock area's size, so the view won't exceed this maximum size. The method is used e.g. in KexiDialogBase::sizeHint(). If you reimplement this method, dont forget to return value of yoursize.boundedTo( KexiViewBase::preferredSizeHint(otherSize) ).

Reimplemented from KexiViewBase.

Definition at line 876 of file kexiformview.cpp.

virtual KoProperty::Set* KexiFormView::propertySet (  )  [inline, protected, virtual]

Returns:
a property set for this view. For reimplementation. By default returns NULL.

Reimplemented from KexiViewBase.

Definition at line 131 of file kexiformview.h.

void KexiFormView::setUnsavedLocalBLOB ( QWidget *  widget,
KexiBLOBBuffer::Id_t  id 
)

Assigns id local (static) BLOB's identifier for widget widget. Previously assigned BLOB will be usassigned. If id is 0, BLOB is unassigned and no new is assigned.

This method is called when a widget supporting BLOB data (currently, images from KexiDBImageBox, within KexiDBFactory) has BLOB assigned by identifier id. BLOB identifiers are defined by KexiBLOBBuffer (KexiBLOBBuffer::self() instance).

The data collected by this method is used on form's design saving (in design mode). Local BLOBs are retrieved KexiBLOBBuffer::self() and stored in "kexi__blobs" 'system' table. Note that db-aware BLOBs (non local) are not handled this way.

Todo:
if there already was data assigned, remember it should be dereferenced

Definition at line 1123 of file kexiformview.cpp.

void KexiFormView::show (  )  [virtual, slot]

Reimplemented to update resize policy.

Definition at line 925 of file kexiformview.cpp.

void KexiFormView::slotHandleDropEvent ( QDropEvent *  e  )  [protected, slot]

Handles field(s) dropping from the data source pane onto the form.

See also:
insertAutoFields()

Definition at line 973 of file kexiformview.cpp.

tristate KexiFormView::storeData ( bool  dontAsk = false  )  [protected, virtual]

Tells this view to store data changes on the backend. Called by KexiDialogBase::storeData(). Default implementation:

  • makes a deep copy of sdata
  • stores object schema data sdata in 'kexi__objects' internal table using Connection::storeObjectSchemaData(). If dontAsk is true, no question dialog will be shown to the user. The default is false.

Reimpelment this for your needs. Should return true on success or cancelled when the task should be cancelled.

See also:
storeNewData()

Reimplemented from KexiViewBase.

Definition at line 640 of file kexiformview.cpp.

KexiDB::SchemaData * KexiFormView::storeNewData ( const KexiDB::SchemaData sdata,
bool &  cancel 
) [protected, virtual]

Tells this dialog to create and store data of the new object pointed by sdata on the backend. Called by KexiDialogBase::storeNewData(). Default implementation:

  • makes a deep copy of sdata
  • stores object schema data sdata in 'kexi__objects' internal table using Connection::storeObjectSchemaData(). Reimpelment this for your needs. Requirements:
  • deep copy of sdata should be made
  • schema data should be created at the backend (by calling KexiViewBase::storeNewData(const KexiDB::SchemaData& sdata)), or using Connection::storeObjectSchemaData() or more specialized method. For example, KexiAlterTableDialog uses Connection::createTable(TableSchema) for this (tableschema is SchemaData subclass) to store more information than just a schem adata. You should use such subclasses if needed. Should return newly created schema data object on success. In this case, do not store schema object yourself (make deep copy if needed).

Reimplemented from KexiViewBase.

Definition at line 620 of file kexiformview.cpp.

void KexiFormView::updateAutoFieldsDataSource (  )  [protected]

Definition at line 280 of file kexiformview.cpp.

void KexiFormView::updateTabStopsOrder (  )  [protected]

Called after loading the form contents (before showing it). Also called when the form window (KexiDialogBase) is detached (in KMDI's Child Frame mode), because otherwise tabstop ordering can get broken.


Member Data Documentation

Reimplemented after KexiViewBase. Updates actions (e.g. availability).

Definition at line 178 of file kexiformview.h.

For new (empty) forms only: Our form's area will be resized more than once. We will resize form widget itself later (in resizeEvent()).

Definition at line 202 of file kexiformview.h.

Database cursor used for data retrieving. It is shared between subsequent Data view sessions (just reopened on switch), but deleted and recreated from scratch when form's "dataSource" property changed since last form viewing (m_previousDataSourceString is used for that).

Definition at line 186 of file kexiformview.h.

bool KexiFormView::m_queryIsOwned [protected]

True, if m_query is created as temporary object within this form. If user selected an existing, predefined (stored) query, m_queryIsOwned will be false, so the query object will not be destroyed.

Definition at line 195 of file kexiformview.h.

QGuardedPtr<QWidget> KexiFormView::m_setFocusInternalOnce [protected]

Used in setFocusInternal().

Definition at line 205 of file kexiformview.h.

Used in setUnsavedLocalBLOBs().

Definition at line 216 of file kexiformview.h.

Stores geometry of widget recently inserted using insertAutoFields() method. having this information, we'r eable to compute position for a newly inserted widget in insertAutoFields() is such position has not been specified. (the position is specified when a widget is inserted with mouse drag & dropping but not with clicking of 'Insert fields' button from Data Source pane)

Definition at line 213 of file kexiformview.h.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys