gSAFE  1.3.8
Signals | Public Member Functions | Public Attributes | Protected Attributes | List of all members
HSqlChoose Class Reference

#include <datalib.h>

Inheritance diagram for HSqlChoose:
HDataField HSqlHandler HSqlInterface HBase

Signals

void dataUpdatedSignal (void)
 
void doWorking (void)
 
void endWorking (void)
 
void startWorking (void)
 
- Signals inherited from HDataField
void dataChanged (void)
 
void disableControl (void)
 
void enableControl (void)
 
void updateStaticDisplayElementsSignal (void)
 
- Signals inherited from HSqlHandler
void errorSignal (QString err)
 

Public Member Functions

 HSqlChoose (QString sqlc, QString ex, QString tit, QString def, QString ct, QString kf, QString sf, QString sfh, QString fp, QString op, QString inthash="", bool easyf=true)
 
 HSqlChoose (HSqlChoose *t)
 
 ~HSqlChoose (void)
 
void addExtraFunction (int pos, const QObject *receiver, QString text)
 
void addToolButton (const QObject *receiver, QString text)
 
virtual QVariant dbValueToDispValue (QVariant v)
 
void deepcopy_from (HSqlChoose *x)
 
void deferredSqlRefresh (void)
 
void disableEasyForm (void)
 
void enableEasyForm (void)
 
virtual HDataFieldget_clone (void)
 
QString getConnectedTableName (void)
 
bool getEasyForm (void)
 
QString getFieldHeads (void)
 
int getGuiSortIndicator (void)
 
QStringList & getKeys (void)
 
QString getPopupDialogTitle (void)
 
QStringList & getSeparatedValues (void)
 
virtual QString getSQLValue (void)
 
virtual QString getSQLValueAsString (void)
 
virtual QVariant getValue (void)
 
QStringList & getValues (void)
 
int refreshSqlValues (bool emitsignal=true, bool tdisabled=false)
 
void removeExtraFunction (void)
 
void removeToolButton (void)
 
void resetPopupDialogTitle (void)
 
virtual int setDefval (QVariant v)
 
void setFilterPart (QString fp)
 
void setGuiSortIndicator (int i)
 
void setHashFunction (int(*nh)(const char *))
 
void setInernalHashFunction (QString hashname)
 
void setPopupDialogTitle (QString title)
 
virtual int setValue (QVariant v, bool sdisabled=false)
 
virtual QString sqlCreateStringPart (QString switches="")
 
virtual QString sqlInsertHead (void)
 
virtual QString sqlInsertValue (void)
 
virtual QString sqlSelectHead (void)
 
virtual QString sqlUpdate (void)
 
- Public Member Functions inherited from HDataField
 HDataField (QString _sqlColumn, QString _explain, QString tit, QString _tailstr="", bool _editable=true)
 
 HDataField (HDataField *t)
 
 ~HDataField (void)
 
virtual bool acceptFunction (void)
 
virtual bool acceptSubselect (void)
 
void addMark (QString mark)
 
void addMark (QStringList pmarkers)
 
void addNotValidValue (QString v)
 
void addRole (HDataFieldRole role)
 
QStringList allMarker (void)
 
HDataFieldasColored (int r, int g, int b)
 
HDataFieldasConstant (void)
 
HDataFieldasHide (void)
 
void clearMarkers (void)
 
void clearNotValidValues (void)
 
void clearRoles (void)
 
void clearSqlSynced (void)
 
void deepcopy_from_hdatafield (HDataField *x)
 
QVariant defvalParser (QString s)
 
void delRole (QString name)
 
void doSet (void)
 
int editBoxMaxWidth (void)
 
int getBColor (void)
 
QString getDefaultValue (void)
 
virtual QVariant getDispValue ()
 
QString getExplainText (void)
 
QString getFunction (void)
 
int getGColor (void)
 
bool getLastValidateStatus ()
 
bool getPermanentValidateStatus ()
 
int getPrintCellWidth (void)
 
int getRColor (void)
 
QString getSpecDisplaySortMode (void)
 
QString getSubselect (void)
 
QString getTailText (void)
 
QString getTitleText (void)
 
bool hasMark (QString mark)
 
bool isEditable (void)
 
bool isGuienabled (void)
 
bool isLogged (void)
 
bool isMeldedWithNext (void)
 
bool isNoMiddleStretch (void)
 
bool isPrintCellWrap (void)
 
bool isReallyChanged (void)
 
bool isSet (void)
 
bool isShow (void)
 
bool isSQLField (void)
 
virtual QString lowerValidate (void)
 
void meldWithNext (void)
 
void noMiddleStretch (void)
 
void notSet (void)
 
void resetFunction (void)
 
void resetLogging (void)
 
void resetMeldWithNext (void)
 
void resetNoMiddleStretch (void)
 
void resetSubselect (void)
 
void resetValidateStatus ()
 
int returnToDefault (void)
 
void setColor (int r, int g, int b)
 
void setData (QString _sqlColumn, QString _explain, QString tit, QString _tailstr="", bool _editable=true)
 
void setEditable (void)
 
void setEditBoxMaxWidth (int max)
 
void setExplainText (QString expl)
 
void setFunction (QString func)
 
void setGuidisabled (void)
 
void setGuienabled (void)
 
void setHide (void)
 
void setLogging (void)
 
void setMaulallyValidateError (QString message)
 
void setNotValidValues (QStringList nvl)
 
void setPrintCellNoWrap (void)
 
void setPrintCellWidth (int w)
 
void setPrintCellWrap (void)
 
void setReadonly (void)
 
void setShow (void)
 
void setSpecDisplaySortMode (QString m)
 
void setSubselect (QString subs)
 
void setTailText (QString tail)
 
void setTitleText (QString titl)
 
void setValidator (QString v="")
 
void sqlSynced (HDataChangeLogger *dclog=NULL, bool forcechange=false, bool forcelog=false)
 
void useRole (QString name)
 
QString validate (void)
 
virtual void value_changed ()
 
- Public Member Functions inherited from HSqlHandler
 HSqlHandler (void)
 
 ~HSqlHandler (void)
 
QSqlQuery * allocateQSqlQuery (void)
 
void cloneSqlSettingsFrom (HSqlHandler *other)
 
void commit (void)
 
bool errorStatus (void)
 
void rollback (void)
 
bool submit0ResultQuery (QString q, QString err, bool tdisabled=false)
 
QVariant submit1ResultQuery (QString q, QString err, bool tdisabled=false)
 
HPlainDataMatrixsubmitNResultQuery (int N, QString q, QString err, bool tdisabled=false)
 
void transaction (void)
 
QSqlDatabase workDB (void)
 
- Public Member Functions inherited from HSqlInterface
 HSqlInterface ()
 
 ~HSqlInterface ()
 
void cloneSqlInterfaceSettingsFrom (HSqlInterface *other)
 
HSqlSingleInterfacemyInterface (void)
 
QString sqlConcatenateToLocal (QString string)
 
QString sqlConcatenateToLocal (QStringList fields)
 
- Public Member Functions inherited from HBase
 HBase (void)
 
 ~HBase (void)
 
QString getWhoami (void)
 

Public Attributes

QString btext
 
const QObject * extrafunc_receiver [5]
 
QString extrafunc_text [5]
 
bool progress_on_read
 
QString toolbarbutton_down_text
 
const QObject * toolbrec
 
- Public Attributes inherited from HDataField
QString conn_sqlTable
 
bool connected
 

Protected Attributes

QString connected_table
 
bool easyform
 
QString filter_part
 
int(* hash )(const char *)
 
QString key_field
 
QStringList keys
 
int maxhash
 
QString order_part
 
KVPair * pairs
 
QString popupdialog_title
 
bool readed_reftable
 
QStringList sepvalues
 
QString showed_field
 
QString showed_field_head
 
int sortc
 
QString value
 
QStringList values
 
- Protected Attributes inherited from HDataField
int color_b
 
int color_g
 
int color_r
 
QString defval
 
QString derived
 
bool editable
 
int editboxmaxwidth
 
QString explain
 
QString function
 
bool guienabled
 
bool lastvalidate_result
 
bool logged
 
QString manual_validate_error
 
QStringList markers
 
bool meldwithnext
 
bool nomiddlestretch
 
QStringList notvalid
 
bool permanentvalidate_result
 
QList< HDataFieldRoleroles
 
int set
 
bool show
 
QString spec_disp_sort
 
bool sql
 
QString sqlColumn
 
bool sync_valueInSql
 
QString tailstr
 
QString title
 
QString valid
 
QString valueInSql
 
bool wcell_print
 
int wcellw_print
 
- Protected Attributes inherited from HSqlHandler
bool query_error_occured
 
- Protected Attributes inherited from HBase
QString whoami
 

Additional Inherited Members

- Public Slots inherited from HDataField
void disableControlSlot (void)
 
void enableControlSlot (void)
 
- Static Public Member Functions inherited from HSqlHandler
static void setCustomSqlDatabase (QString databaseName, QString sqlinterfacename="")
 
static void setDefaultSqlDatabase (void)
 
- Static Public Member Functions inherited from HSqlInterface
static HSqlSingleInterfacecurrentDefaultSqlInterface (void)
 
static HSqlSingleInterfacegetSqlInterface (QString interfacename)
 
static void setSqlMode (QString modename)
 
static void setSqlModeBackToFirst (void)
 
- Static Public Attributes inherited from HSqlHandler
static int trans = 0
 

Detailed Description

This is a field type class. The HSqlChoose holds a key value which is pointed a record in a different table. This field is a varchar in the database. You can browse the elements of the referenced table, and after you finish The field's value will contain the key of the selected record.
You have to set many parameters to specify this connection (You can see examples in brackets)

When the records of the referenced table are queried the select looks like this (according to example):

SELECT p_id,firstname || '|' || lastname || '|' || birthdate FROM persons WHERE age > 18 ORDER BY firstname,lastname,birthdate;

The HSqlChoose have two gui method to select the referenced record. This two modes can be set by easyform attribute:

The HSqlChoose uses a hash mechanism to store the keys. You can use three different hash function to speed up the browsing "nullhash","charcodehash","dropchar" .

Gui appearance: A combobox with a refresh button if easyform is true, otherwise a simple push button with a selected value. If you hit this pushbutton a new dialog is popupped with an element browser. (easyform-true: QComboBox easyform-false: HDialog,HTableBrowser)

Definition at line 3319 of file datalib.h.

Constructor & Destructor Documentation

HSqlChoose::HSqlChoose ( QString  sqlc,
QString  ex,
QString  tit,
QString  def,
QString  ct,
QString  kf,
QString  sf,
QString  sfh,
QString  fp,
QString  op,
QString  inthash = "",
bool  easyf = true 
)

Constructor. Creates a HSqlChoose

Parameters
sqlcthe sql name of the field
exthe explain text of the field
titthe title text of the field
defthe default text of the field
ctis the connected_table (See class details)
kfis the key_field (See class details)
sfis the showed_field (See class details)
sfhis the showed_field_head (See class details)
fpis the filter_part (See class details)
opis the order_part (See class details)
inthashis the internal hash function specifier: can be "nullhash","charcodehash","dropchar"
easyformif this true (default) the HSqlChoose initialized in easyform.

Definition at line 7101 of file datalib.cpp.

HSqlChoose::~HSqlChoose ( void  )

Destructor

Definition at line 7150 of file datalib.cpp.

HSqlChoose::HSqlChoose ( HSqlChoose t)

Deepcopy constructor

Definition at line 7156 of file datalib.cpp.

Member Function Documentation

void HSqlChoose::addExtraFunction ( int  pos,
const QObject *  receiver,
QString  text 
)

When the HSqlChoose is in normal mode (The selection achived with a popupped dialog) you can add a plus position dependent popup menu(whith mouse right click), which can activated on the records of the referenced table. You can define more menu items (maximum 5). Every menu items have a receiver QObject which have to have a "extrafunc_X(QString key)" slot to handle the activating the menu. The X can be 0,1,2,3 or 4.

For example if you call addExtraFunction(0,myobj,"Do something") that case if you click a right mouse button on an element of the referenced table a popupmenu will appear which will have a "Do something" menuitem. That case you click on this menu the "extrafunc_0(QString)" slot of myobj is activated, and the parameter will be the key value of the selected record.

Have to call before the initialization of gui.

Parameters
posthe positon of the added menu. 0<= pos <5
receiverthe QObject descendant which have a "extrafunc_POS(QString) slot.
textthe text of the added menu item.

Definition at line 7498 of file datalib.cpp.

void HSqlChoose::addToolButton ( const QObject *  receiver,
QString  text 
)

When the HSqlChoose is in normal mode (The selection achived with a popupped dialog) you can add a plus push button to that popupped dialog. You can specify a function (slot) which called when this button is pressed.
When the user push this button the gSAFE activates the "toolbuttonclicked" slot of the "receiver" QObject.

The gSAFE also try to connect to the "setKeyTo(QString)" signal of the "receiver".(optional) The called subprogram can set the current value by this signal. Useful if you use this plus button to add new element to the record list. After addig the record you can make immediately active with the setKeyTo signal.

Have to call before the initialization of gui.

Parameters
receiverthe receiver QObject descendant which have a toolbuttonclicked slot and an optional setKeyTo(QString) signal
textthe text of the button

Definition at line 7486 of file datalib.cpp.

QVariant HSqlChoose::dbValueToDispValue ( QVariant  v)
virtual

Converting function, you can give a HDataFiled(or descendant) value to this function, and you get the corresponding sql value of the given value.
This function usally redefined in descendats!
In simple typed fields this function do a trivial conversion for example a text field do "text"->"'text'" conversion. Other cases where the field is more complex (HSqlChoose for example) this conversion can be more complex.

In HSqlChoose can be:
"Joe Black" -> "id_0123"
"Little Richard" -> "id_03453"
"John Wayne" -> "id_0197"
etc...


In a HCharHash the result can be:
"Animal" -> "a"
"Plant" -> "p"
"Objects" -> "o"
etc...

Reimplemented from HDataField.

Definition at line 7315 of file datalib.cpp.

void HSqlChoose::deepcopy_from ( HSqlChoose x)

Deepcopy from the given parameter

Definition at line 7162 of file datalib.cpp.

void HSqlChoose::deferredSqlRefresh ( void  )
inline

Makes a refreshSqlValues() the next necessary time. It does not trigger an immedialty refreshSqlValues() but is emits when it needs same data)

Definition at line 3423 of file datalib.h.

void HSqlChoose::disableEasyForm ( void  )

Sets the HSqlChoose to easyform=false (See class details)

Definition at line 7479 of file datalib.cpp.

void HSqlChoose::doWorking ( void  )
signal

When using a work indicator: This signal is emitted when a work continues

void HSqlChoose::enableEasyForm ( void  )

Sets the HSqlChoose to easyform=true (See class details)

Definition at line 7473 of file datalib.cpp.

void HSqlChoose::endWorking ( void  )
signal

When using a work indicator: This signal is emitted when a work finished

HDataField * HSqlChoose::get_clone ( void  )
virtual

Returns a clone of this field

Reimplemented from HDataField.

Definition at line 7198 of file datalib.cpp.

bool HSqlChoose::getEasyForm ( void  )
inline

Returns true if the HSqlChoose in easyform, otherwise false (See class details)

Definition at line 3419 of file datalib.h.

QString HSqlChoose::getFieldHeads ( void  )
inline

Returns the header texts of showed fields (including "|" sings)

Definition at line 3435 of file datalib.h.

int HSqlChoose::getGuiSortIndicator ( void  )
inline

Returns the current default column sort index in the popup selector.

Definition at line 3441 of file datalib.h.

QStringList & HSqlChoose::getKeys ( void  )

Returns the cached keys (readed keys of the records of the referenced table)

Definition at line 7346 of file datalib.cpp.

QString HSqlChoose::getPopupDialogTitle ( void  )
inline

Returns the title of the popupdialog

Definition at line 3483 of file datalib.h.

QStringList & HSqlChoose::getSeparatedValues ( void  )

Returns the separated values

Definition at line 7360 of file datalib.cpp.

QString HSqlChoose::getSQLValue ( void  )
virtual

Returns the value of the field in that format which accepted by the sql database.

Reimplemented from HDataField.

Definition at line 7435 of file datalib.cpp.

QString HSqlChoose::getSQLValueAsString ( void  )
virtual

Returns string format of the field's value. Very similar to getSQLValue() but the result is always acceptable in an sql varchar field. (Mostly used by the logger system, when every kind of values are stored in varchar. The gsafe try to keep the value as close to the original sql database value as possible)

Reimplemented from HDataField.

Definition at line 7443 of file datalib.cpp.

QVariant HSqlChoose::getValue ( void  )
virtual

Returns the value of the field.

Reimplemented from HDataField.

Definition at line 7430 of file datalib.cpp.

QStringList & HSqlChoose::getValues ( void  )

Returns the cached values (readed keys of the records of the referenced table)

Definition at line 7353 of file datalib.cpp.

int HSqlChoose::refreshSqlValues ( bool  emitsignal = true,
bool  tdisabled = false 
)

Makes the HSqlChoose to refresh the records of the referenced table.

Parameters
emitsignalis true the finction emits the dataUpdatedSignal() after the work.
tdisabledFALSE:It is submitted in a new separate transaction, TRUE:Don's start a new transaction

Definition at line 7203 of file datalib.cpp.

void HSqlChoose::removeExtraFunction ( void  )

Removes all positon dependent popup menu in the popup selector

See Also
addExtraFunction()

Definition at line 7504 of file datalib.cpp.

void HSqlChoose::removeToolButton ( void  )

Remove the plus toolbar button in normal mode.

See Also
addToolButton()

Definition at line 7492 of file datalib.cpp.

void HSqlChoose::resetPopupDialogTitle ( void  )
inline

Sets the title of the popupdialog to empty ("") when the HSqlChoose in normal mode

Definition at line 3481 of file datalib.h.

int HSqlChoose::setDefval ( QVariant  v)
virtual

Sets the default value of the field.

Returns
0 if success.

Reimplemented from HDataField.

Definition at line 7367 of file datalib.cpp.

void HSqlChoose::setFilterPart ( QString  fp)

Sets the filter part of HSqlChoose

Definition at line 7340 of file datalib.cpp.

void HSqlChoose::setGuiSortIndicator ( int  i)
inline

Sets the initial sort indicator in gui popup browser

Parameters
ithe index of culumn to sort

Definition at line 3439 of file datalib.h.

void HSqlChoose::setHashFunction ( int(*)(const char *)  nh)
inline

Sets the key-value hash function manually

Definition at line 3486 of file datalib.h.

void HSqlChoose::setInernalHashFunction ( QString  hashname)

Sets the key-value hash function by name

Definition at line 7525 of file datalib.cpp.

void HSqlChoose::setPopupDialogTitle ( QString  title)
inline

Sets the title of the popupdialog when the HSqlChoose in normal mode

Definition at line 3479 of file datalib.h.

int HSqlChoose::setValue ( QVariant  v,
bool  sdisabled = false 
)
virtual

Sets the value of the field.

Parameters
sdisabledif this parameter is true the dataChanged() signal is disabled
Returns
0 if success.

Reimplemented from HDataField.

Definition at line 7416 of file datalib.cpp.

QString HSqlChoose::sqlCreateStringPart ( QString  switches = "")
virtual

Returns the part of the CREATE TABLE sql command which creates this field

Reimplemented from HDataField.

Definition at line 7513 of file datalib.cpp.

QString HSqlChoose::sqlInsertHead ( void  )
virtual

Returns the sql name of the field (in insert) This function can be redefined in descendats!

Reimplemented from HDataField.

Definition at line 7448 of file datalib.cpp.

QString HSqlChoose::sqlInsertValue ( void  )
virtual

Returns the sql value of the field (in insert) This function can be redefined in descendats!

Reimplemented from HDataField.

Definition at line 7453 of file datalib.cpp.

QString HSqlChoose::sqlSelectHead ( void  )
virtual

Returns the sql name of the field (in select) This function can be redefined in descendats!

Reimplemented from HDataField.

Definition at line 7467 of file datalib.cpp.

QString HSqlChoose::sqlUpdate ( void  )
virtual

Returns the sql update part of the field ( name='VALUE' ) This function can be redefined in descendats!

Reimplemented from HDataField.

Definition at line 7460 of file datalib.cpp.

void HSqlChoose::startWorking ( void  )
signal

When using a work indicator: This signal is emitted when a work begins

Member Data Documentation

QString HSqlChoose::btext

The additional toolbar button text see addToolButton

Definition at line 3359 of file datalib.h.

bool HSqlChoose::easyform
protected

Easyform attribute

Definition at line 3351 of file datalib.h.

const QObject* HSqlChoose::extrafunc_receiver[5]

Extrafunctions receivers see addExtraFunction()

Definition at line 3367 of file datalib.h.

QString HSqlChoose::extrafunc_text[5]

Extrafunctions texts see addExtraFunction()

Definition at line 3370 of file datalib.h.

int(* HSqlChoose::hash)(const char *)
protected

Pointer to the hash function to speedup the key->value searching.

Definition at line 3325 of file datalib.h.

bool HSqlChoose::progress_on_read

If this attribute is true the HSqlChoose show a graphical work indicator at time dependent sql reads

Definition at line 3363 of file datalib.h.

const QObject* HSqlChoose::toolbrec

The additional toolbar button event receiver see addToolButton

Definition at line 3356 of file datalib.h.


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