| 307 | } |
| 308 | |
| 309 | int NetHackQtMenuWindow::SelectMenu(int h, MENU_ITEM_P **menu_list) |
| 310 | { |
| 311 | table->setRowCount(itemcount); |
| 312 | |
| 313 | how=h; |
| 314 | |
| 315 | int presel_ct = 0; |
| 316 | for (int i = 0; i < itemcount; ++i) |
| 317 | if (itemlist[i].preselected) |
| 318 | ++presel_ct; |
| 319 | bool ok_ok = (how != PICK_ONE || presel_ct == 1); |
| 320 | ok->setEnabled(ok_ok); ok->setDefault(ok_ok); |
| 321 | cancel->setEnabled(true); |
| 322 | all->setEnabled(how == PICK_ANY || (how == PICK_ONE && itemcount == 1)); |
| 323 | none->setEnabled(how == PICK_ANY || (how == PICK_ONE && presel_ct == 1)); |
| 324 | invert->setEnabled(how == PICK_ANY || (how == PICK_ONE && itemcount == 1)); |
| 325 | search->setEnabled(how != PICK_NONE); |
| 326 | |
| 327 | setResult(-1); |
| 328 | |
| 329 | // Set contents of table |
| 330 | QFontMetrics fm(table->font()); |
| 331 | for (int col = 0; col < 5; ++col) { |
| 332 | table->setColumnWidth(col, 0); |
| 333 | } |
| 334 | // default height is way too big; rows end up being double-spaced with it |
| 335 | int rowheight = fm.height() * 3 / 5; |
| 336 | for (int row = 0; row < itemcount; ++row) { |
| 337 | AddRow(row, itemlist[row]); |
| 338 | table->setRowHeight(row, rowheight); |
| 339 | } |
| 340 | PadMenuColumns(::iflags.menu_tab_sep ? true : false); |
| 341 | |
| 342 | MenuResize(); |
| 343 | |
| 344 | //old FIXME: size for compact mode |
| 345 | //resize(this->width(), parent()->height()*7/8); |
| 346 | move(0, 0); |
| 347 | centerOnMain(this); |
| 348 | |
| 349 | exec(); |
| 350 | int result = this->result(); |
| 351 | |
| 352 | *menu_list = (MENU_ITEM_P *) 0; |
| 353 | if (result > 0 && how != PICK_NONE) { |
| 354 | int n = 0; |
| 355 | for (int i = 0; i < itemcount; ++i) |
| 356 | if (itemlist[i].selected) |
| 357 | ++n; |
| 358 | if (n) { |
| 359 | *menu_list = (MENU_ITEM_P *) alloc(n * sizeof(MENU_ITEM_P)); |
| 360 | n = 0; |
| 361 | for (int i = 0; i < itemcount; ++i) { |
| 362 | if (itemlist[i].selected) { |
| 363 | (*menu_list)[n].item = itemlist[i].identifier; |
| 364 | (*menu_list)[n].count = count(i); |
| 365 | ++n; |
| 366 | } |
nothing calls this directly
no test coverage detected