Tracker: Fix number format in items count

* Fix cases where the total/selected item count value was not formatted
  (e.g "1000/1,000 selected").
* Fix the item value format when type-ahead filtering.

Change-Id: Ia7f64443227ee1a03ce96ab441cb4ffc77d026df
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10423
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Nathan Patrizi
2026-03-09 22:00:07 +00:00
committed by waddlesplash
parent 2e00deeaa0
commit c971c7adfc
2 changed files with 8 additions and 6 deletions
+6 -6
View File
@@ -229,19 +229,19 @@ BCountView::Draw(BRect updateRect)
if (IsTypingAhead())
itemString << TypeAhead();
else if (IsFiltering()) {
BString lastCountStr;
fNumberFormat.Format(lastCountStr, fLastCount);
if (fLastCountSelected != 0) {
static BStringFormat selectedFilteredFormat(B_TRANSLATE_COMMENT(
"{0, plural, other{#/%total %filter}}",
"Number of selected items from a filtered set: \"10/30 view\""));
char lastCountStr[32];
snprintf(lastCountStr, sizeof(lastCountStr), "%" B_PRId32, fLastCount);
selectedFilteredFormat.Format(itemString, fLastCountSelected);
itemString.ReplaceFirst("%total", lastCountStr);
itemString.ReplaceFirst("%filter", Filter());
} else
itemString << fLastCount << " " << Filter();
itemString << lastCountStr << " " << Filter();
} else {
if (fLastCount == 0)
itemString << B_TRANSLATE("no items");
@@ -255,8 +255,8 @@ BCountView::Draw(BRect updateRect)
"{0, plural, other{#/%total selected}}",
"Number of selected items out of a total: \"10/30 selected\""));
char lastCountStr[32];
snprintf(lastCountStr, sizeof(lastCountStr), "%" B_PRId32, fLastCount);
BString lastCountStr;
fNumberFormat.Format(lastCountStr, fLastCount);
selectedFormat.Format(itemString, fLastCountSelected);
itemString.ReplaceFirst("%total", lastCountStr);
+2
View File
@@ -35,6 +35,7 @@ All rights reserved.
#define _COUNT_VIEW_H
#include <NumberFormat.h>
#include <String.h>
#include <View.h>
@@ -86,6 +87,7 @@ private:
bigtime_t fStartSpinningAfter;
BString fTypeAheadString;
BString fFilterString;
BNumberFormat fNumberFormat;
};
} // namespace BPrivate