QTableWidgetItem *twi = table->item(row, 4); // description
if (twi == NULL)
continue;
+ // if a header/footnote/&c with no sub-fields, don't inflate
+ // the size of col_widths[0]
+ if (!itemlist[row].Selectable()
+ && !itemlist[row].str.contains(QChar('\t')))
+ continue;
// determine column widths of sub-fields within description
QStringList columns = itemlist[row].str.split("\t");
for (int fld = 0; fld < (int) columns.size(); ++fld) {
QTableWidgetItem *cnt = table->item(row, 0);
if (cnt != NULL) {
QString Amt = "";
- long amt = count(row); // fetch item(i,0) as a number
+ long amt = count(row); // fetch item(row,0) as a number
if (amt > 0L)
Amt.sprintf("%*ld", countdigits, amt);
cnt->setText(Amt);
if (split_descr) {
QStringList columns = text.split("\t");
for (int fld = 0; fld < (int) columns.size() - 1; ++fld) {
- //columns[j] += "\t";
+ //columns[fld] += "\t"; /* (used to pad with tabs) */
int width = col_widths[fld];
while (fm.width(columns[fld]) < width)
columns[fld] += " "; //"\t";
letter = QString(mi.ch) + " - ";
} else {
// Letter is left blank, except for skills display when # and * are
- // presented
+ // presented (note: they're just displayed, not become selectors)
if (text.startsWith(" ")) {
// If mi.str starts with " ", it's meant to line up with lines
// that have a letter; we don't want that here
twi = new QTableWidgetItem(letter);
table->setItem(row, 3, twi);
table->item(row, 3)->setFlags(Qt::ItemIsEnabled);
- WidenColumn(3, fm.width(letter));
+ // add extra padding because the measured width comes out too narrow;
+ // for the normal case of "a - ", the trailing space hid the fact that
+ // the column wasn't wide enough for four characters; for the " #"
+ // and " *" cases, the last character was replaced by very tiny "..."
+ int w = (int) fm.width(letter);
+ if (w)
+ w += MENU_WIDTH_SLOP / 2;
+ WidenColumn(3, w);
twi = new QTableWidgetItem(text);
table->setItem(row, 4, twi);
cb->setChecked(Qt::Checked);
}
}
- if (biggestcount > 0L) { // counts got cleared when entries became checked
- UpdateCountColumn(-1L);
+ if (biggestcount > 0L) { // had one or more counts
+ UpdateCountColumn(-1L); // all counts are now gone
} else {
table->repaint();
}
cb->setChecked(Qt::Unchecked);
}
}
- if (biggestcount > 0L) { // all counts have been removed
- UpdateCountColumn(-1L);
+ if (biggestcount > 0L) { // had one or more counts
+ UpdateCountColumn(-1L); // all counts are now gone
} else {
table->repaint();
}
continue;
ToggleSelect(row, false);
}
- if (biggestcount > 0L) { // all entries with counts are now unchecked
- UpdateCountColumn(-1L);
+ if (biggestcount > 0L) { // had one or more counts
+ UpdateCountColumn(-1L); // all counts are now gone
} else {
table->repaint();
}
searching = true;
NetHackQtStringRequestor requestor(this, "Search for:");
- char line[256];
+ char line[BUFSZ];
line[0] = '\0'; /* for EDIT_GETLIN */
if (requestor.Get(line)) {
for (int i=0; i<itemcount; i++) {
searching = false;
}
-void NetHackQtMenuWindow::ToggleSelect(int row, bool already_checked)
+void NetHackQtMenuWindow::ToggleSelect(int row, bool already_toggled)
{
if (itemlist[row].Selectable()) {
QCheckBox *cb = dynamic_cast<QCheckBox *> (table->cellWidget(row, 1));
if (how == PICK_ONE) {
// explicitly picking a preselected item in a pick-one menu
// chooses that item rather than toggling preselection off;
- // by clearing whole menu, the code below will select item #i
+ // by clearing whole menu, the code below will select item #row
ChooseNone();
- already_checked = false;
+ already_toggled = false;
// FIXME? this won't handle a pending count properly;
// are there any pick-one menus with preselected choice
// where a count is useful?
QTableWidgetItem *countfield = table->item(row, 0);
if (!counting) {
- if (!already_checked)
+ if (!already_toggled)
cb->setChecked((cb->checkState() == Qt::Unchecked) // toggle
? Qt::Checked : Qt::Unchecked);
itemlist[row].selected = (cb->checkState() != Qt::Unchecked);