| 535 | } |
| 536 | |
| 537 | void NetHackQtMenuWindow::AddRow(int row, const MenuItem& mi) |
| 538 | { |
| 539 | QFontMetrics fm(table->font()); |
| 540 | QTableWidgetItem *twi; |
| 541 | glyph_info gi; |
| 542 | |
| 543 | if (mi.Selectable() && how != PICK_NONE) { |
| 544 | // Count |
| 545 | twi = new QTableWidgetItem(""); |
| 546 | table->setItem(row, 0, twi); |
| 547 | twi->setFlags(Qt::ItemIsEnabled); |
| 548 | #if 0 // active count field now widened as needed rather than preset |
| 549 | WidenColumn(0, fm.QFM_WIDTH("999999") + MENU_WIDTH_SLOP); |
| 550 | #else |
| 551 | WidenColumn(0, MENU_WIDTH_SLOP); |
| 552 | #endif |
| 553 | |
| 554 | // Check box, set if pre-selected |
| 555 | QCheckBox *cb = new QCheckBox(); |
| 556 | cb->setChecked(mi.preselected); |
| 557 | cb->setFocusPolicy(Qt::NoFocus); |
| 558 | // CheckboxClicked() will call ToggleSelect() for item whose checkbox |
| 559 | // gets clicked upon |
| 560 | connect(cb, SIGNAL(clicked(bool)), this, SLOT(CheckboxClicked(bool))); |
| 561 | table->setCellWidget(row, 1, cb); |
| 562 | WidenColumn(1, cb->width()); |
| 563 | } |
| 564 | if (mi.glyph != NO_GLYPH) { |
| 565 | // Icon |
| 566 | map_glyphinfo(0, 0, mi.glyph, 0, &gi); |
| 567 | QPixmap pm(qt_settings->glyphs().glyph(mi.glyph, gi.gm.tileidx)); |
| 568 | twi = new QTableWidgetItem(QIcon(pm), ""); |
| 569 | table->setItem(row, 2, twi); |
| 570 | twi->setFlags(Qt::ItemIsEnabled); |
| 571 | WidenColumn(2, pm.width()); |
| 572 | } |
| 573 | |
| 574 | QString letter, text(mi.str); |
| 575 | if (mi.ch != 0) { |
| 576 | // Letter specified |
| 577 | letter = QString(mi.ch) + " - "; |
| 578 | } else { |
| 579 | // Letter is left blank, except for skills display when # and * are |
| 580 | // presented (note: they're just displayed, not become selectors) |
| 581 | if (text.startsWith(" ")) { |
| 582 | // If mi.str starts with " ", it's meant to line up with lines |
| 583 | // that have a letter; we don't want that here |
| 584 | text = text.mid(4); |
| 585 | } else if (text.startsWith(" #") || text.startsWith(" *")) { |
| 586 | // Put the * or # in the letter column |
| 587 | letter = text.left(4); |
| 588 | text = text.mid(4); |
| 589 | } |
| 590 | } |
| 591 | twi = new QTableWidgetItem(letter); |
| 592 | table->setItem(row, 3, twi); |
| 593 | table->item(row, 3)->setFlags(Qt::ItemIsEnabled); |
| 594 | // add extra padding because the measured width comes out too narrow; |
nothing calls this directly
no test coverage detected