From ca03d2741ee3c5976b548870f3a844c7fe62e85f Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Sun, 11 Feb 2024 03:54:47 +0000 Subject: Total weight sorting --- src/gui/models/sortlistmodelbuy.h | 8 ++++++-- src/gui/models/sortlistmodelinv.h | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/gui/models') diff --git a/src/gui/models/sortlistmodelbuy.h b/src/gui/models/sortlistmodelbuy.h index 2b2f56d12..19ef70cc6 100644 --- a/src/gui/models/sortlistmodelbuy.h +++ b/src/gui/models/sortlistmodelbuy.h @@ -28,7 +28,9 @@ #include "utils/gettext.h" -static const char *const SORT_NAME_BUY[7] = +#define NUM_ELEMENTS(a) sizeof(a) / sizeof(a[0]) + +static const char *const SORT_NAME_BUY[8] = { // TRANSLATORS: buy dialog sort type. N_("unsorted"), @@ -40,6 +42,8 @@ static const char *const SORT_NAME_BUY[7] = N_("by id"), // TRANSLATORS: buy dialog sort type. N_("by weight"), + // TRANSLATORS: inventory sort mode + N_("by total weight"), // TRANSLATORS: buy dialog sort type. N_("by amount"), // TRANSLATORS: buy dialog sort type. @@ -56,7 +60,7 @@ class SortListModelBuy final : public ListModel A_DELETE_COPY(SortListModelBuy) int getNumberOfElements() override final - { return 7; } + { return NUM_ELEMENTS(SORT_NAME_BUY); } std::string getElementAt(int i) override final { diff --git a/src/gui/models/sortlistmodelinv.h b/src/gui/models/sortlistmodelinv.h index e3cd7e9ad..f89e21a8d 100644 --- a/src/gui/models/sortlistmodelinv.h +++ b/src/gui/models/sortlistmodelinv.h @@ -27,7 +27,9 @@ #include "utils/gettext.h" -static const char *const SORT_NAME_INVENTORY[6] = +#define NUM_ELEMENTS(a) sizeof(a) / sizeof(a[0]) + +static const char *const SORT_NAME_INVENTORY[7] = { // TRANSLATORS: inventory sort mode N_("default"), @@ -38,6 +40,8 @@ static const char *const SORT_NAME_INVENTORY[6] = // TRANSLATORS: inventory sort mode N_("by weight"), // TRANSLATORS: inventory sort mode + N_("by total weight"), + // TRANSLATORS: inventory sort mode N_("by amount"), // TRANSLATORS: inventory sort mode N_("by type") @@ -53,7 +57,7 @@ class SortListModelInv final : public ListModel A_DELETE_COPY(SortListModelInv) int getNumberOfElements() override final - { return 6; } + { return NUM_ELEMENTS(SORT_NAME_INVENTORY); } std::string getElementAt(int i) override final { -- cgit v1.2.3-70-g09d2