00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00041 Q_ULLONG
00042 CatalogForm::getId()
00043 {
00044 return id;
00045 }
00046
00054 void
00055 CatalogForm::setData( aCatalogue* catalog,
00056 QMap<Q_ULLONG, QListViewItem*> mg,
00057
00058 const QStringList & Fname,
00059 const QStringList & FnameGroup,
00060 Q_ULLONG idElForm,
00061 Q_ULLONG idGrForm,
00062 const bool toSelect)
00063 {
00064 ListView->setDestination(toSelect);
00065 aLog::print(aLog::MT_DEBUG, tr("CatalogForm:setData begin"));
00066 QListViewItem* item;
00067 uint i;
00068 QPixmap pixmap(getElementPixmap());
00069 QPixmap pixmap_mark_deleted(getMarkDeletedPixmap());
00070 idElementForm = idElForm;
00071 idGroupForm = idGrForm;
00072 cat = catalog;
00073 fieldName= Fname[0];
00074 fieldList= Fname;
00075 fieldListGroup = FnameGroup;
00076 map_gr = mg;
00077 ListView->setAllColumnsShowFocus ( true );
00078 QMap<Q_ULLONG, QListViewItem *>::Iterator it = map_gr.begin();
00079 cat->Select();
00080
00081 while(it!=map_gr.end())
00082 {
00083 cat->selectByGroup(it.key());
00084 if(cat->First())
00085 {
00086 item = new QListViewItem(map_gr[it.key()]);
00087 aLog::print(aLog::MT_DEBUG, tr("CatalogForm add first element in group"));
00088
00089 if(cat->isElementMarkDeleted())
00090 item->setPixmap(0,pixmap_mark_deleted);
00091 else
00092 item->setPixmap(0,pixmap);
00093 for(i=0; i<fieldList.count(); i++)
00094 {
00095 item->setText(i,cat->sysValue(fieldList[i]).toString());
00096 }
00097 map_el.insert(cat->sysValue("id").toULongLong(),item);
00098 }
00099 ++it;
00100 }
00101
00102 cat->selectByGroup(0);
00103 if(cat->First())
00104 {
00105
00106 aLog::print(aLog::MT_DEBUG, tr("CatalogForm add elements into root"));
00107 do
00108 {
00109 item = new QListViewItem(ListView);
00110 if(cat->isElementMarkDeleted())
00111 item->setPixmap(0,pixmap_mark_deleted);
00112 else
00113 item->setPixmap(0,pixmap);
00114 for(i=0; i<fieldList.count(); i++)
00115 {
00116 item->setText(i,cat->sysValue(fieldList[i]).toString());
00117 }
00118 map_el.insert(cat->sysValue("id").toULongLong(),item);
00119
00120 }while(cat->Next());
00121 }
00122 cat->Select();
00123 setGeometry(aService::loadSizeFromConfig(QString("%1_embedded editor").arg(cat->md->attr(cat->obj, mda_name))));
00124 ListView->setSelected(ListView->firstChild(),true);
00125 aLog::print(aLog::MT_DEBUG, tr("CatalogForm init"));
00126 }
00127
00132 void
00133 CatalogForm::setId(Q_ULLONG idx )
00134 {
00135 id = idx;
00136 }
00137
00143 void
00144 CatalogForm::find(const QString& s )
00145 {
00146 int count=0;
00147 bool ok;
00148 int tmp = aService::readConfigVariable("LengthAboveFind",&ok).toInt();
00149 if(!ok) tmp = 3;
00150 const int LENGTH_NO_FIND = tmp;
00151
00152 tmp = aService::readConfigVariable("VisibleRows",&ok).toInt();
00153 if(!ok) tmp = 50;
00154
00155 const int VISIBLE_ROWS = tmp;
00156
00157 setId(0);
00158 ListHint->clear();
00159 if(s.length()>=LENGTH_NO_FIND)
00160 {
00161 if(!ListHint->isVisible())
00162 {
00163 ListHint->show(LineEdit, StatusFrame);
00164 StatusFrame->show();
00165 }
00166
00167 cat->select(fieldName + " like '%"+s+"%'");
00168 if(cat->First())
00169 {
00170 do
00171 {
00172 if(count++<VISIBLE_ROWS)
00173 {
00174 ListHint->insertItem(cat->sysValue(fieldName).toString(), cat->sysValue("id").toInt());
00175 }
00176 } while(cat->Next());
00177 }
00178 if(!ListHint->count())
00179 {
00180 ListHint->hide();
00181 StatusFrame->hide();
00182
00183 }
00184 else
00185 {
00186 StatusFrame->repaint();
00187 StatusFrame->drawText( 5, StatusFrame->size().height()-3, QString(tr("displaying %1 from %2")).arg(ListHint->count()).arg(count) );
00188 }
00189
00190 }
00191 else
00192 {
00193 if(ListHint->isVisible())
00194 {
00195 ListHint->hide();
00196 StatusFrame->hide();
00197 }
00198 }
00199
00200 }
00201
00205 void
00206 CatalogForm::pressArrow()
00207 {
00208
00209 if(ListHint->isVisible())
00210 {
00211 ListHint->setFocus();
00212 ListHint->setSelected(ListHint->currentItem(),true);
00213
00214 }
00215 else
00216 {
00217 find(LineEdit->text());
00218 if(ListHint->isVisible())
00219 {
00220 ListHint->setFocus();
00221 ListHint->setSelected(ListHint->currentItem(),true);
00222 }
00223
00224 }
00225 }
00226
00227
00228 void
00229 CatalogForm::isPressArrow()
00230 {
00231
00232 }
00233
00237 void
00238 CatalogForm::init()
00239 {
00240
00241 ListView = new aListView(centralWidget(), "listView");
00242 ListView->setGeometry(30,30,400,300);
00243 ListView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
00244 LineEdit = new aLineEdit(centralWidget(), "lineEdit");
00245 ListHint = new aListBox(centralWidget(), "listBox");
00246 StatusFrame = new QFrame(centralWidget(), "statusFrame");
00247
00248 ListView->setRootIsDecorated( true );
00249
00250 StatusFrame->setGeometry( QRect( 0, 0, 50,5 ) );
00251 StatusFrame->setFrameShape( QFrame::StyledPanel );
00252 StatusFrame->setFrameShadow( QFrame::Raised );
00253 StatusFrame->hide();
00254
00255 GridLayout = new QGridLayout(centralWidget(), 1, 1, 11, 6, "GridLayout");
00256 GridLayout->addMultiCellWidget( ListView, 2,3, 0 , 0 );
00257 GridLayout->addWidget( LineEdit, 1, 0 );
00258 GridLayout->addWidget( bCancel, 3, 1 );
00259 QLabel *lb = new QLabel(tr("Search"),centralWidget());
00260 lb->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, lb->sizePolicy().hasHeightForWidth() ) );
00261 GridLayout->addWidget( lb ,0,0);
00262 QSpacerItem* spacer = new QSpacerItem( 20, 390, QSizePolicy::Minimum, QSizePolicy::Expanding );
00263 GridLayout->addMultiCell( spacer, 0,2,1, 1);
00264
00265 QPixmap pix= QPixmap::fromMimeSource("cat.png");
00266 if(pix.isNull())
00267 {
00268 aLog::print(aLog::MT_INFO, tr("Catalog Form image cat.png not loaded"));
00269 }
00270 else
00271 {
00272 setIcon( pix );
00273 }
00274
00275
00276
00277
00278 connect(ListView, SIGNAL (newItemRequest(QListViewItem*)),
00279 this, SLOT (new_item(QListViewItem*)));
00280
00281 connect(ListView, SIGNAL (newGroupRequest(QListViewItem*)),
00282 this, SLOT (new_group(QListViewItem*)));
00283
00284 connect(ListView, SIGNAL (delItemRequest(QListViewItem*)),
00285 this, SLOT (del_item(QListViewItem*)));
00286
00287 connect(ListView, SIGNAL (markDeletedRequest(QListViewItem*)),
00288 this, SLOT (mark_deleted(QListViewItem*)));
00289
00290 connect(ListView, SIGNAL (undoMarkDeletedRequest(QListViewItem*)),
00291 this, SLOT (undo_mark_deleted(QListViewItem*)));
00292
00293 connect(ListView, SIGNAL (editRequest(QListViewItem*, int)),
00294 this, SLOT (edit(QListViewItem*, int)));
00295
00296 connect(ListView, SIGNAL (selectRequest(QListViewItem*)),
00297 this, SLOT (select(QListViewItem*)));
00298
00299 connect(LineEdit, SIGNAL (delayTextChanged(const QString&)),
00300 this, SLOT (find(const QString&)));
00301
00302 connect(LineEdit, SIGNAL (keyArrowPressed()),
00303 this, SLOT (pressArrow()));
00304
00305 connect(LineEdit, SIGNAL (keyEnterPressed()),
00306 this, SLOT (go()));
00307
00308 connect(ListView, SIGNAL (expanded ( QListViewItem *)),
00309 this, SLOT (onLoadElements( QListViewItem *)));
00310
00311 connect(ListHint, SIGNAL (lostFocus()),
00312 LineEdit, SLOT (setFocus()));
00313
00314 connect(ListHint, SIGNAL (lostFocus()),
00315 StatusFrame, SLOT (hide()));
00316
00317 connect(ListHint, SIGNAL (lostFocus()),
00318 ListHint, SLOT (hide()));
00319
00320 connect(ListHint, SIGNAL (keyArrowLRPressed()),
00321 LineEdit, SLOT (setFocus()));
00322
00323 connect(ListHint, SIGNAL (keyArrowLRPressed(const QString&)),
00324 this, SLOT (setText(const QString&)));
00325
00326 connect(ListHint, SIGNAL (keyEnterPressed()),
00327 this, SLOT (go()));
00328
00329 connect(ListHint, SIGNAL (sendMessage(const QString &)),
00330 this->statusBar(), SLOT (message( const QString &)));
00331
00332 connect(ListView, SIGNAL (sendMessage(const QString &)),
00333 this->statusBar(), SLOT (message( const QString &)));
00334
00335 connect(LineEdit, SIGNAL (sendMessage(const QString &)),
00336 this->statusBar(), SLOT (message( const QString &)));
00337
00338 LineEdit->setFocus();
00339 }
00340
00344 void
00345 CatalogForm::destroy()
00346 {
00347 aService::saveSize2Config(this->rect(),QString("%1_embedded editor").arg(cat->md->attr(cat->obj, mda_name)));
00348 delete cat;
00349 cat = 0;
00350 }
00351
00355 void
00356 CatalogForm::setText( const QString & s )
00357 {
00358 LineEdit->blockSignals ( true );
00359 LineEdit->setText ( s );
00360 setId(ListHint->getId(ListHint->currentItem()));
00361 LineEdit->blockSignals ( false );
00362 }
00363
00367 void
00368 CatalogForm::go()
00369 {
00370 Q_ULLONG ide=getId(), idg;
00371 if(!getId())
00372 {
00373 ide = findFirst(LineEdit->text());
00374 setId(ide);
00375 }
00376 idg = getIdg(ide);
00377 loadElements(idg);
00378 if(map_el.contains(getId()))
00379 {
00380 goToItem(map_el[getId()]);
00381 }
00382
00383 }
00387 void
00388 CatalogForm::goToItem( QListViewItem *item)
00389 {
00390 ListView->setSelected(item, true);
00391 ListView->ensureItemVisible(item);
00392 ListView->setFocus();
00393 }
00394
00400 long
00401 CatalogForm::findFirst( const QString &s )
00402 {
00403 Q_ULLONG res=0;
00404 cat->select(fieldName + " like '%"+s+"%'");
00405
00406 if(cat->First())
00407 {
00408 res = cat->sysValue("id").toULongLong();
00409
00410 }
00411 return res;
00412 }
00413
00418 void
00419 CatalogForm::loadElements( Q_ULLONG idGroup )
00420 {
00421 QListViewItem * item;
00422 QListViewItem * p_item;
00423 uint i;
00424
00425
00426 QPixmap pixmap(getElementPixmap());
00427 QPixmap pixmap_mark_deleted(getMarkDeletedPixmap());
00428 cat->selectByGroup(idGroup);
00429
00430 if(cat->First())
00431 {
00432 do
00433 {
00434
00435 if(map_gr.contains(idGroup)
00436 && !map_el.contains(cat->sysValue("id").toULongLong()))
00437 {
00438 p_item = map_gr[idGroup];
00439 item = new QListViewItem(p_item);
00440 if(cat->isElementMarkDeleted())
00441 item->setPixmap(0,pixmap_mark_deleted);
00442 else
00443 item->setPixmap(0,pixmap);
00444 for(i=0; i<fieldList.count(); i++)
00445 {
00446
00447 item->setText(i,cat->sysValue(fieldList[i]).toString());
00448 }
00449 map_el.insert(cat->sysValue("id").toULongLong(),item);
00450 }
00451 }while(cat->Next());
00452 }
00453
00454 }
00455
00460 void
00461 CatalogForm::onLoadElements( QListViewItem *item )
00462 {
00463 QValueList<QListViewItem*> lst = map_gr.values();
00464 int ind = lst.findIndex(item);
00465 Q_ULLONG key;
00466 if(ind!=-1)
00467 {
00468 QValueList<Q_ULLONG> listKey = map_gr.keys();
00469 key = listKey[ind];
00470 loadElements(key);
00471 }
00472 }
00473
00479 Q_ULLONG
00480 CatalogForm::getIdg( Q_ULLONG ide )
00481 {
00482 return cat->idGroupByElement(ide);
00483 }
00484
00485
00490 void
00491 CatalogForm::new_item( QListViewItem * parentItem )
00492 {
00493 if(!parentItem)
00494 {
00495
00496 cat->newElement(0);
00497
00498 QListViewItem* item = new QListViewItem(ListView);
00499 QPixmap pixmap(getElementPixmap());
00500 item->setPixmap(0,pixmap);
00501 map_el.insert(cat->sysValue("id").toULongLong(),item);
00502 edit(item,true);
00503 ListView->ensureItemVisible(item);
00504
00505 return;
00506 }
00507 Q_ULLONG id = getGroupId(parentItem);
00508 QPixmap pixmap(getElementPixmap());
00509 if(id)
00510 {
00511 cat->groupSelect(id);
00512 if(!cat->isGroupMarkDeleted())
00513 {
00514 cat->newElement(id);
00515 QListViewItem* item = new QListViewItem(map_gr[id]);
00516 item->setPixmap(0,pixmap);
00517 map_el.insert(cat->sysValue("id").toULongLong(),item);
00518 edit(item,true);
00519 ListView->ensureItemVisible(item);
00520
00521 }
00522 else cfg_message(0,tr("Can't added new element to mark deleted group"));
00523 }
00524 else
00525 {
00526 new_item(parentItem->parent());
00527 }
00528 }
00529
00534 long
00535 CatalogForm::getGroupId( QListViewItem * item )
00536 {
00537 QValueList<QListViewItem*> lst = map_gr.values();
00538 int ind = lst.findIndex(item);
00539 Q_ULLONG key=0;
00540 if(ind!=-1)
00541 {
00542 QValueList<Q_ULLONG> listKey = map_gr.keys();
00543 key = listKey[ind];
00544 }
00545 return key;
00546 }
00547
00552 void
00553 CatalogForm::new_group( QListViewItem * parentItem )
00554 {
00555 Q_ULLONG id = getGroupId(parentItem);
00556 QListViewItem * item;
00557 QPixmap pixmap(getGroupPixmap());
00558
00559 if(!id)
00560 {
00561 id = getElementId(parentItem);
00562 if(id)
00563 {
00564 cfg_message(0,tr("Can't added group to element"));
00565 return;
00566 }
00567 else
00568 {
00569
00570 cat->newGroup(id);
00571 item = new QListViewItem(ListView);
00572 ListView->insertItem(item);
00573 }
00574 }
00575 else
00576 {
00577
00578 if(cat->isGroupMarkDeleted())
00579 {
00580 cfg_message(0,tr("Can't added group to mark deleted group"));
00581 return;
00582 }
00583 cat->newGroup(id);
00584 item = new QListViewItem(map_gr[id]);
00585 }
00586
00587 item->setPixmap(0,pixmap);
00588 map_gr.insert(cat->GroupSysValue("id").toULongLong(),item);
00589 edit(item,true);
00590 ListView->ensureItemVisible(item);
00591 ListView->setCurrentItem(item);
00592 ListView->setSelected(item,true);
00593
00594
00595 }
00596
00601 QPixmap
00602 CatalogForm::getGroupPixmap()
00603 {
00604 QPixmap pixmap = QPixmap::fromMimeSource("group2.png");
00605
00606 if(pixmap.isNull())
00607 {
00608 aLog::print(aLog::MT_INFO, tr("Catalog Form group pixmap not load"));
00609 }
00610 return pixmap;
00611 }
00612
00613
00618 QPixmap
00619 CatalogForm::getElementPixmap()
00620 {
00621 QPixmap pixmap= QPixmap::fromMimeSource("field2.png");
00622 if(pixmap.isNull())
00623 {
00624 aLog::print(aLog::MT_INFO, tr("Catalog Form element pixmap not load"));
00625 }
00626 return pixmap;
00627 }
00628
00633 QPixmap
00634 CatalogForm::getMarkDeletedPixmap()
00635 {
00636 QPixmap pixmap = QPixmap::fromMimeSource("editdelete2.png");
00637
00638 if(pixmap.isNull())
00639 {
00640 aLog::print(aLog::MT_INFO, tr("Catalog Form mark deleted group pixmap not load"));
00641 }
00642 return pixmap;
00643 }
00648 void CatalogForm::del_item( QListViewItem * item )
00649 {
00650
00651 Q_ULLONG id = getElementId(item);
00652 if(id)
00653 {
00654 cat->select(id);
00655 if(cat->First())
00656 {
00657 cat->delElement();
00658 map_el.remove(id);
00659 delete item;
00660 item = 0;
00661 }
00662 }
00663 else
00664 {
00665 id = getGroupId(item);
00666 if(id)
00667 {
00668 QValueList<Q_ULLONG> listDeletedId;
00669 cat->delGroup(id, listDeletedId);
00670 QValueList<Q_ULLONG>::iterator it = listDeletedId.begin();
00671 while(it!= listDeletedId.end())
00672 {
00673 if(map_el.contains(*it)) map_el.remove(*it);
00674 else if(map_gr.contains(*it)) map_gr.remove(*it);
00675 ++it;
00676 }
00677 delete item;
00678 item = 0;
00679 }
00680 }
00681 }
00682
00688 void CatalogForm::mark_deleted( QListViewItem * item )
00689 {
00690 Q_ULLONG id = getElementId(item);
00691 if(id)
00692 {
00693 cat->select(id);
00694
00695 if(cat->First())
00696 {
00697 cat->setMarkDeletedElement(id,true);
00698 item->setPixmap(0,getMarkDeletedPixmap());
00699 }
00700 }
00701 else
00702 {
00703 id = getGroupId(item);
00704 if(id)
00705 {
00706 loadElements(id);
00707 QValueList<Q_ULLONG> listDeletedId;
00708 cat->getMarkDeletedList(id,listDeletedId);
00709 QValueList<Q_ULLONG>::iterator it = listDeletedId.begin();
00710 while(it != listDeletedId.end())
00711 {
00712 if(map_el.contains(*it))
00713 {
00714 map_el[*it]->setPixmap(0, getMarkDeletedPixmap());
00715 cat->setMarkDeletedElement(*it,true);
00716 it = listDeletedId.remove(it);
00717 }
00718 else
00719 {
00720 ++it;
00721 }
00722 }
00723 it = listDeletedId.begin();
00724 while(it != listDeletedId.end())
00725 {
00726 if(map_gr.contains(*it))
00727 {
00728 map_gr[*it]->setPixmap(0, getMarkDeletedPixmap());
00729 cat->setMarkDeletedGroup(*it,true);
00730 it = listDeletedId.remove(it);
00731
00732 }
00733 else
00734 {
00735 ++it;
00736 }
00737 }
00738 }
00739 }
00740 }
00741
00746 void CatalogForm::undo_mark_deleted( QListViewItem * item )
00747 {
00748 Q_ULLONG id = getElementId(item);
00749 if(id)
00750 {
00751 cat->select(id);
00752 if(cat->First())
00753 {
00754 cat->setMarkDeletedElement(id,false);
00755 item->setPixmap(0,getElementPixmap());
00756 }
00757 }
00758 else
00759 {
00760 id = getGroupId(item);
00761 if(id)
00762 {
00763
00764
00765 QValueList<Q_ULLONG> listDeletedId;
00766
00767 cat->getMarkDeletedList(id, listDeletedId);
00768 QValueList<Q_ULLONG>::iterator it = listDeletedId.begin();
00769 while(it != listDeletedId.end())
00770 {
00771 if(map_el.contains(*it))
00772 {
00773 map_el[*it]->setPixmap(0, getElementPixmap());
00774 cat->setMarkDeletedElement(*it,false);
00775 it = listDeletedId.remove(it);
00776 }
00777 else
00778 {
00779 ++it;
00780 }
00781 }
00782 it = listDeletedId.begin();
00783 while(it != listDeletedId.end())
00784 {
00785 if(map_gr.contains(*it))
00786 {
00787 map_gr[*it]->setPixmap(0, getGroupPixmap());
00788 cat->setMarkDeletedGroup(*it,false);
00789 it = listDeletedId.remove(it);
00790
00791 }
00792 else
00793 {
00794 ++it;
00795 }
00796 }
00797 }
00798 }
00799 }
00800
00801 void CatalogForm::edit( QListViewItem * item, int)
00802 {
00803 edit( item, false);
00804 }
00805
00806 void CatalogForm::edit( QListViewItem * item, bool afterNew)
00807 {
00808
00809 aLog::print(aLog::MT_DEBUG, tr("Catalog Form edit element start"));
00810 MainForm * mw = (MainForm*) topLevelWidget();
00811 if(mw)
00812 {
00813 Q_ULLONG id = getElementId(item);
00814 if(id)
00815 {
00816 aLog::print(aLog::MT_DEBUG, tr("Catalog Form edit element with id=%1").arg(id));
00817 cat->select(id);
00818 if(idElementForm)
00819 {
00820 if(!cat->isElementMarkDeleted())
00821 {
00822 aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idElementForm);
00823 if(editForm)
00824 {
00825 if(afterNew) editForm->setMode(0);
00826 else editForm->setMode(1);
00827 editForm->Select(id);
00828 connect(editForm, SIGNAL(closeForm(Q_ULLONG)), this, SLOT(Refresh(Q_ULLONG)));
00829 editForm->show();
00830 }
00831 else
00832 {
00833 aLog::print(aLog::MT_ERROR, tr("Catalog Form edit element form is null"));
00834 }
00835 }
00836 else cfg_message(0, tr("Can't edit mark deleted element"));
00837 }
00838 else cfg_message(1,tr("Catalog haven't edit element form"));
00839 }
00840 else
00841 {
00842 id = getGroupId(item);
00843 aLog::print(aLog::MT_DEBUG, tr("Catalog Form edit group with id = %1").arg(id));
00844 if(id)
00845 {
00846
00847 cat->groupSelect(id);
00848 if(idGroupForm)
00849 {
00850 if(!cat->isGroupMarkDeleted())
00851 {
00852 aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idGroupForm);
00853 if(editForm)
00854 {
00855 if(afterNew) editForm->setMode(0);
00856 else editForm->setMode(1);
00857
00858 editForm->SelectGroup(id);
00859 connect(editForm, SIGNAL(closeForm(Q_ULLONG)), this, SLOT(Refresh(Q_ULLONG)));
00860 editForm->show();
00861 }
00862 else
00863 {
00864 aLog::print(aLog::MT_ERROR, tr("Catalog Form edit group form is null"));
00865 }
00866 }
00867 else cfg_message(0, tr("Can't edit mark deleted group"));
00868 }
00869 else cfg_message(1,tr("Catalog haven't edit group form"));
00870 }
00871 }
00872 }
00873 else
00874 {
00875 aLog::print(aLog::MT_ERROR, tr("Catalog Form main widget is not 'MainForm'"));
00876 }
00877
00878 }
00879
00884 void CatalogForm::select( QListViewItem * item )
00885 {
00886 Q_ULLONG res = getGroupId(item);
00887 if(!res)
00888 {
00889 res = getElementId(item);
00890 cat->select(res);
00891 if(!cat->isElementMarkDeleted())
00892 {
00893 setId(res);
00894 doOk();
00895 }
00896 }
00897 else
00898 {
00899 cat->groupSelect(res);
00900 if(!cat->isGroupMarkDeleted())
00901 {
00902 setId(res);
00903 doOk();
00904 }
00905 }
00906 emit(selected(res));
00907
00908 }
00909
00914 Q_ULLONG CatalogForm::getElementId( QListViewItem * item )
00915 {
00916 QValueList<QListViewItem*> lst = map_el.values();
00917 int ind = lst.findIndex(item);
00918 Q_ULLONG key=0;
00919 if(ind!=-1)
00920 {
00921 QValueList<Q_ULLONG> listKey = map_el.keys();
00922 key = listKey[ind];
00923 }
00924 return key;
00925 }
00926
00927
00928 void CatalogForm::doOk()
00929 {
00930 close();
00931 }
00932
00933
00934
00935 void CatalogForm::keyPressEvent( QKeyEvent * e )
00936 {
00937 if ( e->key()==Qt::Key_Return)
00938 {
00939 }
00940 if ( e->key()==Qt::Key_Escape)
00941 {
00942 close();
00943 }
00944 e->ignore();
00945 }
00946
00947
00948 void CatalogForm::Refresh( Q_ULLONG id )
00949 {
00950 QListViewItem * item;
00951 if( map_el.contains( id ))
00952 {
00953 item = map_el[id];
00954 cat->select( id );
00955 for(uint i=0; i<fieldList.count(); i++)
00956 {
00957
00958 item->setText(i,cat->sysValue(fieldList[i]).toString());
00959 ListView->setFocus();
00960 }
00961 }
00962 else
00963 {
00964 if( map_gr.contains( id ) )
00965 {
00966 item = map_gr[id];
00967 cat->groupSelect( id );
00968 item->setText(0,cat->GroupSysValue(fieldListGroup[0]).toString());
00969 ListView->setFocus();
00970 }
00971 }
00972 }
00973
00974
00975
00976
00977