Ananas Library  0.9.5
acfg.h
1 /****************************************************************************
2 ** $Id: acfg.h,v 1.123 2008/07/30 15:58:51 leader Exp $
3 **
4 ** Header file of the Ananas configuration objects of Ananas
5 ** Designer and Engine applications
6 **
7 ** Created : 20031201
8 **
9 ** Copyright (C) 2003-2004 Leader InfoTech. All rights reserved.
10 ** Copyright (C) Andrey Paskal <app at lrn dot ru>, Yoshkar-Ola
11 ** Copyright (C) 2003-2005 Grigory Panov <gr1313 at mail dot ru >, Yoshkar-Ola
12 **
13 ** This file is part of the Library of the Ananas
14 ** automation accounting system.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
22 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 **
24 ** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru
25 ** See http://www.leaderit.ru/gpl/ for GPL licensing information.
26 **
27 ** Contact org@leaderit.ru if any conditions of this licensing are
28 ** not clear to you.
29 **
30 **********************************************************************/
31 
32 /*
33 Ananas configuration objects.
34 (c) 2004 Leader InfoTech
35 */
36 #ifndef ACFG_H
37 #define ACFG_H
38 
39 #include "ananasglobal.h"
40 
41 #include <qdom.h>
42 //#include <qdict.h>
43 #include <qintdict.h>
44 #include "acfgrc.h"
45 
46 #ifdef __BORLANDC__
47 #define CHECK_POINT printf("%s:%i %s()\n",__FILE__,__LINE__,__FUNC__);
48 #else
49 #define CHECK_POINT printf("%s:%i %s()\n",__FILE__,__LINE__,__FUNCTION__);
50 #endif
51 
52 
53 extern void (*cfg_messageproc)(int , const char *);
54 void ANANAS_EXPORT cfg_message(int msgtype, const char *msgfmt,...);
55 void ANANAS_EXPORT debug_message(const char *msgfmt,...);
56 
57 class QObject;
58 
63 #define RC_OK 0
64 #define RC_ERROR 1
69 #define mdc_unknown 0
70 #define mdc_root 1
71 #define mdc_info 2
72 #define mdc_interface 3
73 #define mdc_metadata 4
74 #define mdc_globals 5
75 #define mdc_actions 6
77 //#define mdc_documents 6
78 //#define mdc_catalogues 7
79 //#define mdc_iregisters 8
80 //#define mdc_aregisters 9
81 //#define mdc_reports 10
82 //#define mdc_journals 11
87 #define md_root "ananas_configuration"
88 #define md_interface "interface"
89 
90 #define md_info "info"
91 #define md_info_name "name"
92 #define md_info_author "author"
93 #define md_info_date "date"
94 #define md_info_mdate "mdate"
95 #define md_info_remark "remark"
96 #define md_info_lastid "lastid"
97 //#define md_info_dir "dir"
98 
99 #define md_metadata "metadata"
100 #define md_globals "globals"
101 #define md_languages "languages"
102 #define md_language "language"
103 #define md_aliases "aliases"
104 #define md_alias "alias"
105 #define md_roles "roles"
106 #define md_role "role"
107 #define md_description "description"
108 #define md_sourcecode "sourcecode"
109 #define md_servermodule "server_module"
110 #define md_clientmodule "client_module"
111 #define md_formsource "form_source"
112 #define md_menutext "menutext"
113 #define md_argument "argument"
114 
115 #define md_documents "documents"
116 #define md_document "document"
117 
118 #define md_catalogues "catalogues"
119 #define md_catalogue "catalogue"
120 #define md_element "element"
121 #define md_group "group"
122 
123 #define md_string_view "string_view"
124 #define md_svfunction "svfunction"
125 
126 #define md_registers "registers"
127 #define md_iregisters "iregisters"
128 #define md_iregister "iregister"
129 #define md_aregisters "aregisters"
130 #define md_aregister "aregister"
131 
132 #define md_reports "reports"
133 #define md_report "report"
134 
135 #define md_journals "journals"
136 #define md_journal "journal"
137 #define md_columns "columns"
138 #define md_column "column"
139 #define md_used_doc "used_doc"
140 #define md_fieldid "fieldid"
141 
142 #define md_field "field"
143 #define md_forms "forms"
144 #define md_form "form"
145 #define md_defaultmod "defaultmod"
146 #define md_webforms "webforms"
147 #define md_webform "webform"
148 #define md_formdesign "dialogform"
149 
150 #define md_tables "tables"
151 #define md_table "table"
152 #define md_header "header"
153 
154 #define md_resources "resources"
155 #define md_dimensions "dimensions"
156 #define md_information "information"
157 
161 #define md_actions "actions"
162 #define md_actiongroup "actiongroup"
163 #define md_action "action"
164 #define md_objectid "objectid"
165 #define md_formid "formid"
166 #define md_actiontype "actiontype"
167 #define md_active_picture "active_picture"
168 #define md_passive_picture "passive_picture"
169 
173 #define md_interface "interface"
174 #define md_toolbars "toolbars"
175 #define md_toolbar "toolbar"
176 #define md_popupmenus "popupmenus"
177 #define md_popupmenu "popupmenu"
178 #define md_mainmenu "mainmenu"
179 #define md_submenu "submenu"
180 #define md_command "command"
181 #define md_comaction "comaction"
182 #define md_separator "separator"
183 #define md_key "key"
184 #define md_menutext "menutext"
185 //key modifiers
186 #define md_km_ctrl "Ctrl+"
187 #define md_km_alt "Alt+"
188 #define md_km_shift "Shift+"
189 
190 #define md_image_collection "image_collection"
191 #define md_image "image"
192 
193 
197 #define mda_name "name"
198 #define mda_id "id"
199 #define mda_type "type"
200 #define mda_readonly "readonly"
201 #define mda_lang "lang"
202 #define mda_nz "nz"
203 #define mda_sort "sort"
204 #define mda_no_unconduct "no_unconduct"
205 #define mda_plus "plus"
206 #define mda_sum "sum"
207 #define mda_tag "tag"
208 #define mda_trfile "trfile"
209 #define mda_length "length"
210 #define mda_format "format"
211 #define mda_stdf "stdf"
212 #define mda_rights "rights"
213 #define mda_vd "vd"
214 #define mda_twostate "twostate"
215 #define mda_validator "validator"
216 #define mda_inputmask "inputmask"
217 #define mda_numerator "numerator"
218 #define mda_numpref "numpref"
219 #define mda_numsuff "numsuff"
220 #define mda_numdate "numdate"
221 #define mda_lz "lz"
222 
223 
227 #define md_action_new 0
228 #define md_action_edit 1
229 #define md_action_view 2
230 #define md_action_execute 3
231 
237 #define md_form_nouse 0
238 #define md_form_new 1
239 #define md_form_view 2
240 #define md_form_edit 3
241 #define md_form_select 4
242 
243 
248 #define md_form_elem_list 0
249 #define md_form_elem 1
250 #define md_form_group 2
251 
252 
257 #define md_systemjournal 1
258 #define md_aregarhive 2
259 
260 //class aCfg;
261 //extern aCfg cfg;
262 
263 #define ERR_Code int
264 
265 #define err_unknown -1//some ote error
266 #define err_noerror 0// result successful
267 #define err_notable 1// no table with such name
268 #define err_objnotfound 2// no such object in metadata
269 #define err_incorrecttype 3// object has othe metadata id
270 #define err_uidnotfound 4// no such id in unicues
271 #define err_notselected 5// select return nothing
272 #define err_nodatabase 6// database is not inited
273 #define err_selecterror 7// select return some error
274 #define err_condition 8// error in condition
275 #define err_noobject 9// aObject didn't init md object
276 #define err_nosysjournal 10// system journal not inited
277 #define err_inserterror 11// insert in aSQLTable return false
278 #define err_execerror 12// exec return false
279 #define err_updateerror 13// update reutrn false
280 #define err_abstractobj 14// you need to use hi level object or specimen of object
281 #define err_fieldnotfound 15// no filed with such name
282 #define err_copyerror 16// object don't copy
283 #define err_nocatalogue 17// catalogue not found
284 #define err_nogroup 18// group not found
285 #define err_deleteerror 19// object don't deleted or don't mark deleted
286 #define err_nodocument 20// no such document
287 #define err_emptyperiod 21// you try close empty period
288 #define err_noresources 22// the register object have no resources tag in metadata
289 #define err_incorrectname 23// object have incorrect name
290 #define err_closeperiod 24// close period error
291 #define err_conducterror 25// error when document conducting
292 #define err_docconducted 26// you can't change conducted document or conduct document once more
293 #define err_docunconducted 27// you can unconduct document if it not conducted
294 #define err_cyclereparent 28//you have cycle when try reparent
295 #define err_readonly 29//object is readonly
296 #define err_invaliddate 30// invalid date or datetime specified
297 #define err_nodimensions 31// the register object have no dimensions tag in metadata
298 #define err_nowidgetfound 32// there is no such widget in form
299 #define err_invalidparamvalue 33// invalid parameter value
300 
301 #define md_user_roles "userroles"
302 #define md_users "users"
303 #define md_user "user"
304 #define md_usr_role "u_role"
305 #define md_roles "roles"
306 #define md_role "role"
307 #define md_rl_users "r_users"
308 #define md_rl_user "r_user"
309 #define md_right_roles "rroles"
310 
311 #define perm_read 0
312 #define perm_execute 1
313 #define perm_create 2
314 #define perm_delete 3
315 #define perm_turn_on 4
316 #define perm_turn_off 5
317 #define perm_admin 6
318 
319 #define aPermission int
320 
321 #define aCfgItem QDomElement
322 
323 
324 
337 class ANANAS_EXPORT aCfgItemContaner: public QObject
338 {
339 public:
340  long id;
341  aCfgItem item;
342  aCfgItemContaner(long newid, aCfgItem newitem);
343 };
344 
345 /*
346 class ANANAS_EXPORT aCfgFieldType: public QObject
347 {
348 public:
349  QString name, type;
350  aCfgFieldType( const QString &newname, const QString &newtype);
351  aCfgFieldType( aCfgItem newitem );
352 };
353 */
354 
355 
356 
366 class ANANAS_EXPORT AMetadataObject: public QObject
367 {
368 Q_OBJECT
369 public:
370  AMetadataObject( const QString &Name = QString::null );
371 public slots:
372  QString Class();
373 private:
374  QString MDClassName;
375 };
376 
377 
378 
388 class ANANAS_EXPORT AMetadataGroup: public AMetadataObject
389 {
390 Q_OBJECT
391 public:
392  AMetadataGroup( const QString &Name = QString::null );
393 public slots:
394  int Count(){return 0;};
395 private:
396 
397 };
398 
399 
400 
410 class ANANAS_EXPORT AMetadataRoot: public AMetadataGroup
411 {
412 Q_OBJECT
413 public:
414  AMetadataRoot();
415  ~AMetadataRoot();
416 private:
417 
418 };
419 
420 
421 
436 class ANANAS_EXPORT aCfg: public QObject //QDomDocument
437 {
438  Q_OBJECT
439 
440 public:
441  enum fieldType { ftUnknown, ftChar, ftNumberic, ftDate, ftObject };
442  aCfgRc rc;
443 
444  aCfg();
445  ~aCfg();
446 
447  int read(const QString &fname);
448  int write(const QString &fname);
449  int write(QDomDocument doc, const QString &fname);
450  int readrc(const QString &fname);
451  int writerc(const QString &fname);
452  bool compressed();
453  void setCompressed( bool mode );
454  bool modified();
455  void setModified( bool mode );
456 // void print();
457  void createNew();
458 
459  QString info(const QString &name);
460  void setInfo(const QString &name, const QString &value);
461 
462  long getId( QString &name );
463  long id(aCfgItem context);
464 
465  QString objClass( long id );
466  QString objClass( aCfgItem context );
467 
468  int count(aCfgItem context, const QString &classname);
469  int countChild(aCfgItem context, const QString &classname = QString::null );
470 
471  QString attr(aCfgItem context, const QString &name);
472  void setAttr(aCfgItem context, const QString &name, const QString &value);
473  void setAttr(aCfgItem context, const QString &name, int value);
474 
475  QString text(aCfgItem context);
476  void setText(aCfgItem context, const QString &value );
477  QByteArray binary( aCfgItem context );
478  void setBinary( aCfgItem context, const QByteArray &value, const QString &format = QString::null );
479  QString binaryFormat( aCfgItem context );
480  QString sText(aCfgItem context, const QString & subname );
481  void setSText(aCfgItem context, const QString & subname, const QString &value);
482 
483  aCfgItem find(aCfgItem context, const QString &name, int n = 0 );
484  aCfgItem find(long id);
485  aCfgItem find(const QString &name);
486  aCfgItem findChild(aCfgItem context, const QString &classname, int n = 0 );
487  aCfgItem findName(aCfgItem context, const QString &classname, const QString &name = QString::null );
488 
489  bool swap( aCfgItem &item1, aCfgItem &item2);
490  int order( aCfgItem item );
491  aCfgItem parent( aCfgItem context );
492  aCfgItem firstChild( aCfgItem context );
493  aCfgItem lastChild( aCfgItem context );
494  aCfgItem nextSibling( aCfgItem context );
495  aCfgItem previousSibling( aCfgItem context );
496 
497  aCfgItem insert(aCfgItem context, const QString &otype, const QString &name = QString::null, long id = 0);
498  int saveOneObject(aCfgItem context, const QString &fileName);
499  aCfgItem loadOneObject(const QString &fileName);
500  void remove(aCfgItem context);
501 
502  aCfgItem importCfgItem( aCfgItem context, aCfgItem obj );
503  void setupNewId( aCfgItem obj );
504 
505  QStringList types( const QString &filter = QString::null, aCfgItem *obj = 0 );
506  QStringList ObjectTypes();
507 
508  // Hi level functions.
509  aCfgItem insertDocument( const QString &name );
510  aCfgItem insertDocumentTable(aCfgItem owner, const QString &name );
511  aCfgItem insertCatalogue( const QString &name );
512  aCfgItem insertIRegister ( const QString &name );
513  aCfgItem insertARegister ( const QString &name );
514  aCfgItem insertJournal ( const QString &name );
515  aCfgItem insertReport ( const QString &name );
516  aCfgItem insertField( aCfgItem owner, const QString &section, const QString &name,const QString &ftype );
517  aCfgItem insertForm( aCfgItem owner, const QString &name );
518  aCfgItem insertWebForm( aCfgItem owner, const QString &name );
519 
520  long getDefaultFormId( aCfgItem owner, int actiontype, int mode =0 );
521  QStringList getJournalDocuments( aCfgItem journal );
522  aCfgItem findJournal(int jtype, aCfgItem doc);
523  QStringList objTables( aCfgItem obj );
524  QStringList objTables( int objid );
525  aCfgItem objTable( aCfgItem obj, int id );
526  aCfgItem objTable( int objid, int id );
527 
528 public slots:
529  QString Info( QString partname );
530 
531 signals:
532  void message( int messageType, const QString & messageText );
533 
534 private:
535  QDomDocument xml;
536  bool fCompressed, fModified;
537  // QDomElement root;
538  aCfgItem rootnode, cfginfo, md,
539  iface,
540  actions;
541  QIntDict <aCfgItemContaner> idcache;
542  long nextID();
543  void init();
544 
545  void addTypes( QStringList &list, aCfgItem context, const QString &tobject, const QString &tname);
546 };
547 
548 #endif
Definition: acfg.h:337
Definition: acfgrc.h:52
Definition: acfg.h:436
Definition: acfg.h:366
Definition: acfg.h:388
Definition: acfg.h:410