Ananas Library  0.9.5
catalogform.ui.h
1 /****************************************************************************
2 ** $Id: catalogform.ui.h,v 1.39 2007/05/26 19:01:10 leader Exp $
3 **
4 ** Catalogue metadata object implementation file of
5 ** Ananas application library
6 **
7 ** Created : 20031201
8 **
9 ** Copyright (C) 2003-2005 Grigory Panov <gr1313 at mail.ru>, Yoshkar-Ola.
10 **
11 ** This file is part of the Designer application 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 ** ui.h extension file, included from the uic-generated form implementation.
31 **
32 ** If you wish to add, delete or rename functions or slots use
33 ** Qt Designer which will update this file, preserving your code. Create an
34 ** init() function in place of a constructor, and a destroy() function in
35 ** place of a destructor.
36 *****************************************************************************/
37 
41 Q_ULLONG
42 CatalogForm::getId()
43 {
44  return id;
45 }
46 
54 void
55 CatalogForm::setData( aCatalogue* catalog,
56  QMap<Q_ULLONG, QListViewItem*> mg,
57  //QMap<Q_ULLONG, bool> map_d,
58  const QStringList & Fname,
59  const QStringList & FnameGroup,
60  Q_ULLONG idElForm,
61  Q_ULLONG idGrForm,
62  const bool toSelect)
63 {
64  ListView->setDestination(toSelect);
65  aLog::print(aLog::MT_DEBUG, tr("CatalogForm:setData begin"));
66  QListViewItem* item;
67  uint i;
68  QPixmap pixmap(getElementPixmap());
69  QPixmap pixmap_mark_deleted(getMarkDeletedPixmap());
70  idElementForm = idElForm;
71  idGroupForm = idGrForm;
72  cat = catalog;
73  fieldName= Fname[0];
74  fieldList= Fname;
75  fieldListGroup = FnameGroup;
76  map_gr = mg;
77  ListView->setAllColumnsShowFocus ( true );
78  QMap<Q_ULLONG, QListViewItem *>::Iterator it = map_gr.begin();
79  cat->Select();
80  // added one element in each group
81  while(it!=map_gr.end())
82  {
83  cat->selectByGroup(it.key());// select elements in each group
84  if(cat->First()) // if group have elements
85  {
86  item = new QListViewItem(map_gr[it.key()]);
87  aLog::print(aLog::MT_DEBUG, tr("CatalogForm add first element in group"));
88  //printf("add first element in group\n");
89  if(cat->isElementMarkDeleted())
90  item->setPixmap(0,pixmap_mark_deleted);
91  else
92  item->setPixmap(0,pixmap);
93  for(i=0; i<fieldList.count(); i++)
94  {
95  item->setText(i,cat->sysValue(fieldList[i]).toString());
96  }
97  map_el.insert(cat->sysValue("id").toULongLong(),item);
98  }
99  ++it;
100  }
101 
102  cat->selectByGroup(0);// select elements without group
103  if(cat->First())
104  {
105 
106  aLog::print(aLog::MT_DEBUG, tr("CatalogForm add elements into root"));
107  do
108  {
109  item = new QListViewItem(ListView);
110  if(cat->isElementMarkDeleted())
111  item->setPixmap(0,pixmap_mark_deleted);
112  else
113  item->setPixmap(0,pixmap);
114  for(i=0; i<fieldList.count(); i++)
115  {
116  item->setText(i,cat->sysValue(fieldList[i]).toString());
117  }
118  map_el.insert(cat->sysValue("id").toULongLong(),item);
119 
120  }while(cat->Next());
121  }
122  cat->Select();
123  setGeometry(aService::loadSizeFromConfig(QString("%1_embedded editor").arg(cat->md->attr(cat->obj, mda_name))));
124  ListView->setSelected(ListView->firstChild(),true);
125  aLog::print(aLog::MT_DEBUG, tr("CatalogForm init"));
126 }
127 
132 void
133 CatalogForm::setId(Q_ULLONG idx )
134 {
135  id = idx;
136 }
137 
143 void
144 CatalogForm::find(const QString& s )
145 {
146  int count=0;//,rows=0;
147  bool ok;
148  int tmp = aService::readConfigVariable("LengthAboveFind",&ok).toInt();
149  if(!ok) tmp = 3;
150  const int LENGTH_NO_FIND = tmp;
151 
152  tmp = aService::readConfigVariable("VisibleRows",&ok).toInt();
153  if(!ok) tmp = 50;
154 
155  const int VISIBLE_ROWS = tmp;
156 
157  setId(0);
158  ListHint->clear();
159  if(s.length()>=LENGTH_NO_FIND) // show list hint
160  {
161  if(!ListHint->isVisible())
162  {
163  ListHint->show(LineEdit, StatusFrame);
164  StatusFrame->show();
165  }
166 
167  cat->select(fieldName + " like '%"+s+"%'");// AND df<>'1'");
168  if(cat->First())
169  {
170  do
171  {
172  if(count++<VISIBLE_ROWS)
173  {
174  ListHint->insertItem(cat->sysValue(fieldName).toString(), cat->sysValue("id").toInt());
175  }
176  } while(cat->Next());
177  }
178  if(!ListHint->count()) // don't show empty list
179  {
180  ListHint->hide();
181  StatusFrame->hide();
182 
183  }
184  else
185  {
186  StatusFrame->repaint();
187  StatusFrame->drawText( 5, StatusFrame->size().height()-3, QString(tr("displaying %1 from %2")).arg(ListHint->count()).arg(count) );
188  }
189 
190  }
191  else // length < LENGTH_NO_FIND, don't show list hint
192  {
193  if(ListHint->isVisible())
194  {
195  ListHint->hide();
196  StatusFrame->hide();
197  }
198  }
199 
200 }
201 
205 void
206 CatalogForm::pressArrow()
207 {
208 
209  if(ListHint->isVisible())
210  {
211  ListHint->setFocus();
212  ListHint->setSelected(ListHint->currentItem(),true);
213 
214  }
215  else
216  {
217  find(LineEdit->text());
218  if(ListHint->isVisible())
219  {
220  ListHint->setFocus();
221  ListHint->setSelected(ListHint->currentItem(),true);
222  }
223 
224  }
225 }
226 
227 
228 void
229 CatalogForm::isPressArrow()
230 {
231 
232 }
233 
237 void
238 CatalogForm::init()
239 {
240 
241  ListView = new aListView(centralWidget(), "listView");
242  ListView->setGeometry(30,30,400,300);
243  ListView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
244  LineEdit = new aLineEdit(centralWidget(), "lineEdit");
245  ListHint = new aListBox(centralWidget(), "listBox");
246  StatusFrame = new QFrame(centralWidget(), "statusFrame");
247 
248  ListView->setRootIsDecorated( true );
249 
250  StatusFrame->setGeometry( QRect( 0, 0, 50,5 ) );
251  StatusFrame->setFrameShape( QFrame::StyledPanel );
252  StatusFrame->setFrameShadow( QFrame::Raised );
253  StatusFrame->hide();
254 
255  GridLayout = new QGridLayout(centralWidget(), 1, 1, 11, 6, "GridLayout");
256  GridLayout->addMultiCellWidget( ListView, 2,3, 0 , 0 );
257  GridLayout->addWidget( LineEdit, 1, 0 );
258  GridLayout->addWidget( bCancel, 3, 1 );
259  QLabel *lb = new QLabel(tr("Search"),centralWidget());
260  lb->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, lb->sizePolicy().hasHeightForWidth() ) );
261  GridLayout->addWidget( lb ,0,0);
262  QSpacerItem* spacer = new QSpacerItem( 20, 390, QSizePolicy::Minimum, QSizePolicy::Expanding );
263  GridLayout->addMultiCell( spacer, 0,2,1, 1);
264 
265  QPixmap pix= QPixmap::fromMimeSource("cat.png");
266  if(pix.isNull())
267  {
268  aLog::print(aLog::MT_INFO, tr("Catalog Form image cat.png not loaded"));
269  }
270  else
271  {
272  setIcon( pix );
273  }
274  //setFocusPolicy();
275  // connect(this, SIGNAL (destoyed()),
276 // this, SLOT (close());
277 
278  connect(ListView, SIGNAL (newItemRequest(QListViewItem*)),
279  this, SLOT (new_item(QListViewItem*)));
280 
281  connect(ListView, SIGNAL (newGroupRequest(QListViewItem*)),
282  this, SLOT (new_group(QListViewItem*)));
283 
284  connect(ListView, SIGNAL (delItemRequest(QListViewItem*)),
285  this, SLOT (del_item(QListViewItem*)));
286 
287  connect(ListView, SIGNAL (markDeletedRequest(QListViewItem*)),
288  this, SLOT (mark_deleted(QListViewItem*)));
289 
290  connect(ListView, SIGNAL (undoMarkDeletedRequest(QListViewItem*)),
291  this, SLOT (undo_mark_deleted(QListViewItem*)));
292 
293  connect(ListView, SIGNAL (editRequest(QListViewItem*, int)),
294  this, SLOT (edit(QListViewItem*, int)));
295 
296  connect(ListView, SIGNAL (selectRequest(QListViewItem*)),
297  this, SLOT (select(QListViewItem*)));
298 
299  connect(LineEdit, SIGNAL (delayTextChanged(const QString&)),
300  this, SLOT (find(const QString&)));
301 
302  connect(LineEdit, SIGNAL (keyArrowPressed()),
303  this, SLOT (pressArrow()));
304 
305  connect(LineEdit, SIGNAL (keyEnterPressed()),
306  this, SLOT (go()));
307 
308  connect(ListView, SIGNAL (expanded ( QListViewItem *)),
309  this, SLOT (onLoadElements( QListViewItem *)));
310 
311  connect(ListHint, SIGNAL (lostFocus()),
312  LineEdit, SLOT (setFocus()));
313 
314  connect(ListHint, SIGNAL (lostFocus()),
315  StatusFrame, SLOT (hide()));
316 
317  connect(ListHint, SIGNAL (lostFocus()),
318  ListHint, SLOT (hide()));
319 
320  connect(ListHint, SIGNAL (keyArrowLRPressed()),
321  LineEdit, SLOT (setFocus()));
322 
323  connect(ListHint, SIGNAL (keyArrowLRPressed(const QString&)),
324  this, SLOT (setText(const QString&)));
325 
326  connect(ListHint, SIGNAL (keyEnterPressed()),
327  this, SLOT (go()));
328 
329  connect(ListHint, SIGNAL (sendMessage(const QString &)),
330  this->statusBar(), SLOT (message( const QString &)));
331 
332  connect(ListView, SIGNAL (sendMessage(const QString &)),
333  this->statusBar(), SLOT (message( const QString &)));
334 
335  connect(LineEdit, SIGNAL (sendMessage(const QString &)),
336  this->statusBar(), SLOT (message( const QString &)));
337 
338  LineEdit->setFocus();
339 }
340 
344 void
345 CatalogForm::destroy()
346 {
347  aService::saveSize2Config(this->rect(),QString("%1_embedded editor").arg(cat->md->attr(cat->obj, mda_name)));
348  delete cat;
349  cat = 0;
350 }
351 
355 void
356 CatalogForm::setText( const QString & s )
357 {
358  LineEdit->blockSignals ( true );
359  LineEdit->setText ( s );
360  setId(ListHint->getId(ListHint->currentItem()));
361  LineEdit->blockSignals ( false );
362 }
363 
367 void
368 CatalogForm::go()
369 {
370  Q_ULLONG ide=getId(), idg;
371  if(!getId())
372  {
373  ide = findFirst(LineEdit->text());
374  setId(ide);
375  }
376  idg = getIdg(ide);
377  loadElements(idg);
378  if(map_el.contains(getId()))
379  {
380  goToItem(map_el[getId()]);
381  }
382 
383 }
387 void
388 CatalogForm::goToItem( QListViewItem *item)
389 {
390  ListView->setSelected(item, true);
391  ListView->ensureItemVisible(item);
392  ListView->setFocus();
393 }
394 
400 long
401 CatalogForm::findFirst( const QString &s )
402 {
403  Q_ULLONG res=0;
404  cat->select(fieldName + " like '%"+s+"%'");// AND df<>'1'");
405  //Cat->Select();
406  if(cat->First())
407  {
408  res = cat->sysValue("id").toULongLong();
409 
410  }
411  return res;
412 }
413 
418 void
419 CatalogForm::loadElements( Q_ULLONG idGroup )
420 {
421  QListViewItem * item;
422  QListViewItem * p_item;
423  uint i;
424 // printf("load elements\n");
425 // printf("sel by group id = %lu\n",idGroup);
426  QPixmap pixmap(getElementPixmap());
427  QPixmap pixmap_mark_deleted(getMarkDeletedPixmap());
428  cat->selectByGroup(idGroup);
429 // printf("_sel by group\n");
430  if(cat->First())
431  {
432  do
433  {
434  //count++;
435  if(map_gr.contains(idGroup)
436  && !map_el.contains(cat->sysValue("id").toULongLong()))
437  {
438  p_item = map_gr[idGroup];
439  item = new QListViewItem(p_item);
440  if(cat->isElementMarkDeleted())
441  item->setPixmap(0,pixmap_mark_deleted);
442  else
443  item->setPixmap(0,pixmap);
444  for(i=0; i<fieldList.count(); i++)
445  {
446  // printf("i = %d\n",i);
447  item->setText(i,cat->sysValue(fieldList[i]).toString());
448  }
449  map_el.insert(cat->sysValue("id").toULongLong(),item);
450  }
451  }while(cat->Next());
452  }
453 // printf("end load\n");
454 }
455 
460 void
461 CatalogForm::onLoadElements( QListViewItem *item )
462 {
463  QValueList<QListViewItem*> lst = map_gr.values();
464  int ind = lst.findIndex(item);
465  Q_ULLONG key;
466  if(ind!=-1)
467  {
468  QValueList<Q_ULLONG> listKey = map_gr.keys();
469  key = listKey[ind];
470  loadElements(key);
471  }
472 }
473 
479 Q_ULLONG
480 CatalogForm::getIdg( Q_ULLONG ide )
481 {
482  return cat->idGroupByElement(ide);
483 }
484 
485 
490 void
491 CatalogForm::new_item( QListViewItem * parentItem )
492 {
493  if(!parentItem)
494  {
495  //cat->groupSelect(0);
496  cat->newElement(0);
497  //printf("id = %llu\n",id);
498  QListViewItem* item = new QListViewItem(ListView);
499  QPixmap pixmap(getElementPixmap());
500  item->setPixmap(0,pixmap);
501  map_el.insert(cat->sysValue("id").toULongLong(),item);
502  edit(item,true);
503  ListView->ensureItemVisible(item);
504  // cfg_message(0,tr("Can't added element"));
505  return;
506  }
507  Q_ULLONG id = getGroupId(parentItem);
508  QPixmap pixmap(getElementPixmap());
509  if(id) // parent item is group
510  {
511  cat->groupSelect(id);
512  if(!cat->isGroupMarkDeleted())
513  {
514  cat->newElement(id);
515  QListViewItem* item = new QListViewItem(map_gr[id]);
516  item->setPixmap(0,pixmap);
517  map_el.insert(cat->sysValue("id").toULongLong(),item);
518  edit(item,true);
519  ListView->ensureItemVisible(item);
520  //ListView->setFocus();
521  }
522  else cfg_message(0,tr("Can't added new element to mark deleted group"));
523  }
524  else
525  {
526  new_item(parentItem->parent());
527  }//cfg_message(0,tr("Can't added element to element"));
528 }
529 
534 long
535 CatalogForm::getGroupId( QListViewItem * item )
536 {
537  QValueList<QListViewItem*> lst = map_gr.values();
538  int ind = lst.findIndex(item);
539  Q_ULLONG key=0;
540  if(ind!=-1)
541  {
542  QValueList<Q_ULLONG> listKey = map_gr.keys();
543  key = listKey[ind];
544  }
545 return key;
546 }
547 
552 void
553 CatalogForm::new_group( QListViewItem * parentItem )
554 {
555  Q_ULLONG id = getGroupId(parentItem);
556  QListViewItem * item;
557  QPixmap pixmap(getGroupPixmap());
558  //cat->groupSelect( id );
559  if(!id)
560  {
561  id = getElementId(parentItem);
562  if(id)
563  {
564  cfg_message(0,tr("Can't added group to element"));
565  return;
566  }
567  else
568  {
569 // printf(">>>>id=0\n");
570  cat->newGroup(id);
571  item = new QListViewItem(ListView);
572  ListView->insertItem(item);
573  }
574  }
575  else
576  {
577  //cat->groupSelect(id);
578  if(cat->isGroupMarkDeleted())
579  {
580  cfg_message(0,tr("Can't added group to mark deleted group"));
581  return;
582  }
583  cat->newGroup(id);
584  item = new QListViewItem(map_gr[id]);
585  }
586  //item->setText(0,cat->GroupSysValue(fieldListGroup[0]).toString());
587  item->setPixmap(0,pixmap);
588  map_gr.insert(cat->GroupSysValue("id").toULongLong(),item);
589  edit(item,true);
590  ListView->ensureItemVisible(item);
591  ListView->setCurrentItem(item);
592  ListView->setSelected(item,true);
593  //ListView->setFocus();
594 
595 }
596 
601 QPixmap
602 CatalogForm::getGroupPixmap()
603 {
604  QPixmap pixmap = QPixmap::fromMimeSource("group2.png");
605 // pixmap.detach();
606  if(pixmap.isNull())
607  {
608  aLog::print(aLog::MT_INFO, tr("Catalog Form group pixmap not load"));
609  }
610 return pixmap;
611 }
612 
613 
618 QPixmap
619 CatalogForm::getElementPixmap()
620 {
621  QPixmap pixmap= QPixmap::fromMimeSource("field2.png");
622  if(pixmap.isNull())
623  {
624  aLog::print(aLog::MT_INFO, tr("Catalog Form element pixmap not load"));
625  }
626 return pixmap;
627 }
628 
633 QPixmap
634 CatalogForm::getMarkDeletedPixmap()
635 {
636  QPixmap pixmap = QPixmap::fromMimeSource("editdelete2.png");
637 // pixmap.
638  if(pixmap.isNull())
639  {
640  aLog::print(aLog::MT_INFO, tr("Catalog Form mark deleted group pixmap not load"));
641  }
642 return pixmap;
643 }
648 void CatalogForm::del_item( QListViewItem * item )
649 {
650  // cat->groupSelect(getGroupId(item));
651  Q_ULLONG id = getElementId(item);
652  if(id)
653  {
654  cat->select(id);
655  if(cat->First())
656  {
657  cat->delElement();
658  map_el.remove(id);
659  delete item;
660  item = 0;
661  }
662  }
663  else
664  {
665  id = getGroupId(item);
666  if(id)
667  {
668  QValueList<Q_ULLONG> listDeletedId;
669  cat->delGroup(id, listDeletedId);
670  QValueList<Q_ULLONG>::iterator it = listDeletedId.begin();
671  while(it!= listDeletedId.end())
672  {
673  if(map_el.contains(*it)) map_el.remove(*it);
674  else if(map_gr.contains(*it)) map_gr.remove(*it);
675  ++it;
676  }
677  delete item; // destructor delete all subitems
678  item = 0;
679  }
680  }
681 }
682 
688 void CatalogForm::mark_deleted( QListViewItem * item )
689 {
690  Q_ULLONG id = getElementId(item);
691  if(id)
692  {
693  cat->select(id);
694 // cat->setSelected(true);
695  if(cat->First())
696  {
697  cat->setMarkDeletedElement(id,true);
698  item->setPixmap(0,getMarkDeletedPixmap());
699  }
700  }
701  else
702  {
703  id = getGroupId(item);
704  if(id)
705  {
706  loadElements(id); // populate items in group
707  QValueList<Q_ULLONG> listDeletedId;
708  cat->getMarkDeletedList(id,listDeletedId);
709  QValueList<Q_ULLONG>::iterator it = listDeletedId.begin();
710  while(it != listDeletedId.end()) //first delete elements in this group
711  {
712  if(map_el.contains(*it))
713  {
714  map_el[*it]->setPixmap(0, getMarkDeletedPixmap());
715  cat->setMarkDeletedElement(*it,true);
716  it = listDeletedId.remove(it);
717  }
718  else
719  {
720  ++it;
721  }
722  }
723  it = listDeletedId.begin();
724  while(it != listDeletedId.end()) //second delete groups
725  {
726  if(map_gr.contains(*it))
727  {
728  map_gr[*it]->setPixmap(0, getMarkDeletedPixmap());
729  cat->setMarkDeletedGroup(*it,true);
730  it = listDeletedId.remove(it);
731  //map_el[*it]->invalidateHeight();// setHeight(10);
732  }
733  else
734  {
735  ++it;
736  }
737  }
738  }
739  }
740 }
741 
746 void CatalogForm::undo_mark_deleted( QListViewItem * item )
747 {
748  Q_ULLONG id = getElementId(item);
749  if(id)
750  {
751  cat->select(id);
752  if(cat->First())
753  {
754  cat->setMarkDeletedElement(id,false);
755  item->setPixmap(0,getElementPixmap());
756  }
757  }
758  else
759  {
760  id = getGroupId(item);
761  if(id)
762  {
763  // cat->select(QString("id=%1").arg(id),md_group);
764  //if(cat->FirstInGroupTable())
765  QValueList<Q_ULLONG> listDeletedId;
766  // cat->setMarkDeletedGroup(id, listDeletedId,false);
767  cat->getMarkDeletedList(id, listDeletedId);
768  QValueList<Q_ULLONG>::iterator it = listDeletedId.begin();
769  while(it != listDeletedId.end()) //first delete elements in this group
770  {
771  if(map_el.contains(*it))
772  {
773  map_el[*it]->setPixmap(0, getElementPixmap());
774  cat->setMarkDeletedElement(*it,false);
775  it = listDeletedId.remove(it);
776  }
777  else
778  {
779  ++it;
780  }
781  }
782  it = listDeletedId.begin();
783  while(it != listDeletedId.end()) //second delete groups
784  {
785  if(map_gr.contains(*it))
786  {
787  map_gr[*it]->setPixmap(0, getGroupPixmap());
788  cat->setMarkDeletedGroup(*it,false);
789  it = listDeletedId.remove(it);
790  //map_el[*it]->invalidateHeight();// setHeight(10);
791  }
792  else
793  {
794  ++it;
795  }
796  }
797  }
798  }
799 }
800 
801 void CatalogForm::edit( QListViewItem * item, int)
802 {
803  edit( item, false);
804 }
805 
806 void CatalogForm::edit( QListViewItem * item, bool afterNew)
807 {
808 // QWidget *wd = topLevelWidget();
809  aLog::print(aLog::MT_DEBUG, tr("Catalog Form edit element start"));
810  MainForm * mw = (MainForm*) topLevelWidget();
811  if(mw)
812  {
813  Q_ULLONG id = getElementId(item);
814  if(id)
815  {
816  aLog::print(aLog::MT_DEBUG, tr("Catalog Form edit element with id=%1").arg(id));
817  cat->select(id);
818  if(idElementForm)
819  {
820  if(!cat->isElementMarkDeleted())
821  {
822  aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idElementForm);
823  if(editForm)
824  {
825  if(afterNew) editForm->setMode(0);
826  else editForm->setMode(1);
827  editForm->Select(id);
828  connect(editForm, SIGNAL(closeForm(Q_ULLONG)), this, SLOT(Refresh(Q_ULLONG)));
829  editForm->show();
830  }
831  else
832  {
833  aLog::print(aLog::MT_ERROR, tr("Catalog Form edit element form is null"));
834  }
835  }
836  else cfg_message(0, tr("Can't edit mark deleted element"));
837  }
838  else cfg_message(1,tr("Catalog haven't edit element form"));
839  }
840  else
841  {
842  id = getGroupId(item);
843  aLog::print(aLog::MT_DEBUG, tr("Catalog Form edit group with id = %1").arg(id));
844  if(id)
845  {
846 
847  cat->groupSelect(id);
848  if(idGroupForm)
849  {
850  if(!cat->isGroupMarkDeleted())
851  {
852  aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idGroupForm);
853  if(editForm)
854  {
855  if(afterNew) editForm->setMode(0);
856  else editForm->setMode(1);
857 
858  editForm->SelectGroup(id);
859  connect(editForm, SIGNAL(closeForm(Q_ULLONG)), this, SLOT(Refresh(Q_ULLONG)));
860  editForm->show();
861  }
862  else
863  {
864  aLog::print(aLog::MT_ERROR, tr("Catalog Form edit group form is null"));
865  }
866  }
867  else cfg_message(0, tr("Can't edit mark deleted group"));
868  }
869  else cfg_message(1,tr("Catalog haven't edit group form"));
870  }
871  }
872  }
873  else
874  {
875  aLog::print(aLog::MT_ERROR, tr("Catalog Form main widget is not 'MainForm'"));
876  }
877 
878 }
879 
884 void CatalogForm::select( QListViewItem * item )
885 {
886  Q_ULLONG res = getGroupId(item);
887  if(!res)
888  {
889  res = getElementId(item);
890  cat->select(res);
891  if(!cat->isElementMarkDeleted())
892  {
893  setId(res);
894  doOk();
895  }
896  }
897  else
898  {
899  cat->groupSelect(res);
900  if(!cat->isGroupMarkDeleted())
901  {
902  setId(res);
903  doOk();
904  }
905  }
906  emit(selected(res));
907 // return res;
908 }
909 
914 Q_ULLONG CatalogForm::getElementId( QListViewItem * item )
915 {
916  QValueList<QListViewItem*> lst = map_el.values();
917  int ind = lst.findIndex(item);
918  Q_ULLONG key=0;
919  if(ind!=-1)
920  {
921  QValueList<Q_ULLONG> listKey = map_el.keys();
922  key = listKey[ind];
923  }
924 return key;
925 }
926 
927 
928 void CatalogForm::doOk()
929 {
930  close();
931 }
932 
933 
934 
935 void CatalogForm::keyPressEvent( QKeyEvent * e )
936 {
937  if ( e->key()==Qt::Key_Return)
938  {
939  }
940  if ( e->key()==Qt::Key_Escape)
941  {
942  close();
943  }
944  e->ignore();
945 }
946 
947 
948 void CatalogForm::Refresh( Q_ULLONG id )
949 {
950  QListViewItem * item;
951  if( map_el.contains( id ))
952  {
953  item = map_el[id];
954  cat->select( id );
955  for(uint i=0; i<fieldList.count(); i++)
956  {
957 
958  item->setText(i,cat->sysValue(fieldList[i]).toString());
959  ListView->setFocus();
960  }
961  }
962  else
963  {
964  if( map_gr.contains( id ) )
965  {
966  item = map_gr[id];
967  cat->groupSelect( id );
968  item->setText(0,cat->GroupSysValue(fieldListGroup[0]).toString());
969  ListView->setFocus();
970  }
971  }
972 }
973 
974 
975 
976 
977 
static QString readConfigVariable(const QString &name, bool *ok)
Definition: aservice.cpp:448
static void saveSize2Config(QRect size, const QString &mdname)
Definition: aservice.cpp:389
int Select(Q_ULLONG id)
Definition: aform.cpp:1656
static void print(int status, const QString &text)
Definition: alog.cpp:58
Класс aCatalogue определяет программный интерфейс иерархич...
Definition: acatalogue.h:54
virtual int Select(bool grouponly=false)
Делает один (первый) элемент справочника текущим.
Definition: acatalogue.cpp:327
void setMode(int m)
ScriptAPI. Устанавливает режим формы.
Definition: aform.cpp:2026
Definition: catalogformwidgets.h:44
Определяет программный интерфейс экранных форм Ананас...
Definition: aform.h:75
void show()
Deprecated. See Show()
Definition: aform.cpp:449
static QRect loadSizeFromConfig(const QString &mdname)
Definition: aservice.cpp:419
Definition: catalogformwidgets.h:106
Definition: mainform.h:30
Definition: catalogformwidgets.h:79