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>

+ Inheritance diagram for EDelegateForeignKey:
+ Collaboration diagram for EDelegateForeignKey:

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. More...
 
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() [1/2]

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() [2/2]

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

◆ commitAndCloseEditor

void EDelegateForeignKey::commitAndCloseEditor ( )
privateslot
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createEditor()

QWidget * EDelegateForeignKey::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  ,
const QModelIndex &   
) const
+ Here is the call graph for this function:

◆ doCloseEditor

void EDelegateForeignKey::doCloseEditor ( )
privateslot
+ Here is the caller graph for this function:

◆ init()

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:

◆ paint()

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)

◆ reloadForeignKeys()

void EDelegateForeignKey::reloadForeignKeys ( )
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setEditorData()

void EDelegateForeignKey::setEditorData ( QWidget *  editor,
const QModelIndex &  index 
) const

◆ setModelData()

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

◆ setTranslator()

void EDelegateForeignKey::setTranslator ( QString(*)(const QString)  translator)
+ Here is the call graph for this function:

◆ updateCompleter

void EDelegateForeignKey::updateCompleter ( )
privateslot
Todo:
must be really improved
+ Here is the caller graph for this function:

Member Data Documentation

◆ mapOutIn

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

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

◆ matchCol

QString EDelegateForeignKey::matchCol
private

◆ maxComboItems

int EDelegateForeignKey::maxComboItems
private

◆ maxCompleteItems

int EDelegateForeignKey::maxCompleteItems
private

◆ resCol

QString EDelegateForeignKey::resCol
private

◆ resTable

QString EDelegateForeignKey::resTable
private

◆ resultModel

QSqlQueryModel* EDelegateForeignKey::resultModel
private

◆ timer

QTimer* EDelegateForeignKey::timer
private

◆ translator

QString(* EDelegateForeignKey::translator) (const QString)
private

Function callback to translate QString into QString.

◆ useComboBox

bool EDelegateForeignKey::useComboBox
private

◆ useCompleter

bool EDelegateForeignKey::useCompleter
private

◆ useExtendedCompleter

bool EDelegateForeignKey::useExtendedCompleter
private

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