00001 /**************************************************************************** 00002 ** $Id: edocument.ui.h,v 1.7 2004/07/01 11:30:55 pashik Exp $ 00003 ** 00004 ** Code file of the edit document plugin of Ananas 00005 ** Designer and Engine applications 00006 ** 00007 ** Created : 20031201 00008 ** 00009 ** Copyright (C) 2003-2004 Leader InfoTech. All rights reserved. 00010 ** 00011 ** This file is part of the Ananas Plugins of the Ananas 00012 ** automation accounting system. 00013 ** 00014 ** This file may be distributed and/or modified under the terms of the 00015 ** GNU General Public License version 2 as published by the Free Software 00016 ** Foundation and appearing in the file LICENSE.GPL included in the 00017 ** packaging of this file. 00018 ** 00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00021 ** 00022 ** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru 00023 ** See http://www.leaderit.ru/gpl/ for GPL licensing information. 00024 ** 00025 ** Contact org@leaderit.ru if any conditions of this licensing are 00026 ** not clear to you. 00027 ** 00028 **********************************************************************/ 00029 00030 /**************************************************************************** 00031 ** ui.h extension file, included from the uic-generated form implementation. 00032 ** 00033 ** If you wish to add, delete or rename functions or slots use 00034 ** Qt Designer which will update this file, preserving your code. Create an 00035 ** init() function in place of a constructor, and a destroy() function in 00036 ** place of a destructor. 00037 *****************************************************************************/ 00038 //nclude "mainform.h" 00039 //#include "cfgform.h" 00040 #include "acfg.h" 00041 00042 void eDocument::init() 00043 { 00044 /* 00045 int oc, i, f, idx=0; 00046 char *id, *name, *ot; 00047 cfg_objptr o; 00048 char otype[100]; 00049 QString named; 00050 00051 otypes.clear(); 00052 eType->clear(); 00053 otypes.append("D"); 00054 eType->insertItem(trUtf8("Дата"), idx++); 00055 otypes.append("T"); 00056 eType->insertItem(trUtf8("Время"), idx++); 00057 otypes.append("N %d %d"); 00058 eType->insertItem(trUtf8("Число"), idx++); 00059 otypes.append("C %d"); 00060 eType->insertItem(trUtf8("Строка"), idx++); 00061 00062 oc=cfgobj_count(NULL, NULL); 00063 for (i=1;i<=oc;i++) { 00064 id=cfgobj_idn(NULL, NULL, i, &o); 00065 ot=(char *)o->name; 00066 name=cfgobj_attr(o, "name"); 00067 named=""; 00068 f=0; 00069 if (strcmp((char *)ot, aot_doc)==0) { 00070 named=trUtf8("Документ."); 00071 f=1; 00072 } 00073 if (strcmp((char *)ot, aot_cat)==0) { 00074 named=trUtf8("Справочник."); 00075 f=1; 00076 } 00077 if (f) { 00078 named=named+trUtf8(name); 00079 sprintf(otype, "O %s", id); 00080 otypes.append(otype); 00081 eType->insertItem(named, idx++); 00082 } 00083 } 00084 */ 00085 } 00086 00087 00088 00089 void eDocument::setData( QWidget *o, aCfg *md ) 00090 { 00091 // const QObject *o = sender(); 00092 if ( o ) { 00093 if ( o->className() != QString("wDocument") || !md ) { 00094 reject(); 00095 return; 00096 } 00097 } 00098 else { 00099 reject(); 00100 return; 00101 } 00102 wDocument *f = ( wDocument*) o; 00103 int w=0, d=0, idx=0; 00104 unsigned int i; 00105 long oid , id; 00106 00107 id = f->getId(); 00108 00109 otypes.clear(); 00110 eType->clear(); 00111 00112 QStringList tlist = md->types( md_document ); 00113 otypes.clear(); 00114 eType->clear(); 00115 for ( QStringList::Iterator it = tlist.begin(); it != tlist.end(); ++it ) { 00116 otypes.append( (*it).section( "\t", 0, 0 ) ); 00117 eType->insertItem( (*it).section("\t", 1, 1 ), idx++ ); 00118 } 00119 for ( i = 0 ; i < otypes.count(); i++ ) { 00120 oid = 0; 00121 if( otypes[i][0] == 'O' ) { 00122 sscanf( (const char *)otypes[ i ], "O %d", &oid ); 00123 if ( oid == id ) { 00124 eType->setCurrentItem( i ); 00125 break; 00126 } 00127 } 00128 } 00129 } 00130 00131 00132 void eDocument::getData( QWidget *o ) 00133 //aDocument *f ) 00134 { 00135 QVariant v; 00136 // const QObject *o = sender(); 00137 if ( !o ) return; 00138 if ( o->className() != QString("wDocument") ) return; 00139 wDocument *f = ( wDocument*) o; 00140 00141 int idx=eType->currentItem(); 00142 int oid = 0; 00143 00144 if (f) { 00145 if( otypes[idx][0] == 'O' ) { 00146 sscanf( (const char *)otypes[ idx ], "O %d", &oid ); 00147 // v = oid; 00148 f->setProperty("Id", QVariant( oid ) ); 00149 // f->setId( oid ); 00150 } 00151 } 00152 00153 } 00154