00001 /**************************************************************************** 00002 ** $Id: ereport.ui.h,v 1.1 2004/08/18 16:18:27 leader Exp $ 00003 ** 00004 ** Code file of the edit report 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 #include "acfg.h" 00039 00040 void eReport::init() 00041 { 00042 /* 00043 int oc, i, f, idx=0; 00044 char *id, *name, *ot; 00045 cfg_objptr o; 00046 char otype[100]; 00047 QString named; 00048 00049 otypes.clear(); 00050 eType->clear(); 00051 otypes.append("D"); 00052 eType->insertItem(trUtf8("Дата"), idx++); 00053 otypes.append("T"); 00054 eType->insertItem(trUtf8("Время"), idx++); 00055 otypes.append("N %d %d"); 00056 eType->insertItem(trUtf8("Число"), idx++); 00057 otypes.append("C %d"); 00058 eType->insertItem(trUtf8("Строка"), idx++); 00059 00060 oc=cfgobj_count(NULL, NULL); 00061 for (i=1;i<=oc;i++) { 00062 id=cfgobj_idn(NULL, NULL, i, &o); 00063 ot=(char *)o->name; 00064 name=cfgobj_attr(o, "name"); 00065 named=""; 00066 f=0; 00067 if (strcmp((char *)ot, aot_doc)==0) { 00068 named=trUtf8("Документ."); 00069 f=1; 00070 } 00071 if (strcmp((char *)ot, aot_cat)==0) { 00072 named=trUtf8("Справочник."); 00073 f=1; 00074 } 00075 if (f) { 00076 named=named+trUtf8(name); 00077 sprintf(otype, "O %s", id); 00078 otypes.append(otype); 00079 eType->insertItem(named, idx++); 00080 } 00081 } 00082 */ 00083 } 00084 00085 00086 00087 /*void eReport::setData( aCatalogue *f, QWidget *mw ) 00088 { 00089 aCfg *md = 0; 00090 if ( !f ) return; 00091 // printf("name = '%s'\n", (const char *) mw->name() ); 00092 if (mw->name() == QString("ananas-designer_mainwindow") ) { 00093 // printf("running under ananas designer\n"); 00094 CfgForm *cf = ( ( MainForm *) mw )->cfgForm(); 00095 if ( cf ) { 00096 md = &cf->cfg; 00097 // QString ts = f->getFieldType(); 00098 // char t=' '; 00099 int w=0, d=0, idx=0; 00100 unsigned int i; 00101 long oid , id; 00102 00103 id = f->getId(); 00104 00105 otypes.clear(); 00106 eType->clear(); 00107 00108 QStringList tlist = md->types( md_catalogue ); 00109 otypes.clear(); 00110 eType->clear(); 00111 for ( QStringList::Iterator it = tlist.begin(); it != tlist.end(); ++it ) { 00112 otypes.append( (*it).section( "\t", 0, 0 ) ); 00113 eType->insertItem( (*it).section("\t", 1, 1 ), idx++ ); 00114 } 00115 for ( i = 0 ; i < otypes.count(); i++ ) { 00116 oid = 0; 00117 if( otypes[i][0] == 'O' ) { 00118 sscanf( (const char *)otypes[ i ], "O %d", &oid ); 00119 if ( oid == id ) { 00120 eType->setCurrentItem( i ); 00121 break; 00122 } 00123 } 00124 } 00125 } else reject(); 00126 } 00127 00128 } 00129 */ 00130 00131 void 00132 eReport::setData( QWidget *o, aCfg *md ) 00133 { 00134 // const QObject *o = sender(); 00135 if ( o ) { 00136 if ( o->className() != QString("wReport") || !md ) { 00137 reject(); 00138 return; 00139 } 00140 } 00141 else { 00142 reject(); 00143 return; 00144 } 00145 wReport *f = ( wReport*) o; 00146 int w=0, d=0, idx=0; 00147 unsigned int i; 00148 long oid , id; 00149 00150 id = f->getId(); 00151 00152 QStringList tlist = md->types( md_journal ); 00153 otypes.clear(); 00154 eType->clear(); 00155 for ( QStringList::Iterator it = tlist.begin(); it != tlist.end(); ++it ) { 00156 otypes.append( (*it).section( "\t", 0, 0 ) ); 00157 eType->insertItem( (*it).section("\t", 1, 1 ), idx++ ); 00158 } 00159 for ( i = 0 ; i < otypes.count(); i++ ) { 00160 oid = 0; 00161 if( otypes[i][0] == 'O' ) { 00162 sscanf( (const char *)otypes[ i ], "O %d", &oid ); 00163 if ( oid == id ) { 00164 eType->setCurrentItem( i ); 00165 break; 00166 } 00167 } 00168 } 00169 } 00170 00171 00172 void eReport::getData( QWidget * o ) 00173 { 00174 00175 /* int idx=eType->currentItem(); 00176 long oid = 0; 00177 00178 if (f) { 00179 if( otypes[idx][0] == 'O' ) { 00180 sscanf( (const char *)otypes[ idx ], "O %d", &oid ); 00181 f->setId( oid ); 00182 } 00183 } 00184 */ 00185 // const QObject *o = sender(); 00186 if ( !o ) return; 00187 if ( o->className() != QString("wReport") ) return; 00188 wReport *f = ( wReport*) o; 00189 00190 int idx=eType->currentItem(); 00191 long oid = 0; 00192 00193 if (f) { 00194 if( otypes[idx][0] == 'O' ) { 00195 sscanf( (const char *)otypes[ idx ], "O %d", &oid ); 00196 f->setId( oid ); 00197 } 00198 } 00199 00200 } 00201