void AdminMainWidget::initNameSurnameSearch(){ QGroupBox* groupBox=new QGroupBox(tr("Ricerca per nome e cognome:")); groupBox->setStyleSheet("QGroupBox{"+GUIStyle::formBorderStyle()+"margin-right:100px;} "); groupBox->setMaximumWidth(300); groupBox->setMaximumHeight(170); searchNSLayout=new QFormLayout; searchNSLayout->addItem(new QSpacerItem(100,15)); name=new QLineEdit; name->setPlaceholderText(tr("Nome")); searchNSLayout->addRow(tr("Nome"),name); surname=new QLineEdit; surname->setPlaceholderText(tr("Cognome")); searchNSLayout->addRow(tr("Cognome"),surname); searchNSLayout->addItem(new QSpacerItem(100,10)); searchNS=new QPushButton(tr("Cerca")); searchNS->setCursor(QCursor(Qt::PointingHandCursor)); searchNSLayout->addWidget(searchNS); connect(searchNS,SIGNAL(clicked()),this,SLOT(nameSearch())); connect(name,SIGNAL(returnPressed()),this,SLOT(nameSearch())); connect(surname,SIGNAL(returnPressed()),this,SLOT(nameSearch())); groupBox->setLayout(searchNSLayout); searchLayout->addWidget(groupBox); }//initNameSurnameSearch
// used for searching for item name void Inventory::nameSearch() { char searchStr[MAX_CHAR]; int flag; string ans; x = readFile(); do { system("cls"); invTempl(); cout << endl << endl; cout << "Please Enter the item name (type \"exit\" to cancel): "; //user will input any query here cin>>(searchStr); // // if user entered "exit" this statement will return to main menu if( strncmp( "exit", searchStr, 10 ) == 0 ) menuDisplay(); for( int i = 1; i <= x; ++i ) { // comparison between query and item name will be calculated here if( strncmp( inventory[i].itemName, searchStr, 100 ) == 0 ) { // if it is true then program will display found item cout << "\nItem found on item # " << i << " :" << '\n'; cout << "------------------------------------------------------" << '\n'; cout << "Name: " << "\t\t" << inventory[i].itemName << '\n'; cout << "I.C.: " << "\t\t" << inventory[i].itemcode<< '\n'; cout << "Quantity: " << '\t' << inventory[i].intrQty << '\n'; cout << "Per-Price: " << '\t' << "$ " << inventory[i].perPrice << '\n'; cout << "Total Price: " << '\t' << "$ " << inventory[i].total << '\n'; cout << "------------------------------------------------------" << '\n'; cout << " Do you want to search anything else:"<<endl; cin>>ans; if(ans=="yes"||ans=="y") nameSearch(); cout << "\nPress any key to continue..." << endl; getch(); menuDisplay(); } } cout << "\nWe didn't find your item, try again!"; flag = 1; getch(); }while (flag == 1);