void toTemplateEdit::remove(void) { if (LastTemplate != TemplateMap.end()) { toTreeWidgetItem *item = findLast(); TemplateMap.erase(LastTemplate); LastTemplate = TemplateMap.end(); Name->setText(QString::null); Description->setText(QString::null); if (item) { connectList(false); clearUnused(Templates->firstChild(), ""); connectList(true); } } }
void toTemplateEdit::newTemplate(void) { changeSelection(); LastTemplate = TemplateMap.end(); Description->setText(QString::null); toTreeWidgetItem *item = Templates->selectedItem(); if (item) { connectList(false); Templates->setSelected(item, false); connectList(true); item = item->parent(); } QString str; if (item) { str = name(item); str += ":"; } Name->setText(str); }
int main(int argc, char* argv[]) { /* Declarations */ List list; List list_1; List list_2; List list_3; List list_4; List list_5; List list_6; Position pos; Position pos_1; Position pos_2; Position pos_3; Position pos_4; Position pos_a, pos_b; int len; int idx; ElementType elem; /* Initialize list */ list=createList(); /* Test functions 'insertNode' and 'appendNode' */ printf("Test functions 'insertNode' and 'appendNode'\n\n"); printf("Before 'insertNode':\n"); printList(list); pos_1=getHeaderNode(list); insertNode(11, list, pos_1); pos_2=advanceNode(pos_1); insertNode(2, list, pos_2); pos_3=advanceNode(pos_2); insertNode(3, list, pos_3); pos_4=advanceNode(pos_3); insertNode(10, list, pos_4); insertNode(9, list, pos_2); printf("After 'insertNode':\n"); printList(list); printf("Before 'appendNode':\n"); printList(list); appendNode(7, list); appendNode(2, list); printf("After 'appendNode'\n"); printList(list); printf("\n"); /* Test functions 'cloneList', 'deleteNode' and 'deleteList' */ printf("Test functions 'cloneList', 'deleteNode' and 'deleteList'\n\n"); list_1=cloneList(list); printf("Before 'deleteNode':\n"); printList(list_1); deleteNode(2, list_1); printf("After 'deleteNode':\n"); printList(list_1); printf("Before 'deleteList':\n"); printList(list_1); deleteList(list_1); printf("After 'deleteList':\n"); printList(list_1); printf("\n"); /* Test function 'getListLength' */ printf("Test function 'getListLength'\n\n"); len=getListLength(list); printf("Length: %d\n", len); printf("\n"); /* Test functions 'findNode', 'findNodePrevious' and 'getNodeIndex' */ printf("Test functions 'findNode', 'findNodePrevious' and 'getNodeIndex'\n\n"); elem=2; pos=findNode(elem, list); if(pos!=NULL) { idx=getNodeIndex(pos, list); printList(list); printf("finding %d, Element at index %d found\n", elem, idx); } else { printf("finding %d, not found\n", elem); } elem=3; pos=findNodePrevious(elem, list); /* Check whether elem is found in list */ if(pos->m_next!=NULL) { idx=getNodeIndex(pos, list); printf("finding previous element of %d, Element at index %d found\n", elem, idx); } else { /* elem is not in list */ printf("finding previous element of %d, not found\n", elem); } printf("\n"); /* Test functions 'makeListEmpty' and 'isListEmpty' */ printf("Test functions 'makeListEmpty' and 'isListEmpty'\n\n"); list_2=cloneList(list); printf("Before 'makeListEmpty':\n"); printList(list_2); list_2=makeListEmpty(list_2); if(isListEmpty(list_2)) { printf("List emptied successfully\n"); printf("After 'makeListEmpty'\n"); printList(list_2); } printf("\n"); /* Test functions 'getHeaderNode', 'getFirstNode', 'getLastNode', 'advanceNode' and 'getNodeElem' */ printf("Test functions 'getHeaderNode', 'getFirstNode', 'getLastNode', 'advanceNode' and 'getNodeElem'\n\n"); printList(list); pos=getHeaderNode(list); printf("Header at index %d\n", getNodeIndex(pos, list)); pos=getFirstNode(list); printf("First element at index %d have value %d\n", getNodeIndex(pos, list), getNodeElem(pos)); pos=getLastNode(list); printf("Last element at index %d have value %d\n", getNodeIndex(pos, list), getNodeElem(pos)); pos=getFirstNode(list); pos=advanceNode(pos); printf("Second element at index %d have value %d\n", getNodeIndex(pos, list), getNodeElem(pos)); printf("\n"); /* Test function 'reverseList' */ printf("Test function 'reverseList'\n\n"); list_3=cloneList(list); printf("Before 'reverseList':\n"); printList(list_3); list_3=reverseList(list_3); printf("After 'reverseList':\n"); printList(list_3); printf("\n"); /* Test function 'swapNode' */ printf("Test function 'swapNode'\n\n"); list_4=cloneList(list); printf("Before 'swapNode':\n"); printList(list_4); pos_a=getHeaderNode(list_4); pos_a=advanceNode(pos_a); pos_a=advanceNode(pos_a); pos_b=advanceNode(pos_a); swapNode(pos_a, pos_b, list_4); printf("After 'swapNode':\n"); printList(list_4); printf("\n"); /* Test function 'bubbleSortList' */ printf("Test function 'bubbleSortList'\n\n"); list_5=cloneList(list); printf("Before 'bubbleSortList':\n"); printList(list_5); bubbleSortList(list_5); printf("After 'bubbleSortList':\n"); printList(list_5); printf("\n"); /* Test function 'connectList' */ printf("Test function 'connectList'\n\n"); printf("List 1:\n"); printList(list); printf("Length: %d\n", getListLength(list)); printf("List 2:\n"); printList(list_5); printf("Length: %d\n", getListLength(list_5)); list_6=connectList(list, list_5); printf("Connected list:\n"); printList(list_6); printf("Length: %d\n", getListLength(list_6)); printf("\n"); /* Cleanup memory */ destroyList(list); destroyList(list_1); destroyList(list_2); destroyList(list_3); destroyList(list_4); destroyList(list_5); destroyList(list_6); return 0; }
PriceList::PriceList(MainWindow* main, bool prices) : ActiveList(main, "PriceList", true) { _helpSource = "price_cost_list.html"; // List for prices _tabs->changeTab(_list, tr("Prices")); _list->addTextColumn(tr("Item Type"), 12); _list->addTextColumn(tr("Name"), 12); _list->addTextColumn(tr("Size"), 8); _list->addTextColumn(tr("Card Type"), 12); _list->addTextColumn(tr("Name"), 12); _list->addTextColumn(tr("Price"), 24); _list->setSorting(0); // List for costs _cost = new ListView(_tabs); _tabs->addTab(_cost, tr("Costs")); _cost->setAllColumnsShowFocus(true); _cost->setRootIsDecorated(false); _cost->setShowSortIndicator(true); _cost->addTextColumn(tr("Item Type"), 12); _cost->addTextColumn(tr("Name"), 12); _cost->addTextColumn(tr("Size"), 8); _cost->addTextColumn(tr("Card Type"), 12); _cost->addTextColumn(tr("Name"), 12); _cost->addTextColumn(tr("Cost"), 24); _cost->setSorting(0); connectList(_cost); QLabel* itemLabel = new QLabel(tr("Item:"), _search); _item = new ItemEdit(new ItemLookup(_main, this), _search); _item->setLength(18, '9'); itemLabel->setBuddy(_item); QLabel* cardLabel = new QLabel(tr("Card:"), _search); _card = new LookupEdit(new CardLookup(_main, this), _search); _card->setLength(30); cardLabel->setBuddy(_card); QLabel* batchLabel = new QLabel(tr("Promo Batch:"), _search); _batch = new LookupEdit(new PromoBatchLookup(main, this), _search); _batch->setLength(10); QLabel* storeLabel = new QLabel(tr("Store:"), _search); _store = new LookupEdit(new StoreLookup(main, this), _search); _store->setLength(30); QGridLayout* grid = new QGridLayout(_search); grid->setSpacing(3); grid->setMargin(3); grid->setColStretch(2, 1); grid->addWidget(itemLabel, 0, 0); grid->addWidget(_item, 0, 1, AlignLeft | AlignVCenter); grid->addWidget(cardLabel, 1, 0); grid->addWidget(_card, 1, 1, AlignLeft | AlignVCenter); grid->addWidget(batchLabel, 0, 3); grid->addWidget(_batch, 0, 4, AlignLeft | AlignVCenter); grid->addWidget(storeLabel, 1, 3); grid->addWidget(_store, 1, 4, AlignLeft | AlignVCenter); if (_quasar->storeCount() == 1) { storeLabel->hide(); _store->hide(); } connect(_quasar->db(), SIGNAL(dataEvent(DataEvent*)), this, SLOT(dataEvent(DataEvent*))); if (!prices) _tabs->setCurrentPage(1); setCaption(tr("Prices and Costs")); finalize(false); _item->setFocus(); }
//------------------------------------------------------------------------- FKCW_3D_Mesh* CreateConeMesh(float r,float h,int nSlice,int nStack,bool isHaveBottom, const FKCW_3D_Vector4&headColor,const FKCW_3D_Vector4&bottomColor) //why cone need nStack ? because even a plane need subdivision to achieve better specular effect { float dA=360.0f/nSlice; const float PIDIV180= static_cast<float>(M_PI/180.0f); vector<FKCW_3D_Vector4> positionList; vector<FKCW_3D_Vector2> texCoordList; vector<FKCW_3D_Vector4> normalList; vector<FKCW_3D_Vector4> colorList; vector<FKCW_3D_IDTriangle> IDtriList; //----generate side //generate positionList, texCoordList, normalList, colorList for(int i=0;i<=nStack;i++){ float y=i*h/nStack; for (int j=0; j<=nSlice; j++) { float A=j*dA; float R=r-i*r/nStack; float cosA=cosf(A*PIDIV180); float sinA=sinf(A*PIDIV180); float x=R*cosA; float z=R*sinA; FKCW_3D_Vector4 position(x,y,z,1); float s=(float)j/nSlice+0.25f; float t=1-(float)i/nStack; FKCW_3D_Vector2 texCoord(s,t); float ny=r/sqrtf(FKCW_Square(h)+FKCW_Square(r)); float nx,nz;//nx*nx+ny*ny+nz*nz=1 and nx:nz=cosA:sinA => k=sqrt((1-ny*ny)/(cosA*cosA+sinA*sinA)), nx=cosA*k, nz=sinA*k float k=sqrtf((1-ny*ny)/(cosA*cosA+sinA*sinA)); nx=cosA*k; nz=sinA*k; FKCW_3D_Vector4 normal=normalize(FKCW_3D_Vector4(nx,ny,nz,0)); FKCW_3D_Vector4 color=bottomColor*(1-(float)i/nStack)+headColor*((float)i/nStack); positionList.push_back(position); texCoordList.push_back(texCoord); normalList.push_back(normal); colorList.push_back(color); } } //generate IDtriList for(int i=0;i<nStack;i++){ for(int j=0;j<nSlice;j++){ int vID_ld=(nSlice+1)*i+j; int vID_rd=vID_ld+1; int vID_ru=vID_rd+(nSlice+1); int vID_lu=vID_ru-1; FKCW_3D_IDTriangle IDtri0(vID_ld,vID_rd,vID_ru); FKCW_3D_IDTriangle IDtri1(vID_ld,vID_ru,vID_lu); IDtriList.push_back(IDtri0); IDtriList.push_back(IDtri1); } } //----generate bottom if(isHaveBottom){ vector<FKCW_3D_Vector4> _positionList=positionList; vector<FKCW_3D_Vector2> _texCoordList=texCoordList; vector<FKCW_3D_Vector4> _normalList=normalList; vector<FKCW_3D_Vector4> _colorList=colorList; vector<FKCW_3D_IDTriangle> _IDtriList=IDtriList; //all postion in _positionList set y to zero int _nPosition=(int)_positionList.size(); for(int i=0;i<_nPosition;i++){ FKCW_3D_Vector4&position=_positionList[i]; position.sety(0); } //all normal in _normalList set to (0,-1,0,0) int _nNormal=(int)_normalList.size(); for(int i=0;i<_nNormal;i++){ FKCW_3D_Vector4&normal=_normalList[i]; normal=FKCW_3D_Vector4(0, -1, 0, 0); } //all index in _IDtriList should be plus offset=(int)positionList.size() const int offset=(int)positionList.size(); int _nIDtri=(int)_IDtriList.size(); for(int i=0;i<_nIDtri;i++){ FKCW_3D_IDTriangle&IDtri=_IDtriList[i]; int ID0=IDtri.vID(0); int ID1=IDtri.vID(1); int ID2=IDtri.vID(2); IDtri.init(ID0+offset, ID1+offset, ID2+offset); } //connect side and bottom positionList=connectList(positionList,_positionList); texCoordList=connectList(texCoordList,_texCoordList); normalList=connectList(normalList,_normalList); colorList=connectList(colorList,_colorList); IDtriList=connectList(IDtriList,_IDtriList); } //----create mesh FKCW_3D_SubMeshData*subMeshData=new FKCW_3D_SubMeshData(); subMeshData->autorelease(); subMeshData->init(); subMeshData->initPositionList(positionList); subMeshData->initTexCoordList(texCoordList); subMeshData->initNormalList(normalList); subMeshData->initColorList(colorList); subMeshData->initIDtriList(IDtriList); FKCW_3D_SubMesh* subMesh=new FKCW_3D_SubMesh(); subMesh->autorelease(); subMesh->init(); subMesh->setSubMeshData(subMeshData); FKCW_3D_Mesh* mesh=new FKCW_3D_Mesh(); mesh->autorelease(); mesh->init(); mesh->addSubMesh(subMesh); return mesh; }
AddressBook::AddressBook(MainWindow* main) : ActiveList(main, "AddressBook", true) { _helpSource = "address_book.html"; // Columns for all tab _list->addTextColumn(tr("Name"), 30); _list->addTextColumn(tr("Number"), 12); _list->addTextColumn(tr("Phone Number"), 20); _list->addTextColumn(tr("Type"), 14); _list->setSorting(0); // Catch changing tabs so can disable buttons connect(_tabs, SIGNAL(currentChanged(QWidget*)), SLOT(tabChanged(QWidget*))); // List for customers tab if (_quasar->securityCheck("CustomerMaster", "View")) { _customer = new ListView(_tabs); _tabs->addTab(_customer, tr("&Customers")); _customer->setAllColumnsShowFocus(true); _customer->setRootIsDecorated(false); _customer->setShowSortIndicator(true); _customer->addTextColumn(tr("Name"), 30); _customer->addTextColumn(tr("Number"), 12); _customer->addTextColumn(tr("Phone Number"), 20); _customer->addMoneyColumn(tr("Balance")); _customer->setSorting(0); connectList(_customer); } else { _customer = NULL; } // List for vendors tab if (_quasar->securityCheck("VendorMaster", "View")) { _vendor = new ListView(_tabs); _tabs->addTab(_vendor, tr("&Vendors")); _vendor->setAllColumnsShowFocus(true); _vendor->setRootIsDecorated(false); _vendor->setShowSortIndicator(true); _vendor->addTextColumn(tr("Name"), 30); _vendor->addTextColumn(tr("Number"), 12); _vendor->addTextColumn(tr("Phone Number"), 20); _vendor->addMoneyColumn(tr("Balance")); _vendor->setSorting(0); connectList(_vendor); } else { _vendor = NULL; } // List for employees tab if (_quasar->securityCheck("EmployeeMaster", "View")) { _employee = new ListView(_tabs); _tabs->addTab(_employee, tr("&Employees")); _employee->setAllColumnsShowFocus(true); _employee->setRootIsDecorated(false); _employee->setShowSortIndicator(true); _employee->addTextColumn(tr("Name"), 30); _employee->addTextColumn(tr("Number"), 12); _employee->addTextColumn(tr("Phone Number"), 20); _employee->setSorting(0); connectList(_employee); } else { _employee = NULL; } // List for personal tab if (_quasar->securityCheck("PersonalMaster", "View")) { _personal = new ListView(_tabs); _tabs->addTab(_personal, tr("&Personal")); _personal->setAllColumnsShowFocus(true); _personal->setRootIsDecorated(false); _personal->setShowSortIndicator(true); _personal->addTextColumn(tr("Name"), 30); _personal->addTextColumn(tr("Phone Number"), 20); _personal->setSorting(0); connectList(_personal); } else { _personal = NULL; } QLabel* nameLabel = new QLabel(tr("Name:"), _search); _name = new LineEdit(_search); _name->setLength(40); connect(_name, SIGNAL(returnPressed()), SLOT(slotRefresh())); QLabel* numberLabel = new QLabel(tr("Number:"), _search); _number = new LineEdit(_search); _number->setLength(12); connect(_number, SIGNAL(returnPressed()), SLOT(slotRefresh())); QLabel* groupLabel = new QLabel(tr("Group:"), _search); _groupLookup = new GroupLookup(_main, this, -1); _group = new LookupEdit(_groupLookup, _search); _group->setLength(15); groupLabel->setBuddy(_group); QLabel* storeLabel = new QLabel(tr("Store:"), _search); _store = new LookupEdit(new StoreLookup(main, this), _search); _store->setLength(30); QGridLayout* grid = new QGridLayout(_search); grid->setSpacing(3); grid->setMargin(3); grid->setColStretch(2, 1); grid->addWidget(nameLabel, 0, 0); grid->addWidget(_name, 0, 1, AlignLeft | AlignVCenter); grid->addWidget(numberLabel, 1, 0); grid->addWidget(_number, 1, 1, AlignLeft | AlignVCenter); grid->addWidget(groupLabel, 2, 0); grid->addWidget(_group, 2, 1, AlignLeft | AlignVCenter); grid->addWidget(storeLabel, 3, 0); grid->addWidget(_store, 3, 1, AlignLeft | AlignVCenter); if (_quasar->storeCount() == 1) { storeLabel->hide(); _store->hide(); } setCaption(tr("Address Book")); finalize(false); _name->setFocus(); }