Ananas Library  0.9.5
Public Slots | Public Member Functions | List of all members
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. More...
 
virtual bool IsMarkDeleted (const QString &tname="")
 Checks "Deleted" marker. More...
 
virtual bool IsMarked ()
 Checks "Marked" marker. More...
 
virtual int SetMarkDeleted (bool Deleted, const QString &tablename="")
 Устанавливает признак логического удаления объекта (записи SQL таблицы) More...
 
virtual int SetMarked (bool Marked)
 Выставляет отметку на объекте. More...
 
virtual int New ()
 Add new object record in database. More...
 
virtual int Copy ()
 
virtual int Delete ()
 
virtual int Update ()
 Update curent selected object record to database. More...
 
virtual int Conduct ()
 Conducts document. More...
 
virtual int UnConduct ()
 Unconducts document. More...
 
virtual bool IsConducted ()
 Checks if document has been conducted. More...
 
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. More...
 
virtual int SetValue (const QString &name, const QVariant &value, const QString &tableName="")
 Set field value of the primary object database table. More...
 
virtual int SetFilter (const QString &valname, const QVariant &value)
 Задает фильтр записей/объектов
 
virtual int ClearFilter ()
 Чистит фильтр записей/объектов. More...
 
virtual int TableSetFilter (const QString &tname, const QString &valname, const QVariant &value)
 Устанавливает вильтр записей табличной части объекта. More...
 
virtual int TableClearFilter (const QString &tname)
 Чистит фильтр записей указанной табличной части объекта. More...
 
virtual bool IsFiltred ()
 Показывает наличие активного фильтра
 
virtual int TableUpdate (const QString &tablename)
 
virtual QString displayString ()
 Возвращает строку, предназначенную для отображения пользователю объекта сложного типа. More...
 
virtual int LastErrorCode ()
 
virtual QString LastErrorMessage ()
 

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)
 Creates aObject, inited by md object. More...
 
virtual ~aObject ()
 Virtual destructor.
 
virtual bool checkStructure ()
 Not implemented. More...
 
ERR_Code init ()
 Tune on metadata object and it's database tables. More...
 
ERR_Code decodeDocNum (QString nm, QString &pref, int &num)
 Осуществляет выделение символьного префикса из строки. More...
 
Q_ULLONG getUid ()
 Возвращает уникальный идентификатор объекта из базы данных. More...
 
bool selected (const QString &tablename="")
 Показывает задан ли текущий объект или запись в его табличной части. More...
 
ERR_Code select (const QString &query, const QString &tableName="")
 Осуществляет SQL запрос. More...
 
aDataTabletable (const QString &name="")
 Return the table of object by it's name. More...
 
virtual Q_ULLONG docId ()
 Returns document database id. More...
 
virtual bool Next (const QString &tableName="")
 Перемещает указатель на следующую запись SQL таблицы. More...
 
virtual bool Prev (const QString &tableName="")
 Перемещает указатель на предыдующую запись SQL таблицы. More...
 
virtual bool First (const QString &tableName="")
 Перемещает указатель на первую запись SQL таблицы. More...
 
virtual bool Last (const QString &tableName="")
 Перемещает указатель на последнюю запись SQL таблицы. More...
 

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. More...
 
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. More...
 
ERR_Code tableInsert (const QString &dbname, const QString &name="")
 Insert table name and its link into internal buffer. More...
 
ERR_Code tableRemove (const QString &name="")
 Remove table from buffer. More...
 
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 класса More...
 
- 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::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 initObject().

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 initObject().

aDocument::~aDocument ( )
virtual

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

Member Function Documentation

ERR_Code aDocument::ClearFilter ( )
virtualslot

Clear all filters values.

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

References aObject::ClearFilter().

ERR_Code aDocument::Copy ( )
virtualslot

Copy current document. Create document with header and table pats like current document. New document have current date and next unical number.

Returns
error code.

References aCfg::attr(), aObject::Copy(), aCfg::count(), aCfg::find(), aDocJournal::getPrefix(), aObject::getUid(), aCfg::id(), aDatabase::markDeleted(), aDocJournal::New(), select(), aObject::table(), TableNewLine(), TableNext(), TableSelect(), TableSetValue(), TableUpdate(), and TableValue().

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 aCfg::attr(), aCfg::count(), aObject::Delete(), aDocJournal::deleteDocument(), aCfg::find(), aObject::getUid(), IsConducted(), aDatabase::markDeleted(), aLog::print(), aObject::selected(), and UnConduct().

Referenced by aDocJournal::Delete().

bool aDocument::First ( )
virtualslot

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

Returns
operation result.

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

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 select(), aObject::setLastError(), and Value().

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().

Referenced by aARegister::New(), and aIRegister::New().

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 aCfg::attr(), aCfg::count(), aCfg::find(), aObject::initObject(), aDatabase::tableDbName(), and aObject::tableInsert().

Referenced by aDocument().

bool aDocument::IsMarkDeleted ( )
virtualslot

Check document on mark deleted

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

References aObject::IsMarkDeleted().

bool aDocument::IsMarked ( )
virtualslot

Check document on marked

Returns
true if document is marked and fasle in othe event

References aObject::IsMarked().

bool aDocument::IsSignedIn ( )
slot

Check document conducting.

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

References aDatabase::db(), and aObject::getUid().

Referenced by IsConducted().

bool aDocument::Last ( )
virtualslot

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

Returns
operation result.

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

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 aCfg::attr(), aObject::getUid(), aCfg::id(), aObject::LastErrorCode(), aDatabase::markDeleted(), aDocJournal::New(), aObject::New(), Prefix(), aLog::print(), aObject::setLastError(), SetPrefix(), and aObject::table().

bool aDocument::Next ( )
virtualslot

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

Returns
operation result.

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

QString aDocument::Prefix ( )
slot

Get document prefix.

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

Referenced by New().

bool aDocument::Prev ( )
virtualslot

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

Returns
operation result.

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

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().

ERR_Code aDocument::select ( Q_ULLONG  uid)
virtual

Select document with id = uid.

Reimplemented from aObject.

References aCfg::attr(), aCfg::count(), aCfg::find(), and aDocJournal::findDocument().

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

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 aCfg::attr(), aDocJournal::findDocument(), aObject::getUid(), aObject::IsFiltred(), Select(), aObject::setSelected(), and aObject::table().

Referenced by Select().

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 aCfg::attr(), aDocJournal::findDocument(), aObject::getUid(), aObject::IsFiltred(), Select(), aObject::setSelected(), and aObject::table().

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().

ERR_Code aDocument::SetMarkDeleted ( bool  Deleted)
virtualslot

Set document deleted flag

Parameters
Deleted- deleted flag
Returns
error code.

References aObject::SetMarkDeleted().

ERR_Code aDocument::SetMarked ( bool  Marked)
virtualslot

Set document marked flag

Parameters
Marked- marked flag
Returns
error code.

References aObject::SetMarked().

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().

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.

References aDocJournal::setDate(), and aDocJournal::setNumber().

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().

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 aCfg::count(), aARegister::deleteDocument(), aIRegister::deleteDocument(), aCfg::find(), IsConducted(), and aLog::print().

Referenced by UnConduct().

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.

References aDocJournal::getDate(), aDocJournal::getNumber(), and aDocJournal::getSerialNumber().

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(), aDatabase::markDeleted(), aLog::print(), aObject::setLastError(), and aObject::table().

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().

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().

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 aDatabase::db(), aObject::getUid(), IsConducted(), aObject::LastErrorCode(), aLog::print(), aObject::setLastError(), aObject::table(), and TableUpdate().

Referenced by Copy().

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().

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().

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().

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().

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 aCfg::attr(), aCfg::count(), aCfg::find(), IsConducted(), and aLog::print().

Referenced by Copy(), and TableNewLine().

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().

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().

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().

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(), GetDocumentValue(), aARegister::New(), and aARegister::Update().


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