Ananas Library  0.9.5
ecatalogue.ui.h
1 /****************************************************************************
2 ** $Id: ecatalogue.ui.h,v 1.7 2004/07/01 11:30:55 pashik Exp $
3 **
4 ** Code file of the edit catalogue plugin of Ananas
5 ** Designer and Engine applications
6 **
7 ** Created : 20031201
8 **
9 ** Copyright (C) 2003-2004 Leader InfoTech. All rights reserved.
10 **
11 ** This file is part of the Ananas Plugins of the Ananas
12 ** automation accounting system.
13 **
14 ** This file may be distributed and/or modified under the terms of the
15 ** GNU General Public License version 2 as published by the Free Software
16 ** Foundation and appearing in the file LICENSE.GPL included in the
17 ** packaging of this file.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru
23 ** See http://www.leaderit.ru/gpl/ for GPL licensing information.
24 **
25 ** Contact org@leaderit.ru if any conditions of this licensing are
26 ** not clear to you.
27 **
28 **********************************************************************/
29 
30 /****************************************************************************
31 ** ui.h extension file, included from the uic-generated form implementation.
32 **
33 ** If you wish to add, delete or rename functions or slots use
34 ** Qt Designer which will update this file, preserving your code. Create an
35 ** init() function in place of a constructor, and a destroy() function in
36 ** place of a destructor.
37 *****************************************************************************/
38 #include "acfg.h"
39 
40 void eCatalogue::init()
41 {
42 /*
43  int oc, i, f, idx=0;
44  char *id, *name, *ot;
45  cfg_objptr o;
46  char otype[100];
47  QString named;
48 
49  otypes.clear();
50  eType->clear();
51  otypes.append("D");
52  eType->insertItem(trUtf8("Дата"), idx++);
53  otypes.append("T");
54  eType->insertItem(trUtf8("Время"), idx++);
55  otypes.append("N %d %d");
56  eType->insertItem(trUtf8("Число"), idx++);
57  otypes.append("C %d");
58  eType->insertItem(trUtf8("Строка"), idx++);
59 
60  oc=cfgobj_count(NULL, NULL);
61  for (i=1;i<=oc;i++) {
62  id=cfgobj_idn(NULL, NULL, i, &o);
63  ot=(char *)o->name;
64  name=cfgobj_attr(o, "name");
65  named="";
66  f=0;
67  if (strcmp((char *)ot, aot_doc)==0) {
68  named=trUtf8("Документ.");
69  f=1;
70  }
71  if (strcmp((char *)ot, aot_cat)==0) {
72  named=trUtf8("Справочник.");
73  f=1;
74  }
75  if (f) {
76  named=named+trUtf8(name);
77  sprintf(otype, "O %s", id);
78  otypes.append(otype);
79  eType->insertItem(named, idx++);
80  }
81  }
82 */
83 }
84 
85 
86 
87 /*void eCatalogue::setData( aCatalogue *f, QWidget *mw )
88 {
89  aCfg *md = 0;
90  if ( !f ) return;
91 // printf("name = '%s'\n", (const char *) mw->name() );
92  if (mw->name() == QString("ananas-designer_mainwindow") ) {
93 // printf("running under ananas designer\n");
94  CfgForm *cf = ( ( MainForm *) mw )->cfgForm();
95  if ( cf ) {
96  md = &cf->cfg;
97 // QString ts = f->getFieldType();
98 // char t=' ';
99  int w=0, d=0, idx=0;
100  unsigned int i;
101  long oid , id;
102 
103  id = f->getId();
104 
105  otypes.clear();
106  eType->clear();
107 
108  QStringList tlist = md->types( md_catalogue );
109  otypes.clear();
110  eType->clear();
111  for ( QStringList::Iterator it = tlist.begin(); it != tlist.end(); ++it ) {
112  otypes.append( (*it).section( "\t", 0, 0 ) );
113  eType->insertItem( (*it).section("\t", 1, 1 ), idx++ );
114  }
115  for ( i = 0 ; i < otypes.count(); i++ ) {
116  oid = 0;
117  if( otypes[i][0] == 'O' ) {
118  sscanf( (const char *)otypes[ i ], "O %d", &oid );
119  if ( oid == id ) {
120  eType->setCurrentItem( i );
121  break;
122  }
123  }
124  }
125  } else reject();
126  }
127 
128 }
129 */
130 
131 void
132 eCatalogue::setData( QWidget *o, aCfg *md )
133 {
134 // const QObject *o = sender();
135  if ( o ) {
136  if ( o->className() != QString("wCatalogue") || !md ) {
137  reject();
138  return;
139  }
140  }
141  else {
142  reject();
143  return;
144  }
145  wCatalogue *f = ( wCatalogue*) o;
146  int w=0, d=0, idx=0;
147  unsigned int i;
148  long oid , id;
149 
150  id = f->getId();
151 
152  QStringList tlist = md->types( md_catalogue );
153  otypes.clear();
154  eType->clear();
155  for ( QStringList::Iterator it = tlist.begin(); it != tlist.end(); ++it ) {
156  otypes.append( (*it).section( "\t", 0, 0 ) );
157  eType->insertItem( (*it).section("\t", 1, 1 ), idx++ );
158  }
159  for ( i = 0 ; i < otypes.count(); i++ ) {
160  oid = 0;
161  if( otypes[i][0] == 'O' ) {
162  sscanf( (const char *)otypes[ i ], "O %d", &oid );
163  if ( oid == id ) {
164  eType->setCurrentItem( i );
165  break;
166  }
167  }
168  }
169 }
170 
171 
172 void eCatalogue::getData( QWidget * o )
173 {
174 
175 /* int idx=eType->currentItem();
176  long oid = 0;
177 
178  if (f) {
179  if( otypes[idx][0] == 'O' ) {
180  sscanf( (const char *)otypes[ idx ], "O %d", &oid );
181  f->setId( oid );
182  }
183  }
184 */
185 // const QObject *o = sender();
186  if ( !o ) return;
187  if ( o->className() != QString("wCatalogue") ) return;
188  wCatalogue *f = ( wCatalogue*) o;
189 
190  int idx=eType->currentItem();
191  long oid = 0;
192 
193  if (f) {
194  if( otypes[idx][0] == 'O' ) {
195  sscanf( (const char *)otypes[ idx ], "O %d", &oid );
196  f->setId( oid );
197  }
198  }
199 
200 }
201 
Definition: wcatalogue.h:43
QStringList types(const QString &filter=QString::null, aCfgItem *obj=0)
Definition: acfg.cpp:1297
Definition: acfg.h:436