From 20c13c172cd82a68c806757bd1ccc8d26f27367e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 7 Feb 2017 15:20:15 +0100 Subject: [PATCH] [apps/shared] Do no display button to add a new cell when the maximum number of functions is reached Change-Id: I0717998ee3ae9ca575462ee0139182c698ea6c02 --- apps/graph/list/list_controller.cpp | 6 ++++-- apps/shared/list_controller.cpp | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/graph/list/list_controller.cpp b/apps/graph/list/list_controller.cpp index 1e1154ce5..e774d2ba1 100644 --- a/apps/graph/list/list_controller.cpp +++ b/apps/graph/list/list_controller.cpp @@ -38,7 +38,8 @@ bool ListController::handleEnter() { switch (m_selectableTableView.selectedColumn()) { case 0: { - if (m_selectableTableView.selectedRow() == numberOfRows() - 1) { + if (m_functionStore->numberOfFunctions() < m_functionStore->maxNumberOfFunctions() && + m_selectableTableView.selectedRow() == numberOfRows() - 1) { return true; } configureFunction(m_functionStore->functionAtIndex(m_selectableTableView.selectedRow())); @@ -46,7 +47,8 @@ bool ListController::handleEnter() { } case 1: { - if (m_selectableTableView.selectedRow() == numberOfRows() - 1) { + if (m_functionStore->numberOfFunctions() < m_functionStore->maxNumberOfFunctions() && + m_selectableTableView.selectedRow() == numberOfRows() - 1) { return addFunction(); } FunctionExpressionCell * functionCell = (FunctionExpressionCell *)(m_selectableTableView.cellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow())); diff --git a/apps/shared/list_controller.cpp b/apps/shared/list_controller.cpp index b9d4b16ad..9605c651f 100644 --- a/apps/shared/list_controller.cpp +++ b/apps/shared/list_controller.cpp @@ -18,6 +18,9 @@ View * ListController::view() { } int ListController::numberOfRows() { + if (m_functionStore->numberOfFunctions() == m_functionStore->maxNumberOfFunctions()) { + return m_functionStore->numberOfFunctions(); + } return 1 + m_functionStore->numberOfFunctions(); }; @@ -26,7 +29,7 @@ int ListController::numberOfColumns() { }; KDCoordinate ListController::rowHeight(int j) { - if (j == numberOfRows() - 1) { + if (m_functionStore->numberOfFunctions() < m_functionStore->maxNumberOfFunctions() && j == numberOfRows() - 1) { return k_emptyRowHeight; } Function * function = m_functionStore->functionAtIndex(j); @@ -93,7 +96,8 @@ int ListController::indexFromCumulatedHeight(KDCoordinate offsetY) { } int ListController::typeAtLocation(int i, int j) { - if (j == numberOfRows() - 1) { + if (m_functionStore->numberOfFunctions() < m_functionStore->maxNumberOfFunctions() + && j == numberOfRows() - 1) { return i + 2; } return i; @@ -125,7 +129,7 @@ int ListController::reusableCellCount(int type) { } void ListController::willDisplayCellAtLocation(TableViewCell * cell, int i, int j) { - if (j < numberOfRows() - 1) { + if (j < numberOfRows() - 1 || m_functionStore->numberOfFunctions() == m_functionStore->maxNumberOfFunctions()) { if (i == 0) { FunctionTitleCell * myFunctionCell = (FunctionTitleCell *)cell; Function * function = m_functionStore->functionAtIndex(j);