00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef ACFG_H
00037 #define ACFG_H
00038
00039 #include "ananasglobal.h"
00040
00041 #include <qdom.h>
00042
00043 #include <qintdict.h>
00044 #include "acfgrc.h"
00045
00046 #ifdef __BORLANDC__
00047 #define CHECK_POINT printf("%s:%i %s()\n",__FILE__,__LINE__,__FUNC__);
00048 #else
00049 #define CHECK_POINT printf("%s:%i %s()\n",__FILE__,__LINE__,__FUNCTION__);
00050 #endif
00051
00052
00053 extern void (*cfg_messageproc)(int , const char *);
00054 void ANANAS_EXPORT cfg_message(int msgtype, const char *msgfmt,...);
00055 void ANANAS_EXPORT debug_message(const char *msgfmt,...);
00056
00057 class QObject;
00058
00063 #define RC_OK 0
00064 #define RC_ERROR 1
00069 #define mdc_unknown 0
00070 #define mdc_root 1
00071 #define mdc_info 2
00072 #define mdc_interface 3
00073 #define mdc_metadata 4
00074 #define mdc_globals 5
00075 #define mdc_actions 6
00077 //#define mdc_documents 6
00078 //#define mdc_catalogues 7
00079 //#define mdc_iregisters 8
00080 //#define mdc_aregisters 9
00081 //#define mdc_reports 10
00082 //#define mdc_journals 11
00087 #define md_root "ananas_configuration"
00088 #define md_interface "interface"
00089
00090 #define md_info "info"
00091 #define md_info_name "name"
00092 #define md_info_author "author"
00093 #define md_info_date "date"
00094 #define md_info_mdate "mdate"
00095 #define md_info_remark "remark"
00096 #define md_info_lastid "lastid"
00097
00098
00099 #define md_metadata "metadata"
00100 #define md_globals "globals"
00101 #define md_languages "languages"
00102 #define md_language "language"
00103 #define md_aliases "aliases"
00104 #define md_alias "alias"
00105 #define md_roles "roles"
00106 #define md_role "role"
00107 #define md_description "description"
00108 #define md_sourcecode "sourcecode"
00109 #define md_servermodule "server_module"
00110 #define md_clientmodule "client_module"
00111 #define md_formsource "form_source"
00112 #define md_menutext "menutext"
00113 #define md_argument "argument"
00114
00115 #define md_documents "documents"
00116 #define md_document "document"
00117
00118 #define md_catalogues "catalogues"
00119 #define md_catalogue "catalogue"
00120 #define md_element "element"
00121 #define md_group "group"
00122
00123 #define md_string_view "string_view"
00124 #define md_svfunction "svfunction"
00125
00126 #define md_registers "registers"
00127 #define md_iregisters "iregisters"
00128 #define md_iregister "iregister"
00129 #define md_aregisters "aregisters"
00130 #define md_aregister "aregister"
00131
00132 #define md_reports "reports"
00133 #define md_report "report"
00134
00135 #define md_journals "journals"
00136 #define md_journal "journal"
00137 #define md_columns "columns"
00138 #define md_column "column"
00139 #define md_used_doc "used_doc"
00140 #define md_fieldid "fieldid"
00141
00142 #define md_field "field"
00143 #define md_forms "forms"
00144 #define md_form "form"
00145 #define md_defaultmod "defaultmod"
00146 #define md_webforms "webforms"
00147 #define md_webform "webform"
00148 #define md_formdesign "dialogform"
00149
00150 #define md_tables "tables"
00151 #define md_table "table"
00152 #define md_header "header"
00153
00154 #define md_resources "resources"
00155 #define md_dimensions "dimensions"
00156 #define md_information "information"
00157
00161 #define md_actions "actions"
00162 #define md_actiongroup "actiongroup"
00163 #define md_action "action"
00164 #define md_objectid "objectid"
00165 #define md_formid "formid"
00166 #define md_actiontype "actiontype"
00167 #define md_active_picture "active_picture"
00168 #define md_passive_picture "passive_picture"
00169
00173 #define md_interface "interface"
00174 #define md_toolbars "toolbars"
00175 #define md_toolbar "toolbar"
00176 #define md_popupmenus "popupmenus"
00177 #define md_popupmenu "popupmenu"
00178 #define md_mainmenu "mainmenu"
00179 #define md_submenu "submenu"
00180 #define md_command "command"
00181 #define md_comaction "comaction"
00182 #define md_separator "separator"
00183 #define md_key "key"
00184 #define md_menutext "menutext"
00185
00186 #define md_km_ctrl "Ctrl+"
00187 #define md_km_alt "Alt+"
00188 #define md_km_shift "Shift+"
00189
00190 #define md_image_collection "image_collection"
00191 #define md_image "image"
00192
00193
00197 #define mda_name "name"
00198 #define mda_id "id"
00199 #define mda_type "type"
00200 #define mda_readonly "readonly"
00201 #define mda_lang "lang"
00202 #define mda_nz "nz"
00203 #define mda_sort "sort"
00204 #define mda_no_unconduct "no_unconduct"
00205 #define mda_plus "plus"
00206 #define mda_sum "sum"
00207 #define mda_tag "tag"
00208 #define mda_trfile "trfile"
00209 #define mda_length "length"
00210 #define mda_format "format"
00211 #define mda_stdf "stdf"
00212 #define mda_rights "rights"
00213 #define mda_vd "vd"
00214 #define mda_twostate "twostate"
00215 #define mda_validator "validator"
00216 #define mda_inputmask "inputmask"
00217 #define mda_numerator "numerator"
00218 #define mda_numpref "numpref"
00219 #define mda_numsuff "numsuff"
00220 #define mda_numdate "numdate"
00221 #define mda_lz "lz"
00222
00223
00227 #define md_action_new 0
00228 #define md_action_edit 1
00229 #define md_action_view 2
00230 #define md_action_execute 3
00231
00237 #define md_form_nouse 0
00238 #define md_form_new 1
00239 #define md_form_view 2
00240 #define md_form_edit 3
00241 #define md_form_select 4
00242
00243
00248 #define md_form_elem_list 0
00249 #define md_form_elem 1
00250 #define md_form_group 2
00251
00252
00257 #define md_systemjournal 1
00258 #define md_aregarhive 2
00259
00260
00261
00262
00263 #define ERR_Code int
00264
00265 #define err_unknown -1//some ote error
00266 #define err_noerror 0// result successful
00267 #define err_notable 1// no table with such name
00268 #define err_objnotfound 2// no such object in metadata
00269 #define err_incorrecttype 3// object has othe metadata id
00270 #define err_uidnotfound 4// no such id in unicues
00271 #define err_notselected 5// select return nothing
00272 #define err_nodatabase 6// database is not inited
00273 #define err_selecterror 7// select return some error
00274 #define err_condition 8// error in condition
00275 #define err_noobject 9// aObject didn't init md object
00276 #define err_nosysjournal 10// system journal not inited
00277 #define err_inserterror 11// insert in aSQLTable return false
00278 #define err_execerror 12// exec return false
00279 #define err_updateerror 13// update reutrn false
00280 #define err_abstractobj 14// you need to use hi level object or specimen of object
00281 #define err_fieldnotfound 15// no filed with such name
00282 #define err_copyerror 16// object don't copy
00283 #define err_nocatalogue 17// catalogue not found
00284 #define err_nogroup 18// group not found
00285 #define err_deleteerror 19// object don't deleted or don't mark deleted
00286 #define err_nodocument 20// no such document
00287 #define err_emptyperiod 21// you try close empty period
00288 #define err_noresources 22// the register object have no resources tag in metadata
00289 #define err_incorrectname 23// object have incorrect name
00290 #define err_closeperiod 24// close period error
00291 #define err_conducterror 25// error when document conducting
00292 #define err_docconducted 26// you can't change conducted document or conduct document once more
00293 #define err_docunconducted 27// you can unconduct document if it not conducted
00294 #define err_cyclereparent 28//you have cycle when try reparent
00295 #define err_readonly 29//object is readonly
00296 #define err_invaliddate 30// invalid date or datetime specified
00297 #define err_nodimensions 31// the register object have no dimensions tag in metadata
00298 #define err_nowidgetfound 32// there is no such widget in form
00299 #define err_invalidparamvalue 33// invalid parameter value
00300
00301 #define md_user_roles "userroles"
00302 #define md_users "users"
00303 #define md_user "user"
00304 #define md_usr_role "u_role"
00305 #define md_roles "roles"
00306 #define md_role "role"
00307 #define md_rl_users "r_users"
00308 #define md_rl_user "r_user"
00309 #define md_right_roles "rroles"
00310
00311 #define perm_read 0
00312 #define perm_execute 1
00313 #define perm_create 2
00314 #define perm_delete 3
00315 #define perm_turn_on 4
00316 #define perm_turn_off 5
00317 #define perm_admin 6
00318
00319 #define aPermission int
00320
00321 #define aCfgItem QDomElement
00322
00323
00324
00337 class ANANAS_EXPORT aCfgItemContaner: public QObject
00338 {
00339 public:
00340 long id;
00341 aCfgItem item;
00342 aCfgItemContaner(long newid, aCfgItem newitem);
00343 };
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00366 class ANANAS_EXPORT AMetadataObject: public QObject
00367 {
00368 Q_OBJECT
00369 public:
00370 AMetadataObject( aCfgItem newitem );
00371 public slots:
00372 QString Class();
00373 private:
00374 aCfgItem item;
00375 };
00376
00377
00378
00393 class ANANAS_EXPORT aCfg: public QObject
00394 {
00395 Q_OBJECT
00396
00397 public:
00398 enum fieldType { ftUnknown, ftChar, ftNumberic, ftDate, ftObject };
00399 aCfgRc rc;
00400
00401 aCfg();
00402 ~aCfg();
00403
00404 int read(const QString &fname);
00405 int write(const QString &fname);
00406 int write(QDomDocument doc, const QString &fname);
00407 int readrc(const QString &fname);
00408 int writerc(const QString &fname);
00409 bool compressed();
00410 void setCompressed( bool mode );
00411 bool modified();
00412 void setModified( bool mode );
00413
00414 void createNew();
00415
00416 QString info(const QString &name);
00417 void setInfo(const QString &name, const QString &value);
00418
00419 long getId( QString &name );
00420 long id(aCfgItem context);
00421
00422 QString objClass( long id );
00423 QString objClass( aCfgItem context );
00424
00425 int count(aCfgItem context, const QString &classname);
00426 int countChild(aCfgItem context, const QString &classname = QString::null );
00427
00428 QString attr(aCfgItem context, const QString &name);
00429 void setAttr(aCfgItem context, const QString &name, const QString &value);
00430 void setAttr(aCfgItem context, const QString &name, int value);
00431
00432 QString text(aCfgItem context);
00433 void setText(aCfgItem context, const QString &value );
00434 QByteArray binary( aCfgItem context );
00435 void setBinary( aCfgItem context, const QByteArray &value, const QString &format = QString::null );
00436 QString binaryFormat( aCfgItem context );
00437 QString sText(aCfgItem context, const QString & subname );
00438 void setSText(aCfgItem context, const QString & subname, const QString &value);
00439
00440 aCfgItem find(aCfgItem context, const QString &name, int n = 0 );
00441 aCfgItem find(long id);
00442 aCfgItem find(const QString &name);
00443 aCfgItem findChild(aCfgItem context, const QString &classname, int n = 0 );
00444 aCfgItem findName(aCfgItem context, const QString &classname, const QString &name = QString::null );
00445
00446 bool swap( aCfgItem &item1, aCfgItem &item2);
00447 int order( aCfgItem item );
00448 aCfgItem parent( aCfgItem context );
00449 aCfgItem firstChild( aCfgItem context );
00450 aCfgItem lastChild( aCfgItem context );
00451 aCfgItem nextSibling( aCfgItem context );
00452 aCfgItem previousSibling( aCfgItem context );
00453
00454 aCfgItem insert(aCfgItem context, const QString &otype, const QString &name = QString::null, long id = 0);
00455 int saveOneObject(aCfgItem context, const QString &fileName);
00456 aCfgItem loadOneObject(const QString &fileName);
00457 void remove(aCfgItem context);
00458
00459 aCfgItem importCfgItem( aCfgItem context, aCfgItem obj );
00460 void setupNewId( aCfgItem obj );
00461
00462 QStringList types( const QString &filter = QString::null, aCfgItem *obj = 0 );
00463 QStringList ObjectTypes();
00464
00465
00466 aCfgItem insertDocument( const QString &name );
00467 aCfgItem insertDocumentTable(aCfgItem owner, const QString &name );
00468 aCfgItem insertCatalogue( const QString &name );
00469 aCfgItem insertIRegister ( const QString &name );
00470 aCfgItem insertARegister ( const QString &name );
00471 aCfgItem insertJournal ( const QString &name );
00472 aCfgItem insertReport ( const QString &name );
00473 aCfgItem insertField( aCfgItem owner, const QString §ion, const QString &name,const QString &ftype );
00474 aCfgItem insertForm( aCfgItem owner, const QString &name );
00475 aCfgItem insertWebForm( aCfgItem owner, const QString &name );
00476
00477 long getDefaultFormId( aCfgItem owner, int actiontype, int mode =0 );
00478 QStringList getJournalDocuments( aCfgItem journal );
00479 aCfgItem findJournal(int jtype, aCfgItem doc);
00480 QStringList objTables( aCfgItem obj );
00481 QStringList objTables( int objid );
00482 aCfgItem objTable( aCfgItem obj, int id );
00483 aCfgItem objTable( int objid, int id );
00484
00485 public slots:
00486 QString Info( QString partname );
00487
00488 signals:
00489 void message( int messageType, const QString & messageText );
00490
00491 private:
00492 QDomDocument xml;
00493 bool fCompressed, fModified;
00494
00495 aCfgItem rootnode, cfginfo, md,
00496 iface,
00497 actions;
00498 QIntDict <aCfgItemContaner> idcache;
00499 long nextID();
00500 void init();
00501
00502 void addTypes( QStringList &list, aCfgItem context, const QString &tobject, const QString &tname);
00503 };
00504
00505 #endif