Ananas Library 0.9.5
aCfg Class Reference

#include <acfg.h>

Inheritance diagram for aCfg:

Public Types

enum  fieldType {
  ftUnknown , ftChar , ftNumberic , ftDate ,
  ftObject
}
 

Public Slots

QString Info (QString partname)
 

Signals

void message (int messageType, const QString &messageText)
 

Public Member Functions

 aCfg ()
 
 ~aCfg ()
 
int read (const QString &fname)
 
int write (const QString &fname)
 
int write (QDomDocument doc, const QString &fname)
 
int readrc (const QString &fname)
 
int writerc (const QString &fname)
 
bool compressed ()
 
void setCompressed (bool mode)
 
bool modified ()
 
void setModified (bool mode)
 
void createNew ()
 
QString info (const QString &name)
 
void setInfo (const QString &name, const QString &value)
 
long getId (QString &name)
 
long id (aCfgItem context)
 
QString objClass (long id)
 
QString objClass (aCfgItem context)
 
int count (aCfgItem context, const QString &classname)
 
int countChild (aCfgItem context, const QString &classname=QString::null)
 
QString attr (aCfgItem context, const QString &name)
 
void setAttr (aCfgItem context, const QString &name, const QString &value)
 
void setAttr (aCfgItem context, const QString &name, int value)
 
QString text (aCfgItem context)
 
void setText (aCfgItem context, const QString &value)
 
QByteArray binary (aCfgItem context)
 
void setBinary (aCfgItem context, const QByteArray &value, const QString &format=QString::null)
 
QString binaryFormat (aCfgItem context)
 
QString sText (aCfgItem context, const QString &subname)
 
void setSText (aCfgItem context, const QString &subname, const QString &value)
 
aCfgItem find (aCfgItem context, const QString &name, int n=0)
 
aCfgItem find (long id)
 Finds object by unique ID in metadata tree.
 
aCfgItem find (const QString &name)
 
aCfgItem findChild (aCfgItem context, const QString &classname, int n=0)
 
aCfgItem findName (aCfgItem context, const QString &classname, const QString &name=QString::null)
 
bool swap (aCfgItem &item1, aCfgItem &item2)
 
int order (aCfgItem item)
 
aCfgItem parent (aCfgItem context)
 
aCfgItem firstChild (aCfgItem context)
 
aCfgItem lastChild (aCfgItem context)
 
aCfgItem nextSibling (aCfgItem context)
 
aCfgItem previousSibling (aCfgItem context)
 
aCfgItem insert (aCfgItem context, const QString &otype, const QString &name=QString::null, long id=0)
 
int saveOneObject (aCfgItem context, const QString &fileName)
 
aCfgItem loadOneObject (const QString &fileName)
 
void remove (aCfgItem context)
 
aCfgItem importCfgItem (aCfgItem context, aCfgItem obj)
 
void setupNewId (aCfgItem obj)
 
QStringList types (const QString &filter=QString::null, aCfgItem *obj=0)
 
QStringList ObjectTypes ()
 
aCfgItem insertDocument (const QString &name)
 
aCfgItem insertDocumentTable (aCfgItem owner, const QString &name)
 
aCfgItem insertCatalogue (const QString &name)
 
aCfgItem insertIRegister (const QString &name)
 
aCfgItem insertARegister (const QString &name)
 
aCfgItem insertJournal (const QString &name)
 
aCfgItem insertReport (const QString &name)
 
aCfgItem insertField (aCfgItem owner, const QString &section, const QString &name, const QString &ftype)
 
aCfgItem insertForm (aCfgItem owner, const QString &name)
 
aCfgItem insertWebForm (aCfgItem owner, const QString &name)
 
long getDefaultFormId (aCfgItem owner, int actiontype, int mode=0)
 
QStringList getJournalDocuments (aCfgItem journal)
 
aCfgItem findJournal (int jtype, aCfgItem doc)
 
QStringList objTables (aCfgItem obj)
 
QStringList objTables (int objid)
 
aCfgItem objTable (aCfgItem obj, int id)
 
aCfgItem objTable (int objid, int id)
 

Public Attributes

aCfgRc rc
 

Detailed Description

System configuration object.

Using for story and edit accountine system configuration.

Constructor & Destructor Documentation

◆ aCfg()

aCfg::aCfg ( )

Ananas configuation object constructor.

References createNew(), setCompressed(), and setModified().

◆ ~aCfg()

aCfg::~aCfg ( )

Ananas configuation object destructor.

Member Function Documentation

◆ attr()

QString aCfg::attr ( aCfgItem context,
const QString & name )

Returns object's attribute value.

Parameters
context(in) - object.
name(in) - attribute name.
Returns
attribute value.

Referenced by binary(), binaryFormat(), getDefaultFormId(), getJournalDocuments(), id(), objTables(), remove(), and setupNewId().

◆ binary()

QByteArray aCfg::binary ( aCfgItem context)

Returns binary value of object.

Parameters
context(in) - object to get value of.
Returns
array of bytes.

References attr(), and text().

◆ binaryFormat()

QString aCfg::binaryFormat ( aCfgItem context)

Returns format of metadata tree node binary data.

Parameters
context(in) - node of metadata tree.
Returns
format of binary data.

References attr().

◆ compressed()

bool aCfg::compressed ( )

Returns configuration file compression mode.

Returns
boolean

◆ count()

int aCfg::count ( aCfgItem context,
const QString & classname )

Counts specified objects in metadata tree.

Parameters
context(in) - parent of objects to count. May be a root of metadata tree.
classname(in) - class of objects to count.
Returns
number of objects.

Referenced by getDefaultFormId(), getJournalDocuments(), and objTables().

◆ countChild()

int aCfg::countChild ( aCfgItem context,
const QString & classname = QString::null )

Counts specified child objects of object in metadata tree. Only child objects will be counted, not subchild objects.

Parameters
context(in) - parent of objects to count. May be a root of metadata tree.
classname(in) - class of objects to count.
Returns
number of objects.

References firstChild(), nextSibling(), and objClass().

◆ createNew()

void aCfg::createNew ( )

Creates new empty configuration.

Returns
void.

References insert(), aLog::print(), setInfo(), and setModified().

Referenced by aCfg(), and readrc().

◆ find() [1/3]

aCfgItem aCfg::find ( aCfgItem context,
const QString & name,
int n = 0 )

Finds object by its name and number.

Parameters
context(in) - context to seach in.
name(in) - name of object to search for.
n(in) - number of object in found context.
Returns
founded object.

Referenced by aObject::aObject(), aObjectList::aObjectList(), aWidget::aWidget(), find(), getDefaultFormId(), getId(), getJournalDocuments(), insertARegister(), insertCatalogue(), insertDocument(), insertDocumentTable(), insertField(), insertForm(), insertIRegister(), insertJournal(), insertReport(), insertWebForm(), objClass(), ObjectTypes(), objTable(), objTable(), objTables(), objTables(), aExtSQL::SqlFieldName(), aExtSQL::SqlTableName(), and types().

◆ find() [2/3]

aCfgItem aCfg::find ( const QString & name)

Finds object by its full name.

Parameters
name(in) - object's full name.
Returns
founded object.

References find(), and aLog::print().

◆ find() [3/3]

aCfgItem aCfg::find ( long id)

Finds object by unique ID in metadata tree.

Parameters
id(in) - id to search for.
Returns
founded object.

References id().

◆ firstChild()

aCfgItem aCfg::firstChild ( aCfgItem context)

Returns the first child item of the context. If there is no child, a null context is returned. Changing the returned item will also change the item in the metadata tree.

Parameters
context(in) - node in metadata tree.
Returns
aCfgItem - node in metafata tree if found, NULL if not found.

Referenced by countChild(), remove(), and setupNewId().

◆ getDefaultFormId()

long aCfg::getDefaultFormId ( aCfgItem owner,
int actiontype,
int mode = 0 )

Returns ID of default screen form of object like Document.

Parameters
owner(in) - form's owner.
actiontype(in) - action to which form is a default form.
mode(in) - action to which form is a mode.
Returns
form's ID.

References attr(), count(), find(), id(), and sText().

◆ getId()

long aCfg::getId ( QString & name)

Gets ID for metadata object by complete name. Name like "Document.Invoice", "Report.Total", etc.

Parameters
name(in) - full object's name.
Returns
object's ID.

References find(), and id().

◆ getJournalDocuments()

QStringList aCfg::getJournalDocuments ( aCfgItem journal)

Gets journal's documents list.

Parameters
journal(in) - journal to get list from.
Returns
list of documents IDs.

References attr(), count(), find(), objClass(), remove(), and text().

◆ id()

long aCfg::id ( aCfgItem context)

Returns configuration object ID.

Parameters
context(in) - object which ID we looking for.
Returns
object's ID.

References attr().

Referenced by find(), getDefaultFormId(), getId(), objTables(), remove(), setupNewId(), aExtSQL::SqlFieldName(), and aDatabase::tableDbName().

◆ importCfgItem()

aCfgItem aCfg::importCfgItem ( aCfgItem context,
aCfgItem objFromAnotherCfg )

Import configuration object from another configuration.

Parameters
context- parent for imported object
objFromAnotherCfg- imported object

References setupNewId().

◆ info()

QString aCfg::info ( const QString & name)

Returns value of info section field of configuration.

Parameters
name(in) - name of field to fetch value from.
Returns
info field's value.

References text().

◆ insert()

aCfgItem aCfg::insert ( aCfgItem context,
const QString & otype,
const QString & name = QString::null,
long id = 0 )

Inserts a new object into metadata tree.

Parameters
context(in) - metadata object context.
otype(in) - metadata object type.
name(in) - metadata object name. If name = QString::null, name attribute will not be setted.
id(in) - metadata object id. If id = 0, setting next avalable id for the metadata tree.
Returns
newly created metadata object. To check if created object is valid use "if (CreatedObject.isNull()) ..." construction.

References setAttr(), and setModified().

Referenced by createNew(), insertARegister(), insertCatalogue(), insertDocument(), insertDocumentTable(), insertField(), insertForm(), insertIRegister(), insertJournal(), insertReport(), insertWebForm(), and setSText().

◆ insertARegister()

aCfgItem aCfg::insertARegister ( const QString & name)

Inserts new accumalation register in metadata tree.

Parameters
name(in) - name of catalogue.
Returns
newly created catalogue.

References find(), and insert().

◆ insertCatalogue()

aCfgItem aCfg::insertCatalogue ( const QString & name)

Inserts new catalogue in metadata tree.

Parameters
name(in) - name of catalogue.
Returns
newly created catalogue.

References find(), and insert().

◆ insertDocument()

aCfgItem aCfg::insertDocument ( const QString & name)

Inserts new document in metadata tree.

Parameters
name(in) - document's name.
Returns
newly created document.

References find(), and insert().

◆ insertDocumentTable()

aCfgItem aCfg::insertDocumentTable ( aCfgItem owner,
const QString & name )

Inserts document's table in metadata tree.

Parameters
owner(in) - document to insert table.
name(in) - table's name.
Returns
newly created table.

References find(), and insert().

◆ insertField()

aCfgItem aCfg::insertField ( aCfgItem owner,
const QString & section,
const QString & name,
const QString & ftype )

Creates a new field's definition in owner's section. If section is empty, field will be created in owner's context.

Parameters
owner(in) - owner of a new field.
section(in) - section of owner. For example Document may consists of one or more table sections. All of them contains set of fields.
name(in) - field's name.
ftype(in) - field's type.
Returns
newly created field.

References find(), insert(), and setAttr().

◆ insertForm()

aCfgItem aCfg::insertForm ( aCfgItem owner,
const QString & name )

Creates new screen form for object like Document and writes it to metadata tree.

Parameters
owner(in) - owner of new form.
name(in) - name of new form.
Returns
node of metadata tree which represents a newly created form.

References find(), and insert().

◆ insertIRegister()

aCfgItem aCfg::insertIRegister ( const QString & name)

Inserts new information register in metadata tree.

Parameters
name(in) - name of catalogue.
Returns
newly created catalogue.

References find(), and insert().

◆ insertJournal()

aCfgItem aCfg::insertJournal ( const QString & name)

Inserts new journal in metadata tree.

Parameters
name(in) - name of catalogue.
Returns
newly created catalogue.

References find(), and insert().

◆ insertReport()

aCfgItem aCfg::insertReport ( const QString & name)

Inserts new report in metadata tree.

Parameters
name(in) - name of catalogue.
Returns
newly created catalogue.

References find(), and insert().

◆ insertWebForm()

aCfgItem aCfg::insertWebForm ( aCfgItem owner,
const QString & name )

Creates new Web form for object like Document and writes it to metadata tree.

Parameters
owner(in) - owner of new form.
name(in) - name of new form.
Returns
node of metadata tree which represents a newly created form.

References find(), and insert().

◆ lastChild()

aCfgItem aCfg::lastChild ( aCfgItem context)

Returns the last child item of the context. If there is no child, a null context is returned. Changing the returned item will also change the item in the metadata tree.

◆ loadOneObject()

aCfgItem aCfg::loadOneObject ( const QString & fileName)

Load configuration object from file.

Parameters
fileName- file name
Returns
- object, stored in xml file

References aLog::print().

◆ modified()

bool aCfg::modified ( )

Returns modification status.

Returns
boolean

◆ nextSibling()

aCfgItem aCfg::nextSibling ( aCfgItem context)

Returns the next sibling in the netadata tree. Changing the returned item will also change the item in the metadata tree.

Referenced by countChild(), and setupNewId().

◆ objClass() [1/2]

QString aCfg::objClass ( aCfgItem context)

Returns class name of object.

Parameters
context(in) - object.
Returns
object's class name.

◆ objClass() [2/2]

QString aCfg::objClass ( long id)

Returns class name of object.

Parameters
id(in) - object id.
Returns
object's class name.

References find(), and objClass().

Referenced by countChild(), getJournalDocuments(), objClass(), objTable(), objTables(), setAttr(), aExtSQL::SqlFieldName(), aExtSQL::SqlTableName(), and aDatabase::tableDbName().

◆ ObjectTypes()

QStringList aCfg::ObjectTypes ( )

Returns object types names.

Returns
list of types names.

References find().

◆ objTable() [1/2]

aCfgItem aCfg::objTable ( aCfgItem obj,
int id )

Return context of the object table by id. This function used by Database tables plugins.

Parameters
obj(in) - metadata object.
id(in) - metadata object table id. id = 0 for document header, catalogue element; id = 1 for catalogue group; id = metadata object id for document table.
Returns
table context.

References find(), and objClass().

Referenced by objTable().

◆ objTable() [2/2]

aCfgItem aCfg::objTable ( int objid,
int id )

Return context of the object table by object id and table id. This function used by Database tables plugins.

Parameters
objid(in) - metadata object id.
id(in) - metadata object table id. id = 0 for document header, catalogue element; id = 1 for catalogue group; id = metadata object id for document table.
Returns
table context.

References find(), and objTable().

◆ objTables() [1/2]

QStringList aCfg::objTables ( aCfgItem obj)

Return list of object database tables. Every string in string list stored in format, consist of table id, table's human name fields, separated by tabulate char. This function used by Database tables plugins. For example: 0\tHeader 123\tTable1 id = 0 for document header, catalogue element; id = 1 for catalogue group; id = metadata object id for document table.

Parameters
obj(in) - metadata object.
Returns
list of tables.

References attr(), count(), find(), id(), and objClass().

Referenced by objTables().

◆ objTables() [2/2]

QStringList aCfg::objTables ( int objid)

Return list of object database tables. Every string in string list stored in format, consist of table id, table's human name fields, separated by tabulate char. This function used by Database tables plugins. For example: 0\tHeader 123\tTable1 id = 0 for document header, catalogue element; id = 1 for catalogue group; id = metadata object id for document table.

Parameters
objid(in) - metadata object id.
Returns
list of tables.

References find(), and objTables().

◆ order()

int aCfg::order ( aCfgItem item)

Returns onject's order number among siblings.

Parameters
item(in) - object.
Returns
object's order number.

References previousSibling().

◆ parent()

aCfgItem aCfg::parent ( aCfgItem context)

Returns parent object.

Parameters
context(in) - object.
Returns
paren object.

Referenced by swap(), and aDatabase::tableDbName().

◆ previousSibling()

aCfgItem aCfg::previousSibling ( aCfgItem context)

Returns the previous sibling in the netadata tree. Changing the returned item will also change the item in the metadata tree.

Referenced by order().

◆ read()

int aCfg::read ( const QString & fname)

Reads configuration information (metadata) from file.

Parameters
fname(in) - name of configuration file.
Returns
error code.

References aLog::print(), and setModified().

Referenced by readrc().

◆ readrc()

int aCfg::readrc ( const QString & fname)

Reads resource file.

Parameters
fname(in) - rc file name.
Returns
error code.

References createNew(), aLog::print(), and read().

◆ remove()

void aCfg::remove ( aCfgItem context)

Removes metadata object from metadata tree. All children objects also removed.

Parameters
context(in) - metadata object.
Returns
nothing.

References attr(), firstChild(), id(), remove(), and setModified().

Referenced by getJournalDocuments(), and remove().

◆ saveOneObject()

int aCfg::saveOneObject ( aCfgItem context,
const QString & fileName )

Saves configuration object to file.

Parameters
context- object to save
fileName- file name
Returns
- error code

References aLog::print(), and write().

◆ setAttr() [1/2]

void aCfg::setAttr ( aCfgItem context,
const QString & name,
const QString & value )

Sets object's attribute value.

Parameters
context(in) - object.
name(in) - attribute's name.
value(in) - new value.
Returns
void.

References objClass(), and setModified().

Referenced by insert(), insertField(), setBinary(), and setupNewId().

◆ setAttr() [2/2]

void aCfg::setAttr ( aCfgItem context,
const QString & name,
int value )

Changes value of object's attribute.

Parameters
context(in) - object.
name(in) - attribute's name.
value(in) - new attribute's vakue.
Returns
nothing.

References setModified().

◆ setBinary()

void aCfg::setBinary ( aCfgItem context,
const QByteArray & value,
const QString & format = QString::null )

Sets binary value of metadata tree node.

Parameters
context(in) - metadata tree node.
value(in) - new binary value.
format(in) - format of binary data.
Returns
void.

References setAttr(), and setText().

◆ setCompressed()

void aCfg::setCompressed ( bool mode)

Sets compression mode of configuration file.

Parameters
mode(in) - compression mode.
Returns
void

Referenced by aCfg().

◆ setInfo()

void aCfg::setInfo ( const QString & name,
const QString & value )

Sets new value to specified field of info section of configuration.

Parameters
name(in) - field's name.
value(in) - field's value.
Returns
void.

References setModified(), and setText().

Referenced by createNew().

◆ setModified()

void aCfg::setModified ( bool mode)

Set modification status.

Parameters
mode(in) - new value of modification status
Returns
void

Referenced by aCfg(), createNew(), insert(), read(), remove(), setAttr(), setAttr(), setInfo(), setText(), swap(), and writerc().

◆ setSText()

void aCfg::setSText ( aCfgItem context,
const QString & subname,
const QString & value )

Sets text value of child node.

Parameters
context(in) - parent node.
subname(in) - name of child node.
value(in) - new value of child node.
Returns
void.

References insert(), and setText().

◆ setText()

void aCfg::setText ( aCfgItem context,
const QString & value )

Sets text for object.

Parameters
context(in) - object.
value(in) - new value.
Returns
void.

References setModified().

Referenced by setBinary(), setInfo(), and setSText().

◆ setupNewId()

void aCfg::setupNewId ( aCfgItem obj)

Sets new id for all children of object obj

References attr(), firstChild(), id(), nextSibling(), aLog::print(), setAttr(), and setupNewId().

Referenced by importCfgItem(), and setupNewId().

◆ sText()

QString aCfg::sText ( aCfgItem context,
const QString & subname )

Returns text value of child node of metadata tree.

Parameters
context(in) - parent node.
subname(in) - name of child node.
Returns
text value.

References text().

Referenced by getDefaultFormId().

◆ swap()

bool aCfg::swap ( aCfgItem & item1,
aCfgItem & item2 )

Swaps two items in metadata tree.

Parameters
item1(in) - first item to swap.
item2(in) - second item to swap.
Returns
true or false.

References parent(), aLog::print(), and setModified().

◆ text()

QString aCfg::text ( aCfgItem context)

Returns text of object.

Parameters
context(in) - object.
Returns
string.

Referenced by binary(), getJournalDocuments(), info(), and sText().

◆ types()

QStringList aCfg::types ( const QString & filter = QString::null,
aCfgItem * obj = 0 )

Returns list of the configuration types. Every string in string list stored in format, consist of type's format string and type's human name fields, separated by tabulate char. For example: N d d\tNumberic C d\tChar O 221\tDocument.Invoice

Parameters
filter(in) - used to limit returned types. If this parameter is empty all types will be returned.
Returns
list of types.

References find().

◆ write() [1/2]

int aCfg::write ( const QString & fname)

helper method. Save current configuration.

References write().

Referenced by saveOneObject(), write(), and writerc().

◆ write() [2/2]

int aCfg::write ( QDomDocument doc,
const QString & fname )

Writes configuration information (metadata) to file.

Parameters
doc(in) - xml document to save.
fname(in) - name of configuration file.
Returns
error code.

◆ writerc()

int aCfg::writerc ( const QString & fname)

Writes resource file.

Parameters
(in)- rc file name to write to.
Returns
int.

References setModified(), and write().


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