From: PatR Date: Sat, 19 Mar 2022 22:32:31 +0000 (-0700) Subject: menuinvertmode for Qt X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20411d9ed4ef7284da0cd37c7989c315ce9df228;p=nethack menuinvertmode for Qt Catch up with tty, curses, and X11. Items flagged as skip-invert will not be toggled On by select-all. If menuinvertmode is 2, they also won't be toggled Off by unselect-all. --- diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index 29420d910..7a4eefee2 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -763,8 +763,11 @@ void NetHackQtMenuWindow::All() if (counting) ClearCount(); // discard any pending count for (int row = 0; row < itemcount; ++row) { - itemlist[row].selected = itemlist[row].preselected = false; - if (!itemlist[row].Selectable()) + itemlist[row].preselected = false; // stale for all rows + // skip if not selectable or already selected or fails invert_test() + if (!itemlist[row].Selectable() + || itemlist[row].selected + || !menuitem_invert_test(1, itemlist[row].itemflags, FALSE)) continue; itemlist[row].selected = true; @@ -792,9 +795,13 @@ void NetHackQtMenuWindow::ChooseNone() if (counting) ClearCount(); // discard any pending count for (int row = 0; row < itemcount; ++row) { - itemlist[row].selected = itemlist[row].preselected = false; - if (!itemlist[row].Selectable()) + itemlist[row].preselected = false; // stale for all rows + // skip if not selectable or already unselected or fails invert_test() + if (!itemlist[row].Selectable() + || !itemlist[row].selected + || !menuitem_invert_test(2, itemlist[row].itemflags, TRUE)) continue; + itemlist[row].selected = false; QTableWidgetItem *count = table->item(row, 0); if (count != NULL) { @@ -820,8 +827,10 @@ void NetHackQtMenuWindow::Invert() if (counting) ClearCount(); // discard any pending count for (int row = 0; row < itemcount; ++row) { - if (!menuitem_invert_test(0, itemlist[row].itemflags, - itemlist[row].preselected)) + itemlist[row].preselected = false; // stale for all rows + if (!itemlist[row].Selectable() + || !menuitem_invert_test(0, itemlist[row].itemflags, + itemlist[row].selected)) continue; ToggleSelect(row, false); }