store_selectable_table_view.cpp
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "store_selectable_table_view.h"
namespace Shared {
StoreSelectableTableView::StoreSelectableTableView(DoublePairStore * store, Responder * parentResponder, TableViewDataSource * dataSource, SelectableTableViewDataSource * selectionDataSource, SelectableTableViewDelegate * delegate) :
SelectableTableView(parentResponder, dataSource, selectionDataSource, delegate),
m_store(store)
{
}
bool StoreSelectableTableView::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::Down) {
return selecNonHiddenCellAtLocation(selectedColumn(), selectedRow()+1);
}
if (event == Ion::Events::Up) {
return selecNonHiddenCellAtLocation(selectedColumn(), selectedRow()-1);
}
if (event == Ion::Events::Left) {
return selecNonHiddenCellAtLocation(selectedColumn()-1, selectedRow());
}
if (event == Ion::Events::Right) {
return selecNonHiddenCellAtLocation(selectedColumn()+1, selectedRow());
}
return false;
}
bool StoreSelectableTableView::selecNonHiddenCellAtLocation(int i, int j) {
if (i < 0 || i >= dataSource()->numberOfColumns()) {
return false;
}
if (j < 0 || j >= dataSource()->numberOfRows()) {
return false;
}
int seriesIndex = i/DoublePairStore::k_numberOfColumnsPerSeries;
int numberOfPairsOfCurrentSeries = m_store->numberOfPairsOfSeries(seriesIndex);
if (j > 1 + numberOfPairsOfCurrentSeries) {
return selectCellAtLocation(i, 1 + numberOfPairsOfCurrentSeries);
}
return selectCellAtLocation(i, j);
}
}