fix some cppcheck complains

This commit is contained in:
Uri Tauber 2026-01-26 16:25:12 +02:00
parent 9a8aeee5ae
commit 4f227ec277
3 changed files with 9 additions and 33 deletions

View File

@ -498,29 +498,29 @@ void EpubReaderActivity::renderStatusBar(const int orientedMarginRight, const in
// Position status bar near the bottom of the logical screen, regardless of orientation
const auto screenHeight = renderer.getScreenHeight();
const auto textY = screenHeight - orientedMarginBottom - 4;
int progressTextWidth = 0;
if (showProgress) {
// Calculate progress in book
// TODO: use progress values for UI
// cppcheck-suppress unreadVariable
const float sectionChapterProg = static_cast<float>(section->currentPage) / section->pageCount;
// cppcheck-suppress unreadVariable
const float bookProgress = epub->calculateProgress(currentSpineIndex, sectionChapterProg) * 100;
}
// Left aligned battery icon and percentage
if (showBattery) {
ScreenComponents::drawBattery(renderer, orientedMarginLeft + 1, textY, showBatteryPercentage);
}
}
if (showBattery) {
ScreenComponents::drawBattery(renderer, orientedMarginLeft + 1, textY, showBatteryPercentage);
}
if (showChapterTitle) {
// Centered chatper title text
// Page width minus existing content with 30px padding on each side
const int rendererableScreenWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;
int progressTextWidth = 0;
const int batterySize = showBattery ? (showBatteryPercentage ? 50 : 20) : 0;
const int titleMarginLeft = batterySize + 30;
const int titleMarginRight = progressTextWidth + 30;
@ -630,8 +630,8 @@ void EpubReaderActivity::navigateToHref(const char* href, bool savePosition) {
BookMetadataCache::SpineEntry entry = epub->getSpineItem(i);
std::string spineItem = entry.href;
size_t lastSlash = spineItem.find_last_of('/');
std::string spineFilename = (lastSlash != std::string::npos) ? spineItem.substr(lastSlash + 1) : spineItem;
size_t lastslash = spineItem.find_last_of('/');
std::string spineFilename = (lastslash != std::string::npos) ? spineItem.substr(lastslash + 1) : spineItem;
if (spineFilename == filename) {
targetSpineIndex = i;

View File

@ -14,23 +14,7 @@ constexpr int SKIP_PAGE_MS = 700;
bool EpubReaderChapterSelectionActivity::hasSyncOption() const { return KOREADER_STORE.hasCredentials(); }
int EpubReaderChapterSelectionActivity::getTotalItems() const {
// Add 2 for sync options (top and bottom) if credentials are configured
const int syncCount = hasSyncOption() ? 2 : 0;
return epub->getTocItemsCount() + syncCount;
}
bool EpubReaderChapterSelectionActivity::isSyncItem(int index) const {
if (!hasSyncOption()) return false;
// First item and last item are sync options
return index == 0 || index == getTotalItems() - 1;
}
int EpubReaderChapterSelectionActivity::tocIndexFromItemIndex(int itemIndex) const {
// Account for the sync option at the top
const int offset = hasSyncOption() ? 1 : 0;
return itemIndex - offset;
}
int EpubReaderChapterSelectionActivity::getPageItems() const {
// Layout constants used in renderScreen

View File

@ -27,18 +27,10 @@ class EpubReaderChapterSelectionActivity final : public ActivityWithSubactivity
// This adapts automatically when switching between portrait and landscape.
int getPageItems() const;
// Total items including sync options (top and bottom)
int getTotalItems() const;
// Check if sync option is available (credentials configured)
bool hasSyncOption() const;
// Check if given item index is a sync option (first or last)
bool isSyncItem(int index) const;
// Convert item index to TOC index (accounting for top sync option offset)
int tocIndexFromItemIndex(int itemIndex) const;
// Filtered list of spine indices (excluding footnote pages)
std::vector<int> filteredSpineIndices;