Ananas Library  0.9.5
efield.ui.h
1 /****************************************************************************
2 ** $Id: efield.ui.h,v 1.13 2007/04/19 07:30:49 gr Exp $
3 **
4 ** Code file of the edit field 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 #include <stdlib.h>
40 
41 void eField::init()
42 {
43 
44 
45 
46 }
47 
48 
49 
50 void eField::setData( QWidget *o, aCfg *cfg )
51 {
52  md = cfg;
53  if(!o)
54  {
55  reject();
56  return;
57  }
58  if ( o->className() != QString("wField") || !md ) {
59  reject();
60  return;
61  }
62  wField *f = ( wField*) o;
63  QString ts = f->getFieldType();
64 // printf(">>> fieldType = %s;\n", ts.ascii() );
65  char t=' ';
66  int w=0, d=0, oid, idx=0;
67  unsigned int i;
68 
69 // eName->setText(f->getName());
70  otypes.clear();
71  eType->clear();
72 
73  QStringList tlist = md->types();
74  otypes.clear();
75  eType->clear();
76  for ( QStringList::Iterator it = tlist.begin(); it != tlist.end(); ++it ) {
77  otypes.append( (*it).section( "\t", 0, 0 ) );
78  eType->insertItem( (*it).section("\t", 1, 1 ), idx++ );
79  }
80  if ( !ts.isEmpty() ) {
81  sscanf( ts, "%c %d %d", &t, &w, &d );
82  } else {
83  t = 'N';
84  w = 10;
85  }
86  if ( t=='O' ) {
87  for( i = 0 ; i < otypes.count(); i++ ) {
88  if( otypes[i][0] == 'O' ) {
89  sscanf( (const char *)otypes[ i ], "O %d", &oid );
90  if ( oid == w ) {
91  eType->setCurrentItem( i );
92  break;
93  }
94  }
95  }
96  } else {
97  eWidth->setValue( w );
98  eDec->setValue( d );
99  if ( t == ' ' ) eType->setCurrentItem( 0 );
100  if ( t == 'N' ) eType->setCurrentItem( 1 );
101  if ( t == 'C' ) eType->setCurrentItem( 2 );
102  if ( t == 'D' ) eType->setCurrentItem( 3 );
103  if ( t == 'B' ) eType->setCurrentItem( 4 );
104  }
105  typeSelect( eType->currentItem() );
106 }
107 
108 
109 void eField::getData( QWidget *o )
110 {
111 // const QObject *o = sender();
112  if ( !o ) return;
113  if ( o->className() != QString("wField") ) return;
114  wField *f = ( wField*) o;
115  wField::tEditorType type;
116  char ntype[40]="";
117  int idx=eType->currentItem();
118 
119  if (f) {
120  //f->setName(eName->text());
121  sprintf(ntype, (const char *) otypes[idx], eWidth->value(), eDec->value());
122  f->setFieldType(ntype);
123  if(otypes[idx][0]==' ') type = wField::Unknown;
124  if(otypes[idx][0]=='N') type = wField::Numberic;
125  if(otypes[idx][0]=='C') type = wField::String;
126  if(otypes[idx][0]=='D') type = wField::Date;
127  if(otypes[idx][0]=='B') type = wField::Boolean;
128  if(otypes[idx][0]=='O')
129  {
130  QString tmp = otypes[idx].section(' ',1,1);
131  long tid = atol(tmp);
132  aCfgItem item = md->find(tid);
133  if(!item.isNull())
134  {
135  //gets object class
136  tmp = md->objClass(item);
137  if(tmp == md_catalogue)
138  type = wField::Catalogue;
139  if(tmp == md_document)
140  type = wField::Document;
141  }
142  }
143  f->setEditorType(type);
144  }
145 }
146 
147 void eField::typechanged(const QString &s )
148 {
149 }
150 
151 void eField::typeSelect( int idx )
152 {
153  bool w = false, d = false;
154  if ( otypes[ idx ][0] == 'N' ){
155  w = true;
156  d = true;
157 
158  } else
159  if ( otypes[ idx ][0] == 'C' ){
160  w = true;
161 
162  }
163  eWidth->setShown( w );
164  tWidth->setShown( w );
165  eDec->setShown( d );
166  tDec->setShown( d );
167 }
void setFieldType(QString n)
Definition: wfield.cpp:308
Класс реализует програмный интерфейс доступа к элемен...
Definition: acfg.h:436
Плагин – виджет предназначенный для редактирования зн...
Definition: wfield.h:63
void setEditorType(tEditorType n)
Definition: wfield.cpp:324