ListBookController - partie 2

This commit is contained in:
Fournier Gabriel
2020-11-15 18:55:34 +01:00
parent c37b4bd1f4
commit b4e9ceed18
2 changed files with 22 additions and 3 deletions

View File

@@ -12,11 +12,13 @@ ListBookController::ListBookController(Responder * parentResponder):
ViewController(parentResponder),
m_tableView(this, this)
{
m_files[0].name= "Harry Potter 1.txt";
m_nbFiles = 1;
}
int ListBookController::numberOfRows() const
{
return 0;
return m_nbFiles;
}
KDCoordinate ListBookController::cellHeight()
@@ -26,12 +28,20 @@ KDCoordinate ListBookController::cellHeight()
HighlightCell * ListBookController::reusableCell(int index)
{
return nullptr;
return &m_cells[index];
}
int ListBookController::reusableCellCount() const
{
return 0;
return NB_CELLS;
}
void ListBookController::willDisplayCellForIndex(HighlightCell * cell, int index)
{
MessageTableCell* myTextCell = static_cast<MessageTableCell*>(cell);
MessageTextView* textView = static_cast<MessageTextView*>(myTextCell->labelView());
textView->setText(m_files[index].name);
myTextCell->setMessageFont(KDFont::LargeFont);
}
}

View File

@@ -2,6 +2,7 @@
#define __LIST_BOOK_CONTROLLER_H__
#include <escher.h>
#include <apps/external/archive.h>
namespace reader
{
@@ -16,8 +17,16 @@ public:
KDCoordinate cellHeight() override;
HighlightCell * reusableCell(int index) override;
int reusableCellCount() const override;
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
private:
TableView m_tableView;
static const int NB_FILES = 20;
External::Archive::File m_files[NB_FILES];
int m_nbFiles = 0;
static const int NB_CELLS = 6;
MessageTableCell m_cells[NB_CELLS];
};
}