[apps/shared] Factorize tab table controller in a class

Change-Id: I0af0da6b9a1216c57c8a4b669d14d8a3473ac48b
This commit is contained in:
Émilie Feral
2017-03-08 11:18:55 +01:00
parent 72d898e73e
commit b4b2e284e1
9 changed files with 97 additions and 119 deletions

View File

@@ -10,16 +10,10 @@ namespace Shared {
EditableCellTableViewController::EditableCellTableViewController(Responder * parentResponder, KDCoordinate topMargin,
KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin) :
ViewController(parentResponder),
m_selectableTableView(SelectableTableView(this, this, topMargin, rightMargin, bottomMargin, leftMargin, this,
false, true, Palette::WallScreenDark))
TabTableController(parentResponder, topMargin, rightMargin, bottomMargin, leftMargin, this, true)
{
}
View * EditableCellTableViewController::view() {
return &m_selectableTableView;
}
bool EditableCellTableViewController::textFieldDidFinishEditing(TextField * textField, const char * text) {
AppsContainer * appsContainer = ((TextFieldDelegateApp *)app())->container();
Context * globalContext = appsContainer->globalContext();
@@ -64,14 +58,6 @@ KDCoordinate EditableCellTableViewController::rowHeight(int j) {
return k_cellHeight;
}
KDCoordinate EditableCellTableViewController::cumulatedHeightFromIndex(int j) {
return j*k_cellHeight;
}
int EditableCellTableViewController::indexFromCumulatedHeight(KDCoordinate offsetY) {
return (offsetY-1) / k_cellHeight;
}
void EditableCellTableViewController::willDisplayCellAtLocationWithDisplayMode(HighlightCell * cell, int i, int j, Expression::FloatDisplayMode floatDisplayMode) {
EvenOddCell * myCell = (EvenOddCell *)cell;
myCell->setEven(j%2 == 0);
@@ -104,12 +90,12 @@ void EditableCellTableViewController::didBecomeFirstResponder() {
int selectedColumn = m_selectableTableView.selectedColumn();
selectedColumn = selectedColumn >= numberOfColumns() ? numberOfColumns() - 1 : selectedColumn;
m_selectableTableView.selectCellAtLocation(selectedColumn, selectedRow);
app()->setFirstResponder(&m_selectableTableView);
TabTableController::didBecomeFirstResponder();
}
}
void EditableCellTableViewController::viewWillAppear() {
m_selectableTableView.reloadData();
TabTableController::viewWillAppear();
if (m_selectableTableView.selectedRow() == -1) {
m_selectableTableView.selectCellAtLocation(0, 1);
} else {
@@ -121,12 +107,6 @@ void EditableCellTableViewController::viewWillAppear() {
}
}
void EditableCellTableViewController::willExitResponderChain(Responder * nextFirstResponder) {
if (nextFirstResponder == tabController()) {
m_selectableTableView.deselectTable();
}
}
TextFieldDelegateApp * EditableCellTableViewController::textFieldDelegateApp() {
return (TextFieldDelegateApp *)app();
}