00001 /**************************************************************************** 00002 ** $Id: etable.ui.h,v 1.4 2004/07/01 11:30:55 pashik Exp $ 00003 ** 00004 ** Code file of the select files 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 "ananas.h" 00039 #include "wtable.h" 00040 00041 void eTable::init() 00042 { 00043 /* 00044 int oc, i, f, idx=0; 00045 char *id, *name, *ot; 00046 cfg_objptr o; 00047 char otype[100]; 00048 QString named; 00049 00050 CHECK_POINT 00051 r = tablerow_new(0); 00052 00053 otypes.clear(); 00054 eType->clear(); 00055 otypes.append("U"); 00056 eType->insertItem(trUtf8("Текстовая метка"), idx++); 00057 otypes.append("D"); 00058 eType->insertItem(trUtf8("Дата"), idx++); 00059 otypes.append("T"); 00060 eType->insertItem(trUtf8("Время"), idx++); 00061 otypes.append("N %d %d"); 00062 eType->insertItem(trUtf8("Число"), idx++); 00063 otypes.append("C %d"); 00064 eType->insertItem(trUtf8("Строка"), idx++); 00065 00066 oc=cfgobj_count(NULL, NULL); 00067 for (i=1;i<=oc;i++) { 00068 id=cfgobj_idn(NULL, NULL, i, &o); 00069 ot=(char *)o->name; 00070 name=cfgobj_attr(o, "name"); 00071 named=""; 00072 f=0; 00073 if (strcmp((char *)ot, aot_doc)==0) { 00074 named=trUtf8("Документ."); 00075 f=1; 00076 } 00077 if (strcmp((char *)ot, aot_cat)==0) { 00078 named=trUtf8("Справочник."); 00079 f=1; 00080 } 00081 if (f) { 00082 named=named+trUtf8(name); 00083 sprintf(otype, "O %s", id); 00084 otypes.append(otype); 00085 eType->insertItem(named, idx++); 00086 } 00087 } 00088 CHECK_POINT 00089 */ 00090 } 00091 00092 00093 void 00094 eTable::destroy() 00095 { 00096 // tablerow_free( r ); 00097 } 00098 00099 00100 00101 void eTable::insertColumn(const char *Header, const char *Name, 00102 int idxt, int cw, int tw, int td) 00103 { 00104 /* 00105 tablefield *f; 00106 char s[30]; 00107 00108 sprintf(s, "%s %i %i", (const char *)otypes[idxt], tw, td); 00109 00110 f = tablefield_newsys(Name, s, ""); 00111 tablefield_setheader(f, Header); 00112 f->sizex = cw; 00113 f->flen = tw; 00114 f->decimals = td; 00115 f->ftypeindex = idxt; 00116 tablerow_insertcolumn(r, f, -1); 00117 00118 // blockSignals( true ); 00119 ListCol->insertItem(trUtf8(Header)); 00120 // eColHeader->setText( trUtf8(Header)); 00121 // eColName->setText(trUtf8(Name)); 00122 // eColWidth->setValue(cw); 00123 // eColTWidth->setValue(tw); 00124 // eColTDec->setValue(td); 00125 // blockSignals( false ); 00126 if (ListCol->count()) ListCol->setCurrentItem(ListCol->count()-1); 00127 */ 00128 } 00129 00130 00131 00132 void eTable::ColumnAdd() 00133 { 00134 // insertColumn("Новый", "Новый", 0, 0, 0, 0); 00135 } 00136 00137 00138 void eTable::ColumnDel() 00139 { 00140 /* 00141 int idx; 00142 idx = ListCol->currentItem(); 00143 if (ListCol->count() && idx != -1) { 00144 tablerow_removecolumn( r, idx ); 00145 ListCol->removeItem(idx); 00146 } 00147 */ 00148 } 00149 00150 00151 void eTable::ColumnL() 00152 { 00153 00154 } 00155 00156 00157 void eTable::ColumnR() 00158 { 00159 00160 } 00161 00162 00163 void eTable::ColumnSel(int col) 00164 { 00165 /* 00166 tablefield *f; 00167 00168 if (col >= 0 && col < tablerow_columns( r )) { 00169 f = tablerow_column( r, col ); 00170 blockSignals( true ); 00171 eColHeader->setText(trUtf8(tablefield_header( f ))); 00172 eColWidth->setValue(f->sizex); 00173 eType->setCurrentItem(f->ftypeindex); 00174 eColName->setText(trUtf8(f->name)); 00175 eColTWidth->setValue(f->flen); 00176 eColTDec->setValue(f->decimals); 00177 blockSignals( false ); 00178 } 00179 */ 00180 } 00181 00182 00183 void eTable::ColumnUpd() 00184 { 00185 /* 00186 tablefield *f; 00187 00188 if (signalsBlocked()) return; 00189 int idx = ListCol->currentItem(); 00190 00191 if ( idx >= 0 && idx < tablerow_columns( r )) { 00192 f = tablerow_column( r, idx ); 00193 if (f->name) free(f->name); 00194 f->name=strdup((const char *) eColName->text().utf8()); 00195 tablefield_setheader( f, (const char *) eColHeader->text().utf8()); 00196 f->sizex = eColWidth->value(); 00197 f->flen = eColTWidth->value(); 00198 f->decimals = eColTDec->value(); 00199 f->ftypeindex = eType->currentItem(); 00200 00201 printf("set w=%i l=%i d=%i ti=%i\n", f->sizex, f->flen, 00202 f->decimals, f->ftypeindex); 00203 ListCol->blockSignals( TRUE ); 00204 ListCol->changeItem(eColHeader->text(), idx); 00205 ListCol->blockSignals( FALSE ); 00206 } 00207 CHECK_POINT 00208 */ 00209 } 00210 00211 00212 void eTable::setData( QWidget *o, aCfg *md ) 00213 { 00214 00215 QStringList sl; 00216 unsigned int i; 00217 QString ft,h,n; 00218 int w=0, l=0, d=0, idxt=0; 00219 char st[20]; 00220 00221 wTable *t = (wTable *) o; 00222 eTabName->setText(t->getName()); 00223 /* 00224 if (!t->getDefineCols().isEmpty()) { 00225 sl = QStringList::split("\n",t->getDefineCols()); 00226 for (i = 0; i < sl.count(); i++) { 00227 sscanf((const char *)sl[i].section("|",3,3),"%s %d %d", st, &l, &d); 00228 if (st[0]=='O') ft.sprintf("O %d",l); 00229 else ft=st; 00230 w = sl[i].section("|",2,2).toInt(); 00231 h = sl[i].section("|",5,5); 00232 n = sl[i].section("|",4,4); 00233 for (idxt = otypes.count()-1; idxt>0; idxt--) { 00234 if (ft[0]=='O' && otypes[idxt]==ft) break; 00235 else if (otypes[idxt][0]==ft[0]) break; 00236 } 00237 printf("set data %i = %s %s %i %i %i\n", i, 00238 (const char *)h, (const char *)n, idxt, w, l); 00239 insertColumn(h,n,idxt,w,l,d); 00240 } 00241 } 00242 */ 00243 } 00244 00245 00246 void eTable::getData( QWidget *o ) 00247 { 00248 wTable *t = (wTable *) o; 00249 /* 00250 int i; 00251 QStringList sl; 00252 QString cdef, ft, s; 00253 tablefield *f; 00254 00255 t->vTable->setNumCols(ListCol->count()); 00256 for (i=0;i<tablerow_columns( r ); i++) { 00257 f = tablerow_column( r, i ); 00258 ft.sprintf(otypes[f->ftypeindex],f->flen,f->decimals); 00259 cdef.sprintf("%i|%i|%i|%s|%s|%s",i,0, f->sizex, 00260 (const char *) ft, f->name, 00261 tablefield_header( f )); 00262 s = s + cdef +"\n"; 00263 } 00264 // t->vTable->setColumnLabels(sl); 00265 t->setName(eTabName->text()); 00266 CHECK_POINT 00267 printf("getData defs = %s\n",(const char *)s.utf8()); 00268 t->setDefineCols(s); 00269 */ 00270 t->setName(eTabName->text()); 00271 } 00272 00273 00274 void eTable::ColumnTextUpd( const QString &s ) 00275 { 00276 /* 00277 int idx; 00278 idx = ListCol->currentItem(); 00279 if (idx == -1) return; 00280 ListCol->blockSignals( TRUE ); 00281 ListCol->changeItem(s, ListCol->currentItem()); 00282 ListCol->blockSignals( FALSE ); 00283 CHECK_POINT 00284 */ 00285 } 00286 00287