LibEngsas
Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
EDelegateForeignKey Class Reference

A delegate to display and edit foreign keys from SQL tables. More...

#include <edelegateforeignkey.h>

Public Member Functions

 EDelegateForeignKey (QString table, QString matchColumn, QString resultColumn, QWidget *parent=0)
 EDelegateForeignKey (QString table, QString matchColumn, QString resultColumn, QString(*translator)(const QString), QWidget *parent=0)
 Constructor to supply an translator callback.
void setTranslator (QString(*translator)(const QString))
void reloadForeignKeys ()
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
void setEditorData (QWidget *editor, const QModelIndex &index) const
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const

Private Slots

void commitAndCloseEditor ()
void doCloseEditor ()
void updateCompleter ()

Private Member Functions

void init (QString table, QString matchColumn, QString resultColumn)

Private Attributes

QMap< QString, unsigned int > mapOutIn
QString resTable
QString matchCol
QString resCol
QSqlQueryModel * resultModel
int maxComboItems
int maxCompleteItems
bool useComboBox
bool useCompleter
bool useExtendedCompleter
QTimer * timer
QString(* translator )(const QString)

Detailed Description

A delegate to display and edit foreign keys from SQL tables.

If there are more than maxComboItems, it switches to QLineEdit with autocompletion if there are more than maxCompleteItems, it loads the completer after 3 inserted characters to reduce load.

To translate the mapped function, set the translator callback to an apropriate function with setTranslator() or the related constructor.

Todo:

last one is not useable right now

use ESqlDatabase if it is available

The completer model does not support translations yet

Constructor & Destructor Documentation

EDelegateForeignKey::EDelegateForeignKey ( QString  table,
QString  matchColumn,
QString  resultColumn,
QWidget *  parent = 0 
)
Parameters
tablethe table where the foreignkey points to
matchColumnthe column which is the same in showed table and foreignkey table (at table table)
resultColumnthe column at the foreignkey table which holds the content to be displayed
See Also
EDelegateForeignKey(QString, QString, QString, QString (*)(const QString), QWidget*)

+ Here is the call graph for this function:

EDelegateForeignKey::EDelegateForeignKey ( QString  table,
QString  matchColumn,
QString  resultColumn,
QString(*)(const QString)  translator,
QWidget *  parent = 0 
)

Constructor to supply an translator callback.

See Also
EDelegateForeignKey(QString, QString, QString, QWidget*)

+ Here is the call graph for this function:

Member Function Documentation

void EDelegateForeignKey::commitAndCloseEditor ( )
privateslot

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QWidget * EDelegateForeignKey::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  ,
const QModelIndex &   
) const

+ Here is the call graph for this function:

void EDelegateForeignKey::doCloseEditor ( )
privateslot

+ Here is the caller graph for this function:

void EDelegateForeignKey::init ( QString  table,
QString  matchColumn,
QString  resultColumn 
)
private

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void EDelegateForeignKey::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
Todo:
must be really improved to use QCompleter with only part of the table (useExtendedCompleter)
void EDelegateForeignKey::reloadForeignKeys ( )

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void EDelegateForeignKey::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const
void EDelegateForeignKey::setModelData ( QWidget *  editor,
QAbstractItemModel *  model,
const QModelIndex &  index 
) const
void EDelegateForeignKey::setTranslator ( QString(*)(const QString)  translator)

+ Here is the call graph for this function:

void EDelegateForeignKey::updateCompleter ( )
privateslot
Todo:
must be really improved

+ Here is the caller graph for this function:

Member Data Documentation

QMap<QString, unsigned int> EDelegateForeignKey::mapOutIn
private

the QString, int order is needed, because the entries should be ordered after the string's

QString EDelegateForeignKey::matchCol
private
int EDelegateForeignKey::maxComboItems
private
int EDelegateForeignKey::maxCompleteItems
private
QString EDelegateForeignKey::resCol
private
QString EDelegateForeignKey::resTable
private
QSqlQueryModel* EDelegateForeignKey::resultModel
private
QTimer* EDelegateForeignKey::timer
private
QString(* EDelegateForeignKey::translator)(const QString)
private

Function callback to translate QString into QString.

bool EDelegateForeignKey::useComboBox
private
bool EDelegateForeignKey::useCompleter
private
bool EDelegateForeignKey::useExtendedCompleter
private

The documentation for this class was generated from the following files: