Files
Upsilon/apps/statistics/store_controller.cpp
Émilie Feral 128af56396 [apps/statistics] Forbid negative sizes and round float sizes
Change-Id: I4db9777bea04f70b86da97f940ef5cbe669e41d9
2017-03-29 15:04:37 +02:00

47 lines
1.3 KiB
C++

#include "store_controller.h"
#include "app.h"
#include "../apps_container.h"
#include "../constant.h"
#include <assert.h>
using namespace Shared;
namespace Statistics {
StoreController::StoreController(Responder * parentResponder, Store * store, ButtonRowController * header) :
Shared::StoreController(parentResponder, store, header),
m_titleCells{EvenOddMessageTextCell(KDText::FontSize::Small), EvenOddMessageTextCell(KDText::FontSize::Small)}
{
}
void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
::StoreController::willDisplayCellAtLocation(cell, i, j);
if (cellAtLocationIsEditable(i, j)) {
return;
}
EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
if (i == 0) {
mytitleCell->setMessage(I18n::Message::Values);
return;
}
mytitleCell->setMessage(I18n::Message::Sizes);
}
HighlightCell * StoreController::titleCells(int index) {
assert(index >= 0 && index < k_numberOfTitleCells);
return &m_titleCells[index];
}
bool StoreController::setDataAtLocation(float floatBody, int columnIndex, int rowIndex) {
if (columnIndex == 1) {
if (floatBody < 0) {
return false;
}
m_store->set(roundf(floatBody), columnIndex, rowIndex-1);
return true;
}
return Shared::StoreController::setDataAtLocation(floatBody, columnIndex, rowIndex);
}
}