// add keymap Keymap *Keymaps::add(const Keymap &i_keymap) { if (Keymap *k = searchByName(i_keymap.getName())) return k; m_keymapList.push_front(i_keymap); return &m_keymapList.front(); }
Component *searchByName (string name, Component *root) { if (!root) { return NULL; } else { bool found = false; unsigned int i; for (i = 0; i < root->getChildren().size(); i++) { if (root->getChildren()[i]->getName() == name) { found = true; return root; } } if (!found) { for (i = 0; i < root->getChildren().size(); i++) { return searchByName (name, root->getChildren()[i]); } } } }
void searching(Result *person, int amount) { int choice; while(1) { switch(choice = subMenu()) { case 1: if(!searchByName(person, amount)) { printf("Cannot find this person\n"); } continue; case 2: if(!searchByClass(person, amount)) { printf("Cannot find this person\n"); } continue; case 3: if(!searchByAverage(person, amount)) { printf("Cannot find this person\n"); } continue; case 4: break; } break; } }
//! Find and select an object from its standard program name bool StelObjectMgr::findAndSelect(const QString &name, StelModule::StelModuleSelectAction action) { // Then look for another object StelObjectP obj = searchByName(name); if (!obj) return false; else return setSelectedObject(obj, action); }
// add a named keyseq (name can be empty) KeySeq *KeySeqs::add(const KeySeq &i_keySeq) { if (!i_keySeq.getName().empty()) { KeySeq *ks = searchByName(i_keySeq.getName()); if (ks) return &(*ks = i_keySeq); } m_keySeqList.push_front(i_keySeq); return &m_keySeqList.front(); }
RankingDialog::RankingDialog(const QStringList &tiers) { QVBoxLayout *mainLayout = new QVBoxLayout(this); QHBoxLayout *row1 = new QHBoxLayout(); mainLayout->addLayout(row1); QPushButton *search; row1->addWidget(name = new QLineEdit()); row1->addWidget(search = new QPushButton(tr("&Search"))); row1->addWidget(tierSelection = new QComboBox()); tierSelection->addItems(tiers); players = new QCompactTable(0,3); players->setAlternatingRowColors(true); players->setHorizontalHeaderLabels(QStringList() << tr("Rank") << tr("Player Name") << tr("Points")); players->horizontalHeader()->setStretchLastSection(true); mainLayout->addWidget(players); QHBoxLayout *row3 = new QHBoxLayout(); mainLayout->addLayout(row3); QPushButton *prev, *next; row3->addWidget(prev = new QPushButton("<<")); row3->addWidget(next = new QPushButton(">>")); row3->addWidget(page = new QLineEdit(), 0, Qt::AlignRight); row3->addWidget(totalPages = new QLabel("/ ---"), 0, Qt::AlignLeft); resize(400,500); page->setMaximumWidth(40); setAttribute(Qt::WA_DeleteOnClose, true); connect(next, SIGNAL(clicked()), SLOT(nextPage())); connect(prev, SIGNAL(clicked()), SLOT(prevPage())); connect(tierSelection, SIGNAL(activated(int)), SLOT(searchByName())); connect(name, SIGNAL(returnPressed()), SLOT(searchByName())); connect(search, SIGNAL(clicked()), SLOT(searchByName())); connect(this->page, SIGNAL(returnPressed()), SLOT(changePage())); }
int main(){ openDatabase(); char choice; int checkLoop; while(1){ checkLoop = 1; char name[128],message[512]; printf("\n%sSEARCH IN DATABASE\n",ANSI_COLOR_CYAN); printf(" 1. Search by name\n"); printf(" 2. Search by message content\n"); printf(" 3. Search by both name and message content\n"); printf(" 4. Exit\n"); while (checkLoop==1){ printf("Enter your choice: %s",ANSI_COLOR_RESET); scanf("%s",&choice); getchar(); switch (choice) { case '1': printf("Enter name: "); scanf("%s",name); searchByName(&name); checkLoop=0; break; case '2': printf("Enter message: "); scanf("%s",message); searchByMsg(&message); checkLoop=0; break; case '3': printf("Enter name: "); scanf("%s",name); printf("Enter message: "); scanf("%s",message); searchByNameAndMsg(&name,&message); checkLoop=0; break; case '4': exit(0); break; default: printf("%sPlease enter a valid choice!%s\n",ANSI_COLOR_RED,ANSI_COLOR_RESET); } } } sqlite3_close(db); }
void Report::searchMainMenu() { int choice; do { system(CLEAR); //show the mainMenu and get the choice cout << "\t\tSearch\n\t\tMain Menu\n\n"; cout << "\t 1. Search restaurants by name\n"; cout << "\t 2. Search restaurants by cuisine\n"; cout << "\t 3. Return to main menu\n"; cout << "\n\t Enter your choice: "; cin >> choice; if (choice == 1) { //run searchByName(); searchByName(); } else if (choice == 2) { //run searchByCuisine(); searchByCuisine(); } else if (choice == 3) { //return to main menu break; } else { system(CLEAR); cout << "\n\t Please enter a valid selection.\n"; cin.clear(); cin.ignore(1000, '\n'); cout << "\n\t Press return to continue."; cin.get(); choice = 0; } } while (choice != 3); }
int main() { int command = 1; int const size = 30; Phone *list = NULL; open(list); setlocale (LC_ALL, "Rus"); while (command) { printf("Выберите операцию для выполнения:\n0 - выход\n1 - добавить запись\n2 - найти телефон по имени\n3 - найти имя по телефону\n4 - сохранить текущие данные в файл\n"); scanf("%d", &command); if (command == 1) { int number = 0; char name[size]; printf("Введите имя и номер\n"); scanf("%s %d", name, &number); addContact(name, number, list); } if (command == 2) { printf("Введите имя\n"); char name[size]; scanf("%s", name); searchByName(name, list); } if (command == 3) { printf("Введите номер телефона\n"); int number = 0; scanf("%d", &number); searchByNumber(number, list); } if (command == 4) { save(list); } } exit(list); return 0; }
bool GUI::removeComponent (string name) { Component *toDelete = searchByName (name, this->root); if (toDelete) { Component *temp = toDelete->getParent(); for (unsigned int i = 0; i < temp->getChildren().size(); i++) { if (temp->getChildren()[i] == toDelete) { temp->getChildren().erase(temp->getChildren().begin() + i); subtractArea (temp, toDelete->getAreaUsage()); return true; } } } else { return false; } }