Ananas Library 0.9.5
|
#include <acfg.h>
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 §ion, 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 |
System configuration object.
Using for story and edit accountine system configuration.
aCfg::aCfg | ( | ) |
Ananas configuation object constructor.
References createNew(), setCompressed(), and setModified().
aCfg::~aCfg | ( | ) |
Ananas configuation object destructor.
QString aCfg::attr | ( | aCfgItem | context, |
const QString & | name ) |
Returns object's attribute value.
context | (in) - object. |
name | (in) - attribute name. |
Referenced by binary(), binaryFormat(), getDefaultFormId(), getJournalDocuments(), id(), objTables(), remove(), and setupNewId().
QByteArray aCfg::binary | ( | aCfgItem | context | ) |
QString aCfg::binaryFormat | ( | aCfgItem | context | ) |
Returns format of metadata tree node binary data.
context | (in) - node of metadata tree. |
References attr().
bool aCfg::compressed | ( | ) |
Returns configuration file compression mode.
int aCfg::count | ( | aCfgItem | context, |
const QString & | classname ) |
Counts specified objects in metadata tree.
context | (in) - parent of objects to count. May be a root of metadata tree. |
classname | (in) - class of objects to count. |
Referenced by getDefaultFormId(), getJournalDocuments(), and objTables().
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.
context | (in) - parent of objects to count. May be a root of metadata tree. |
classname | (in) - class of objects to count. |
References firstChild(), nextSibling(), and objClass().
void aCfg::createNew | ( | ) |
Creates new empty configuration.
References insert(), aLog::print(), setInfo(), and setModified().
aCfgItem aCfg::find | ( | aCfgItem | context, |
const QString & | name, | ||
int | n = 0 ) |
Finds object by its name and number.
context | (in) - context to seach in. |
name | (in) - name of object to search for. |
n | (in) - number of object in found context. |
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().
aCfgItem aCfg::find | ( | const QString & | name | ) |
Finds object by its full name.
name | (in) - object's full name. |
References find(), and aLog::print().
aCfgItem aCfg::find | ( | long | id | ) |
Finds object by unique ID in metadata tree.
id | (in) - id to search for. |
References id().
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.
context | (in) - node in metadata tree. |
Referenced by countChild(), remove(), and setupNewId().
long aCfg::getDefaultFormId | ( | aCfgItem | owner, |
int | actiontype, | ||
int | mode = 0 ) |
long aCfg::getId | ( | QString & | name | ) |
QStringList aCfg::getJournalDocuments | ( | aCfgItem | journal | ) |
long aCfg::id | ( | aCfgItem | context | ) |
Returns configuration object ID.
context | (in) - object which ID we looking for. |
References attr().
Referenced by find(), getDefaultFormId(), getId(), objTables(), remove(), setupNewId(), aExtSQL::SqlFieldName(), and aDatabase::tableDbName().
aCfgItem aCfg::importCfgItem | ( | aCfgItem | context, |
aCfgItem | objFromAnotherCfg ) |
Import configuration object from another configuration.
context | - parent for imported object |
objFromAnotherCfg | - imported object |
References setupNewId().
QString aCfg::info | ( | const QString & | name | ) |
Returns value of info section field of configuration.
name | (in) - name of field to fetch value from. |
References text().
aCfgItem aCfg::insert | ( | aCfgItem | context, |
const QString & | otype, | ||
const QString & | name = QString::null, | ||
long | id = 0 ) |
Inserts a new object into metadata tree.
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. |
References setAttr(), and setModified().
Referenced by createNew(), insertARegister(), insertCatalogue(), insertDocument(), insertDocumentTable(), insertField(), insertForm(), insertIRegister(), insertJournal(), insertReport(), insertWebForm(), and setSText().
aCfgItem aCfg::insertARegister | ( | const QString & | name | ) |
aCfgItem aCfg::insertCatalogue | ( | const QString & | name | ) |
aCfgItem aCfg::insertDocument | ( | const QString & | name | ) |
aCfgItem aCfg::insertDocumentTable | ( | aCfgItem | owner, |
const QString & | name ) |
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.
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. |
aCfgItem aCfg::insertForm | ( | aCfgItem | owner, |
const QString & | name ) |
aCfgItem aCfg::insertIRegister | ( | const QString & | name | ) |
aCfgItem aCfg::insertJournal | ( | const QString & | name | ) |
aCfgItem aCfg::insertReport | ( | const QString & | name | ) |
aCfgItem aCfg::insertWebForm | ( | aCfgItem | owner, |
const QString & | name ) |
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.
aCfgItem aCfg::loadOneObject | ( | const QString & | fileName | ) |
Load configuration object from file.
fileName | - file name |
References aLog::print().
bool aCfg::modified | ( | ) |
Returns modification status.
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().
QString aCfg::objClass | ( | aCfgItem | context | ) |
Returns class name of object.
context | (in) - object. |
QString aCfg::objClass | ( | long | id | ) |
Returns class name of object.
id | (in) - object id. |
References find(), and objClass().
Referenced by countChild(), getJournalDocuments(), objClass(), objTable(), objTables(), setAttr(), aExtSQL::SqlFieldName(), aExtSQL::SqlTableName(), and aDatabase::tableDbName().
QStringList aCfg::ObjectTypes | ( | ) |
aCfgItem aCfg::objTable | ( | aCfgItem | obj, |
int | id ) |
Return context of the object table by id. This function used by Database tables plugins.
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. |
References find(), and objClass().
Referenced by objTable().
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.
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. |
References find(), and objTable().
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.
obj | (in) - metadata object. |
References attr(), count(), find(), id(), and objClass().
Referenced by objTables().
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.
objid | (in) - metadata object id. |
References find(), and objTables().
int aCfg::order | ( | aCfgItem | item | ) |
Returns onject's order number among siblings.
item | (in) - object. |
References previousSibling().
aCfgItem aCfg::parent | ( | aCfgItem | context | ) |
Returns parent object.
context | (in) - object. |
Referenced by swap(), and aDatabase::tableDbName().
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().
int aCfg::read | ( | const QString & | fname | ) |
Reads configuration information (metadata) from file.
fname | (in) - name of configuration file. |
References aLog::print(), and setModified().
Referenced by readrc().
int aCfg::readrc | ( | const QString & | fname | ) |
Reads resource file.
fname | (in) - rc file name. |
References createNew(), aLog::print(), and read().
void aCfg::remove | ( | aCfgItem | context | ) |
Removes metadata object from metadata tree. All children objects also removed.
context | (in) - metadata object. |
References attr(), firstChild(), id(), remove(), and setModified().
Referenced by getJournalDocuments(), and remove().
int aCfg::saveOneObject | ( | aCfgItem | context, |
const QString & | fileName ) |
Saves configuration object to file.
context | - object to save |
fileName | - file name |
References aLog::print(), and write().
void aCfg::setAttr | ( | aCfgItem | context, |
const QString & | name, | ||
const QString & | value ) |
Sets object's attribute value.
context | (in) - object. |
name | (in) - attribute's name. |
value | (in) - new value. |
References objClass(), and setModified().
Referenced by insert(), insertField(), setBinary(), and setupNewId().
void aCfg::setAttr | ( | aCfgItem | context, |
const QString & | name, | ||
int | value ) |
Changes value of object's attribute.
context | (in) - object. |
name | (in) - attribute's name. |
value | (in) - new attribute's vakue. |
References setModified().
void aCfg::setBinary | ( | aCfgItem | context, |
const QByteArray & | value, | ||
const QString & | format = QString::null ) |
void aCfg::setCompressed | ( | bool | mode | ) |
Sets compression mode of configuration file.
mode | (in) - compression mode. |
Referenced by aCfg().
void aCfg::setInfo | ( | const QString & | name, |
const QString & | value ) |
Sets new value to specified field of info section of configuration.
name | (in) - field's name. |
value | (in) - field's value. |
References setModified(), and setText().
Referenced by createNew().
void aCfg::setModified | ( | bool | mode | ) |
void aCfg::setSText | ( | aCfgItem | context, |
const QString & | subname, | ||
const QString & | value ) |
void aCfg::setText | ( | aCfgItem | context, |
const QString & | value ) |
Sets text for object.
context | (in) - object. |
value | (in) - new value. |
References setModified().
Referenced by setBinary(), setInfo(), and setSText().
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().
QString aCfg::sText | ( | aCfgItem | context, |
const QString & | subname ) |
Returns text value of child node of metadata tree.
context | (in) - parent node. |
subname | (in) - name of child node. |
References text().
Referenced by getDefaultFormId().
bool aCfg::swap | ( | aCfgItem & | item1, |
aCfgItem & | item2 ) |
Swaps two items in metadata tree.
item1 | (in) - first item to swap. |
item2 | (in) - second item to swap. |
References parent(), aLog::print(), and setModified().
QString aCfg::text | ( | aCfgItem | context | ) |
Returns text of object.
context | (in) - object. |
Referenced by binary(), getJournalDocuments(), info(), and sText().
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
filter | (in) - used to limit returned types. If this parameter is empty all types will be returned. |
References find().
int aCfg::write | ( | const QString & | fname | ) |
helper method. Save current configuration.
References write().
Referenced by saveOneObject(), write(), and writerc().
int aCfg::write | ( | QDomDocument | doc, |
const QString & | fname ) |
Writes configuration information (metadata) to file.
doc | (in) - xml document to save. |
fname | (in) - name of configuration file. |
int aCfg::writerc | ( | const QString & | fname | ) |
Writes resource file.
(in) | - rc file name to write to. |
References setModified(), and write().