kexi

KexiTableDesignerView Class Reference

#include <kexitabledesignerview.h>

Inheritance diagram for KexiTableDesignerView:

KexiDataTable KexiTableDesignerInterface KexiDataAwareView KexiViewBase KexiActionProxy List of all members.

Detailed Description

Design view of the Table Designer.

Contains a spreadsheet-like space for entering field definitions. Property editor is provided for altering field definitions.

The view also supports Undo and Redo operations. These are connected to a factility creating a list of actions used by AlterTableHandler to perform required operation of altering the table.

Altering itself is performed upon design saving (storeData()). Saving unstored designs just creates a new table. Saving changes made to empty (not filled with data) table is performed by physically deleting the previous table schema and recreating it TODO: this will be not quite when we have db relationships supported.

Saving changes made to table containing data requires use of the AlterTableHandler functionality.

Definition at line 56 of file kexitabledesignerview.h.


Public Slots

virtual tristate executeRealAlterTable ()

Public Member Functions

 KexiTableDesignerView (KexiMainWindow *win, QWidget *parent)
virtual ~KexiTableDesignerView ()
KexiTablePart::TempDatatempData () const
virtual void clearRow (int row, bool addCommand=false)
virtual void insertField (int row, const QString &caption, bool addCommand=false)
virtual void insertField (int row, KoProperty::Set &set, bool addCommand=false)
virtual void insertEmptyRow (int row, bool addCommand=false)
virtual void deleteRow (int row, bool addCommand=false)
virtual void changeFieldPropertyForRow (int row, const QCString &propertyName, const QVariant &newValue, KoProperty::Property::ListData *const listData, bool addCommand)
void changeFieldProperty (int fieldUID, const QCString &propertyName, const QVariant &newValue, KoProperty::Property::ListData *const listData=0, bool addCommand=false)
void changePropertyVisibility (int fieldUID, const QCString &propertyName, bool visible)
KexiDB::FieldbuildField (const KoProperty::Set &set) const
virtual QString debugStringForCurrentTableSchema (tristate &result)
virtual tristate simulateAlterTableExecution (QString *debugTarget)

Protected Slots

void updateActions ()
virtual void slotUpdateRowActions (int row)
void slotAboutToShowContextMenu ()
void slotBeforeCellChanged (KexiTableItem *item, int colnum, QVariant &newValue, KexiDB::ResultInfo *result)
void slotRowUpdated (KexiTableItem *item)
void slotRowInserted ()
void slotAboutToDeleteRow (KexiTableItem &item, KexiDB::ResultInfo *result, bool repaint)
void slotPropertyChanged (KoProperty::Set &set, KoProperty::Property &property)
void slotTogglePrimaryKey ()
void slotUndo ()
void slotRedo ()
void slotCommandExecuted (KCommand *command)
void slotSimulateAlterTableExecution ()

Protected Member Functions

virtual void updateActions (bool activated)
void initData ()
KoProperty::Set * createPropertySet (int row, const KexiDB::Field &field, bool newOne=false)
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)
tristate buildSchema (KexiDB::TableSchema &schema, bool beSilent=false)
tristate buildAlterTableActions (KexiDB::AlterTableHandler::ActionList &actions)
void switchPrimaryKey (KoProperty::Set &propertySet, bool set, bool aWasPKey=false, CommandGroup *commandGroup=0)
void getSubTypeListData (KexiDB::Field::TypeGroup fieldTypeGroup, QStringList &stringsList, QStringList &namesList)
void addHistoryCommand (KCommand *command, bool execute)
void updateUndoRedoActions ()
void insertFieldInternal (int row, KoProperty::Set *set, const QString &caption, bool addCommand)
virtual void propertySetSwitched ()

Constructor & Destructor Documentation

KexiTableDesignerView::KexiTableDesignerView ( KexiMainWindow win,
QWidget *  parent 
)

Creates a new alter table dialog.

Definition at line 107 of file kexitabledesignerview.cpp.


Member Function Documentation

void KexiTableDesignerView::clearRow ( int  row,
bool  addCommand = false 
) [virtual]

Clears field information entered for row. This is performed by removing values from caption and data type columns. Used by InsertFieldCommand to undo inserting a new field.

Implements KexiTableDesignerInterface.

Definition at line 1654 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::insertField ( int  row,
const QString &  caption,
bool  addCommand = false 
) [virtual]

Inserts a new field with caption for row. Property set is also created.

Implements KexiTableDesignerInterface.

Definition at line 1679 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::insertField ( int  row,
KoProperty::Set &  set,
bool  addCommand = false 
) [virtual]

Inserts a new field for row. Property set is also created. set will be deeply-copied into the new set. Used by InsertFieldCommand to insert a new field.

Implements KexiTableDesignerInterface.

Definition at line 1684 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::insertEmptyRow ( int  row,
bool  addCommand = false 
) [virtual]

Inserts a new empty row at position row. Used by RemoveFieldCommand as a part of undo inserting a new field; also used by InsertEmptyRowCommand.

Implements KexiTableDesignerInterface.

Definition at line 1736 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::deleteRow ( int  row,
bool  addCommand = false 
) [virtual]

Deletes row from the table view. Property set is also deleted. All the subsequent fields are moved up. Used for undoing InsertEmptyRowCommand and by RemoveFieldCommand to remove a field.

Implements KexiTableDesignerInterface.

Definition at line 1754 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::changeFieldPropertyForRow ( int  row,
const QCString &  propertyName,
const QVariant &  newValue,
KoProperty::Property::ListData *const   listData,
bool  addCommand 
) [virtual]

Changes property propertyName to newValue for a field at row row. If listData is not NULL and not empty, a deep copy of it is passed to Property::setListData(). If listData nlist if not NULL but empty, Property::setListData(0) is called.

Implements KexiTableDesignerInterface.

Definition at line 1770 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::changeFieldProperty ( int  fieldUID,
const QCString &  propertyName,
const QVariant &  newValue,
KoProperty::Property::ListData *const   listData = 0,
bool  addCommand = false 
)

Changes property propertyName to newValue. Works exactly like changeFieldPropertyForRow() except the field is pointed by fieldUID. Used by ChangeFieldPropertyCommand to change field's property.

Definition at line 1843 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::changePropertyVisibility ( int  fieldUID,
const QCString &  propertyName,
bool  visible 
)

Changes visibility of property propertyName to visible for a field pointed by fieldUID. Used by ChangePropertyVisibilityCommand.

Definition at line 1856 of file kexitabledesignerview.cpp.

KexiDB::Field * KexiTableDesignerView::buildField ( const KoProperty::Set &  set  )  const

Builds table field's schema by looking at the set.

Definition at line 1161 of file kexitabledesignerview.cpp.

QString KexiTableDesignerView::debugStringForCurrentTableSchema ( tristate result  )  [virtual]

Creates temporary table for the current design and returns debug string for it.

Implements KexiTableDesignerInterface.

Definition at line 1641 of file kexitabledesignerview.cpp.

tristate KexiTableDesignerView::simulateAlterTableExecution ( QString *  debugTarget  )  [virtual]

Simulates execution of alter table, and puts debug into debugTarget. A case when debugTarget is not 0 is true for the alter table test suite.

Implements KexiTableDesignerInterface.

Definition at line 1496 of file kexitabledesignerview.cpp.

tristate KexiTableDesignerView::executeRealAlterTable (  )  [virtual, slot]

Real execution of the Alter Table. For debugging of the real alter table.

Returns:
true on success, false on failure and cancelled if user has cancelled execution.

Implements KexiTableDesignerInterface.

Definition at line 1528 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::updateActions (  )  [protected, slot]

Equivalent to updateActions(false). Called on row insert/delete in a KexiDataAwarePropertySet.

Definition at line 909 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotAboutToShowContextMenu (  )  [protected, slot]

Definition at line 1625 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotBeforeCellChanged ( KexiTableItem item,
int  colnum,
QVariant &  newValue,
KexiDB::ResultInfo result 
) [protected, slot]

Called before cell change in tableview.

forceAddCommand

Todo:
maybe this is good for other data types as well?

forceAddCommand

rememberOldValue

forceAddCommand

rememberOldValue

Todo:
should we display (passive?) dialog informing about cleared pkey?

rememberOldValue

Definition at line 650 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotRowUpdated ( KexiTableItem item  )  [protected, slot]

Called on row change in a tableview.

Definition at line 827 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotRowInserted (  )  [protected, slot]

Called before row inserting in tableview.

Definition at line 1129 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotAboutToDeleteRow ( KexiTableItem item,
KexiDB::ResultInfo result,
bool  repaint 
) [protected, slot]

Called before row deleting in tableview.

Definition at line 1142 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotPropertyChanged ( KoProperty::Set &  set,
KoProperty::Property &  property 
) [protected, slot]

Called after any property has been changed in the current property set, to perform some actions (like updating other dependent properties)

Todo:
indicate invalid definitions of lookup columns as well using a special icon (e.g. due to missing data source)

Todo:
perhaps show a hint in help panel telling what happens?

Todo:
: add setting for this: "Integer PKeys have autonumber set by default"

set PK to false

Definition at line 914 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotTogglePrimaryKey (  )  [protected, slot]

Toggles primary key for currently selected field. Does nothing for empty row.

Definition at line 479 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotUndo (  )  [protected, slot]

Undoes the recently performed action.

Definition at line 1596 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotRedo (  )  [protected, slot]

Redoes the recently undoed action.

Definition at line 1607 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotCommandExecuted ( KCommand *  command  )  [protected, slot]

Reaction on command execution from the command history

Definition at line 1618 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::slotSimulateAlterTableExecution (  )  [protected, slot]

Simulates real execution of the Alter Table. For debugging.

Definition at line 1523 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::updateActions ( bool  activated  )  [protected, virtual]

Updates actions (e.g. availability). Reimplement it, if needed (you must call superclass impelmentation at the end!). This implementation does nothing for this view but calls updateActions() for every child-view of this view. called by KexiDialogBase on dialog's activation (activated is true) or deactivation.

Reimplemented from KexiDataAwareView.

Definition at line 460 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::initData (  )  [protected]

called whenever data should be reloaded (on switching to this view mode)

Definition at line 210 of file kexitabledesignerview.cpp.

KoProperty::Set * KexiTableDesignerView::createPropertySet ( int  row,
const KexiDB::Field field,
bool  newOne = false 
) [protected]

Creates a new property set for field. The property set will be asigned to row, and owned by this dialog. If newOne is true, the property set will be marked as newly created.

Returns:
newly created property set.

Todo:
add table_field icon

Todo:
this should be retrieved from KexiDB::Field when BLOB supports many different mimetypes

Todo:
set reasonable default for column width

Todo:
use "Variant" type here when supported by KoProperty

Todo:
support columnWidths(), columnHeadersVisible(), maximumListRows(), limitToList(), displayWidget()

Definition at line 304 of file kexitabledesignerview.cpp.

tristate KexiTableDesignerView::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 574 of file kexitabledesignerview.cpp.

tristate KexiTableDesignerView::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 621 of file kexitabledesignerview.cpp.

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

Returns:
property set associated with currently selected row (i.e. field) or 0 if current row is empty.

Reimplemented from KexiViewBase.

Definition at line 629 of file kexitabledesignerview.cpp.

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

Reimplemented from KexiViewBase, because tables creation is more complex. No table schema altering is required, so just buildSchema() is used to create a new schema.

Reimplemented from KexiViewBase.

Definition at line 1375 of file kexitabledesignerview.cpp.

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

Reimplemented from KexiViewBase, because table storage is more complex. Table schema altering may be required, so just buildSchema() is used to create a new schema.

Todo:
temp; remove this:

Todo:
: result?

Todo:
temp; remove this:

Reimplemented from KexiViewBase.

Definition at line 1411 of file kexitabledesignerview.cpp.

tristate KexiTableDesignerView::buildSchema ( KexiDB::TableSchema schema,
bool  beSilent = false 
) [protected]

Builds table schema by looking at the current design. Used in storeNewData() and storeData(). If beSilent is true, no message boxes are used to show questions or warnings. This is used in the altertable test suite (kexi/tests/altertable).

Returns:
true on successful schema creating, false on failure and cancelled when there was a problem with user's design (and user has been informed about it).

Todo:
for "names hidden" mode we won't get this error because user is unable to change names

Todo:
support columnWidths(), columnHeadersVisible(), maximumListRows(), limitToList(), displayWidget()

Definition at line 1191 of file kexitabledesignerview.cpp.

tristate KexiTableDesignerView::buildAlterTableActions ( KexiDB::AlterTableHandler::ActionList actions  )  [protected]

Builds action list usable for KexiDB::AlterTableHandler by looking at undo buffer of commands' history. Used in storeData()

Definition at line 1364 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::switchPrimaryKey ( KoProperty::Set &  propertySet,
bool  set,
bool  aWasPKey = false,
CommandGroup *  commandGroup = 0 
) [protected]

Helper, used for slotTogglePrimaryKey() and slotPropertyChanged(). Assigns primary key icon and value for property set propertySet, and deselects it from previous pkey's row. aWasPKey is internal. If commandGroup is not 0, it is used as parent group for storing actions' history.

Definition at line 503 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::getSubTypeListData ( KexiDB::Field::TypeGroup  fieldTypeGroup,
QStringList &  stringsList,
QStringList &  namesList 
) [protected]

Gets subtype strings and names for type fieldType.

Definition at line 285 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::addHistoryCommand ( KCommand *  command,
bool  execute 
) [protected]

Adds history command command to the undo/redo buffer. If execute is true, the command is executed afterwards.

Definition at line 1577 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::updateUndoRedoActions (  )  [protected]

Updates undo/redo shared actions availability by looking at command history's action.

Definition at line 1588 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::insertFieldInternal ( int  row,
KoProperty::Set *  set,
const QString &  caption,
bool  addCommand 
) [protected]

Inserts a new field for row. Property set is also created. If set is not 0 (the default), it will be copied into the new set. Used by insertField().

Definition at line 1689 of file kexitabledesignerview.cpp.

void KexiTableDesignerView::propertySetSwitched (  )  [protected, virtual]

Reimplemented to pass the information also to the "Lookup" tab.

Reimplemented from KexiViewBase.

Definition at line 1881 of file kexitabledesignerview.cpp.


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