Ananas Library 0.9.5
aDocument Class Reference

#include <adocument.h>

Inheritance diagram for aDocument:
aObject

Public Slots

virtual ERR_Code New ()
virtual ERR_Code Delete ()
virtual ERR_Code Update ()
virtual ERR_Code Select (QDateTime from, QDateTime to)
virtual bool Select ()
virtual ERR_Code Select (const QString &num)
virtual int SelectDocument (QVariant uid)
virtual ERR_Code Copy ()
virtual bool Next ()
virtual bool Prev ()
virtual bool First ()
virtual bool Last ()
virtual ERR_Code TableNewLine (const QString &tablename)
virtual ERR_Code TableDelete (const QString &tablename)
virtual ERR_Code TableSelect (const QString &name)
virtual QVariant TableValue (const QString &tablename, const QString &name)
virtual ERR_Code TableSetValue (const QString &tablename, const QString &name, const QVariant &value)
virtual ERR_Code TableUpdate (const QString &tablename="")
virtual bool TableNext (const QString &name)
virtual bool TablePrev (const QString &name)
virtual bool TableFirst (const QString &name)
virtual bool TableLast (const QString &name)
virtual bool IsMarkDeleted ()
virtual bool IsMarked ()
virtual ERR_Code SetMarkDeleted (bool Deleted)
virtual ERR_Code SetMarked (bool Marked)
void SetPrefix (const QString &pr)
QString Prefix ()
virtual QVariant Value (const QString &name, const QString &tableName="")
virtual ERR_Code SetFilter (const QString &valname, const QVariant &value)
virtual ERR_Code ClearFilter ()
ERR_Code Conduct ()
 Deprecated.
ERR_Code UnConduct ()
 Deprecated.
bool IsConducted ()
 Deprecated.
ERR_Code SignIn ()
ERR_Code SignOut ()
bool IsSignedIn ()
void Seek (int pos, const QString &tname)
QVariant GetDocumentValue (QVariant ide, const QString &fname)
Public Slots inherited from aObject
virtual QString Uid ()
virtual bool IsSelected ()
 Checks if object selected.
virtual bool IsMarkDeleted (const QString &tname="")
 Checks "Deleted" marker.
virtual bool IsMarked ()
 Checks "Marked" marker.
virtual int SetMarkDeleted (bool Deleted, const QString &tablename="")
 Устанавливает признак логического удаления объекта (записи SQL таблицы)
virtual int SetMarked (bool Marked)
 Выставляет отметку на объекте.
virtual int New ()
 Add new object record in database.
virtual int Copy ()
virtual int Delete ()
virtual int Update ()
 Update curent selected object record to database.
virtual int Conduct ()
virtual int UnConduct ()
virtual bool IsConducted ()
virtual QString Kind (const QString &name=QString::null)
virtual QVariant Value (const QString &name, const QString &tableName="")
 Return field value of the primary object database table.
virtual int SetValue (const QString &name, const QVariant &value, const QString &tableName="")
 Set field value of the primary object database table.
virtual int SetFilter (const QString &valname, const QVariant &value)
 Задает фильтр записей/объектов
virtual int ClearFilter ()
 Чистит фильтр записей/объектов.
virtual int TableSetFilter (const QString &tname, const QString &valname, const QVariant &value)
 Устанавливает вильтр записей табличной части объекта.
virtual int TableClearFilter (const QString &tname)
 Чистит фильтр записей указанной табличной части объекта.
virtual bool IsFiltred ()
 Показывает наличие активного фильтра

Public Member Functions

 aDocument (aCfgItem context, aDatabase *adb=0)
 aDocument (const QString &name, aDatabase *adb=0)
virtual ~aDocument ()
virtual ERR_Code select (Q_ULLONG uid)
virtual ERR_Code initObject ()
virtual QString trSysName (const QString &sname)
virtual QVariant sysValue (const QString &sname, const QString &="")
virtual ERR_Code setSysValue (const QString &sname, QVariant value, const QString &="")
aSQLTable * getTable (const QString &tablename)
Public Member Functions inherited from aObject
 aObject (QObject *parent=0, const char *name=0)
 aObject (const QString &oname, aDatabase *adb, QObject *parent=0, const char *name=0)
 aObject (aCfgItem context, aDatabase *adb, QObject *parent=0, const char *name=0)
virtual ~aObject ()
 Virtual destructor. .
virtual bool checkStructure ()
 Not implemented.
ERR_Code init ()
 Tune on metadata object and it's database tables.
ERR_Code decodeDocNum (QString nm, QString &pref, int &num)
 Осуществляет выделение символьного префикса из строки.
Q_ULLONG getUid ()
 Возвращает уникальный идентификатор объекта из базы данных.
bool selected (const QString &tablename="")
 Показывает задан ли текущий объект или запись в его табличной части.
ERR_Code select (const QString &query, const QString &tableName="")
 Осуществляет SQL запрос.
aDataTabletable (const QString &name="")
 Return the table of object by it's name.
virtual Q_ULLONG docId ()
 Returns document database id.
virtual bool Next (const QString &tableName="")
 Перемещает указатель на следующую запись SQL таблицы.
virtual bool Prev (const QString &tableName="")
 Перемещает указатель на предыдующую запись SQL таблицы.
virtual bool First (const QString &tableName="")
 Перемещает указатель на первую запись SQL таблицы.
virtual bool Last (const QString &tableName="")
 Перемещает указатель на последнюю запись SQL таблицы.
virtual int TableUpdate (const QString &tablename)
virtual QString displayString ()
 Возвращает строку, предназначенную для отображения пользователю объекта сложного типа.
virtual int LastErrorCode ()
virtual QString LastErrorMessage ()

Additional Inherited Members

Public Attributes inherited from aObject
aCfgmd
aCfgItem obj
aDatabasedb
Protected Member Functions inherited from aObject
virtual aCfgItem displayStringContext ()
 Возвращает контекст (узел дерева) метаданных для вычисления строкового представления сложного типа.
virtual ERR_Code setObject (aCfgItem newobject)
 Sets new object type after create.
bool isInited ()
void setInited (bool flag)
ERR_Code tableInsert (const QString &dbname, aCfgItem obj, const QString &name="")
 Insert table name and its link into internal buffer.
ERR_Code tableInsert (const QString &dbname, const QString &name="")
 Insert table name and its link into internal buffer.
ERR_Code tableRemove (const QString &name="")
 Remove table from buffer.
virtual QVariant tValue (const QString &tablename, const QString &name)
 Return field value of the secondary object database table.
virtual ERR_Code setTValue (const QString &tablename, const QString &name, const QVariant &value)
 Set field value of the secondary object database table.
void setSelected (bool sel, const QString &tablename="")
 Явно задает состояние выбранности объекта или записи его табличной части.
virtual ERR_Code setTFilter (const QString &tname, const QString &valname, const QVariant &value)
 Устанавливает вильтр записей табличной части объекта.
virtual ERR_Code clearTFilter (const QString &tname)
 Чистит фильтр записей указанной табличной части объекта.
void setLastError (int, QString)
 Задает значения свойствам lastErrorCode и lastErrorMessage класса
Protected Attributes inherited from aObject
bool concrete

Detailed Description

Not visual object used for working with documents in database. Used as interface between database and script or wObjects

Constructor & Destructor Documentation

◆ aDocument() [1/2]

aDocument::aDocument ( aCfgItem context,
aDatabase * adb = 0 )

Create object aDocument by ananas configuration object. New object initing by md ojbect Use for creating object if you have md object, for example in default document form

Parameters
context- md object used for initing aDocument.
adb- ananas database for working.

References aObject::aObject(), and initObject().

Referenced by Copy().

◆ aDocument() [2/2]

aDocument::aDocument ( const QString & name,
aDatabase * adb = 0 )

Create object aDocument by document metadata name. new object initing by md ojbect with some name Use for creating object if you know it's name

Parameters
name- md name of document.
adb- ananas database for working.

References aObject::aObject(), and initObject().

◆ ~aDocument()

aDocument::~aDocument ( )
virtual

Destroy object aDocument. Use for delete system journal and free memory.

Member Function Documentation

◆ ClearFilter

ERR_Code aDocument::ClearFilter ( )
virtualslot

Clear all filters values.

See also
SetFilter( const QString & valname, const QVariant & value )
Returns
error code.

References aObject::ClearFilter().

◆ Copy

ERR_Code aDocument::Copy ( )
virtualslot
\if english
Copy current document.
Create document with header and table pats like current document.
New document have current date and next unical number.
\endif
Returns
error code.

References aDocument(), aObject::Copy(), aObject::getUid(), select(), aObject::table(), TableNewLine(), TableNext(), TableSelect(), TableSetValue(), TableUpdate(), TableValue(), and aObject::Uid().

◆ Delete

ERR_Code aDocument::Delete ( )
virtualslot

Delete current document. Delete document header, all tables and system journal record, If document conducted (turn on) it unconduct (make turn off).

Returns
error code.

References aObject::Delete(), aObject::getUid(), IsConducted(), aLog::print(), aObject::selected(), and UnConduct().

Referenced by aDocJournal::Delete().

◆ First

bool aDocument::First ( )
virtualslot

Make current first selected header. Use for navigation by selected documents.

Returns
operation result.

References aObject::First(), and aObject::getUid().

◆ GetDocumentValue

QVariant aDocument::GetDocumentValue ( QVariant docId,
const QString & fname )
slot

Get value of document field.

Parameters
docId- document id
fname- md field name
Returns
value of field

References aObject::docId(), select(), aObject::setLastError(), and Value().

◆ getTable()

aSQLTable * aDocument::getTable ( const QString & tname)

Get table by it's metadataname name. This function added for get access to document table by it name for othe objects.

See also
aObject::table()
Parameters
tname- metadata table name.
Returns
link on aSQLTable or 0 if table not found.

References aObject::table().

◆ initObject()

ERR_Code aDocument::initObject ( )
virtual

Init object aDocument. Used for insert table for document header and tables for all table part of document. After that we can work wthith document' tables by it name, name of heared table = ""

Returns
error code.

Reimplemented from aObject.

References aObject::initObject(), aDatabase::tableDbName(), and aObject::tableInsert().

Referenced by aDocument(), and aDocument().

◆ IsMarkDeleted

bool aDocument::IsMarkDeleted ( )
virtualslot

Check document on mark deleted

Returns
true if document is mark deleted and fasle in othe event

◆ IsMarked

bool aDocument::IsMarked ( )
virtualslot

Check document on marked

Returns
true if document is marked and fasle in othe event

◆ IsSignedIn

bool aDocument::IsSignedIn ( )
slot

Check document conducting.

See also
SignIn() SignOut()
Returns
true, if document is conducted.

References aObject::getUid().

Referenced by IsConducted().

◆ Last

bool aDocument::Last ( )
virtualslot

Make current last selected header. Use for navigation by selected documents.

Returns
operation result.

References aObject::getUid(), and aObject::Last().

◆ New

ERR_Code aDocument::New ( )
virtualslot

Create new document. Create new document header record by selected type in database, if object not seted, return error. New document also registred in system journal and make current

Returns
error code.

References aObject::getUid(), aObject::LastErrorCode(), aObject::New(), Prefix(), aLog::print(), aObject::setLastError(), SetPrefix(), aObject::table(), and aObject::Uid().

◆ Next

bool aDocument::Next ( )
virtualslot

Make current next selected header. Use for navigation by selected documents.

Returns
operation result.

References aObject::getUid(), and aObject::Next().

◆ Prefix

QString aDocument::Prefix ( )
slot

Get document prefix.

See also
SetPrefix( const QString & pr ) Select( const QString & num )
Returns
document prefix.

Referenced by New().

◆ Prev

bool aDocument::Prev ( )
virtualslot

Make current prev selected header. Use for navigation by selected documents.

Returns
operation result.

References aObject::getUid(), and aObject::Prev().

◆ Seek

void aDocument::Seek ( int pos,
const QString & tname )
slot

Sets position in document table tname at pos.

Parameters
pos- line number
tname- table name

References aObject::setSelected(), and aObject::table().

◆ Select [1/2]

ERR_Code aDocument::Select ( const QString & num)
virtualslot

Select document by number. Document number string which conteyn document prefix and some number If adocument inited by some document type from metadata selected only this documents from jpurnal, otherwise - select all documents from system journal with such date

See also
Prefix() SetPrefix()
Parameters
num- document number
Returns
error code.

References aObject::getUid(), aObject::IsFiltred(), aObject::setSelected(), and aObject::table().

◆ Select [2/2]

ERR_Code aDocument::Select ( QDateTime from,
QDateTime to )
virtualslot

Select document by dates. If set only one date (othe isNull) select records before or after date. If adocument inited by some document type from metadata selected only this documents from jpurnal, otherwise - select all documents from system journal with such date

Parameters
from- begin date of selection if isNull - selected from first date of system journal,
to- end date of selection if isNull - selected to last date of system journal.
Returns
error code.

References aObject::getUid(), aObject::IsFiltred(), aObject::setSelected(), and aObject::table().

◆ select()

ERR_Code aDocument::select ( Q_ULLONG uid)
virtual

Select document with id = uid.

Reimplemented from aObject.

References aObject::select().

Referenced by Copy(), aDocJournal::CurrentDocument(), aIRegister::GetDocument(), GetDocumentValue(), and SelectDocument().

◆ SelectDocument

int aDocument::SelectDocument ( QVariant uid)
virtualslot

References select().

◆ SetFilter

ERR_Code aDocument::SetFilter ( const QString & valname,
const QVariant & value )
virtualslot

Set filter for some field. If filter seted, on select selected only records where that field equal value. If seted filters for diferent fields it's group by and. If filter reseted it override previous value

See also
ClearFilter()
Parameters
valname- metadata name of field.
value- filter value.
Returns
error code.

References aObject::SetFilter().

◆ SetMarkDeleted

ERR_Code aDocument::SetMarkDeleted ( bool Deleted)
virtualslot

Set document deleted flag

Parameters
Deleted- deleted flag
Returns
error code.

◆ SetMarked

ERR_Code aDocument::SetMarked ( bool Marked)
virtualslot

Set document marked flag

Parameters
Marked- marked flag
Returns
error code.

◆ SetPrefix

void aDocument::SetPrefix ( const QString & pr)
slot

Set document prefix. Document prefix used for generate document number.

See also
Prefix() Select( const QString & num )
Parameters
pr- new document prefix.

Referenced by New().

◆ setSysValue()

ERR_Code aDocument::setSysValue ( const QString & sname,
QVariant value,
const QString & = "" )
virtual

Set value for some system field of document. Used for write some system field of document: DocDate - Date and time of document, DocNumber - Number of document.

Parameters
sname- name of system field
value- new value of field
Returns
error code.

Reimplemented from aObject.

◆ SignIn

ERR_Code aDocument::SignIn ( )
slot

Make document conducted. Work only for unconducted documents otherwise return error err_docconducted

See also
SignOut() IsSignedIn()
Returns
error code.

References IsConducted().

Referenced by Conduct().

◆ SignOut

ERR_Code aDocument::SignOut ( )
slot

Make document unconducted. Work only for conducted documents otherwise return error err_docunconducted

See also
SignIn() IsSignedIn()
Returns
error code.

References aARegister::deleteDocument(), aIRegister::deleteDocument(), IsConducted(), and aLog::print().

Referenced by UnConduct().

◆ sysValue()

QVariant aDocument::sysValue ( const QString & sname,
const QString & = "" )
virtual

Get value for some system field of document. Used for read some system field of document: DocDate - Date and time of document, DocNumber - Number of document.

Parameters
sname- name of system field.
Returns
field value or QVariant::Invalid if used unknown field name.

Reimplemented from aObject.

◆ TableDelete

ERR_Code aDocument::TableDelete ( const QString & tablename)
virtualslot

Delete current table line. When deleted table line also deleted all records in all reegisters which contain link on this line Don't work if document conducted.

Parameters
tablename- metadata name of table
Returns
error code.

References aIRegister::deleteTable(), IsConducted(), aObject::LastErrorCode(), aLog::print(), aObject::setLastError(), and aObject::table().

◆ TableFirst

bool aDocument::TableFirst ( const QString & name)
virtualslot

Make current first selected line in table. Use for navigation in table

Parameters
name- metadata table name.
Returns
operation result.

References aObject::table().

◆ TableLast

bool aDocument::TableLast ( const QString & name)
virtualslot

Make current last selected line in table. Use for navigation in table

Parameters
name- metadata table name.
Returns
operation result.

References aObject::table().

◆ TableNewLine

ERR_Code aDocument::TableNewLine ( const QString & tablename)
virtualslot

Create new table line. Create new table line for table of now document if document not selected, or no table with some name return error. New line begin current in table

Parameters
tablename- metadata name of table.
Returns
error code.

References aObject::getUid(), IsConducted(), aObject::LastErrorCode(), aLog::print(), aObject::setLastError(), aObject::table(), and TableUpdate().

Referenced by Copy().

◆ TableNext

bool aDocument::TableNext ( const QString & name)
virtualslot

Make current next selected line in table. Use for navigation in table.

Parameters
name- metadata table name.
Returns
operation result.

References aObject::table().

Referenced by Copy().

◆ TablePrev

bool aDocument::TablePrev ( const QString & name)
virtualslot

Make current prev selected line in table. Use for navigation in table

Parameters
name- metadata table name.
Returns
operation result.

References aObject::table().

◆ TableSelect

ERR_Code aDocument::TableSelect ( const QString & name)
virtualslot

Select table by name. Make table with such name current

Parameters
name- table metadata name
Returns
error code.

Referenced by Copy().

◆ TableSetValue

ERR_Code aDocument::TableSetValue ( const QString & tablename,
const QString & name,
const QVariant & value )
virtualslot

Set some field value of current table line. Set value for field by metadata name

Parameters
tablename- metadata name of table,
name- metadata name of field,
value- new field value.
Returns
error code.

References aObject::setTValue().

Referenced by Copy().

◆ TableUpdate

ERR_Code aDocument::TableUpdate ( const QString & tablename = "")
virtualslot

Update table. Use for insert information from bufer into database. Information is inserting in table with md name=teblename, if used TableUpdate() - updating all tables of document. If document already conducted return error.

Parameters
tablename- metadata name of table
Returns
error code.

References IsConducted(), aLog::print(), and aObject::TableUpdate().

Referenced by Copy(), and TableNewLine().

◆ TableValue

QVariant aDocument::TableValue ( const QString & tablename,
const QString & name )
virtualslot

Get some field value of current table line. Get value for field by metadata name or sustem value ln if use name "TableLine".

Parameters
tablename- metadata name of table
name- name of field
Returns
field value

References aDataTable::sysValue(), aObject::table(), trSysName(), and aObject::tValue().

Referenced by Copy().

◆ trSysName()

QString aDocument::trSysName ( const QString & sname)
virtual

Translate name of system field. Used for translate same system names from different languages ot english, result used from working with system fields

Parameters
sname- field name on same language.
Returns
field name on english

Reimplemented from aObject.

Referenced by TableValue().

◆ Update

ERR_Code aDocument::Update ( )
virtualslot

Updete current record in database. Also update record for document system journal and all table parts. Don't work for conducted (Turn on) documents

Returns
error code.

References IsConducted(), aObject::LastErrorCode(), aObject::setLastError(), and aObject::Update().

◆ Value

QVariant aDocument::Value ( const QString & name,
const QString & tableName = "" )
virtualslot

Return field value with name = name of the primary object database table.

Parameters
name- field name
Returns
field value

References aObject::Value().

Referenced by aARegister::deleteDocument(), and GetDocumentValue().


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