| 550 | } |
| 551 | |
| 552 | void CATableView::reloadData() |
| 553 | { |
| 554 | CC_RETURN_IF(m_pTableViewDataSource == NULL); |
| 555 | this->reloadViewSizeData(); |
| 556 | |
| 557 | this->removeAllSubviews(); |
| 558 | |
| 559 | float width = this->getBounds().size.width; |
| 560 | unsigned int y = 0; |
| 561 | |
| 562 | if (m_pTableHeaderView) |
| 563 | { |
| 564 | m_pTableHeaderView->setFrame(DRect(0, y, width, m_nTableHeaderHeight)); |
| 565 | this->addSubview(m_pTableHeaderView); |
| 566 | y += m_nTableHeaderHeight; |
| 567 | } |
| 568 | |
| 569 | unsigned int sectionCount = m_pTableViewDataSource->numberOfSections(this); |
| 570 | |
| 571 | m_rTableCellRectss.resize(sectionCount); |
| 572 | m_rLineRectss.resize(sectionCount); |
| 573 | for (unsigned int i=0; i<sectionCount; i++) |
| 574 | { |
| 575 | DRect sectionHeaderRect = DRect(0, y, width, m_nSectionHeaderHeights.at(i)); |
| 576 | CAView* sectionHeaderView = m_pTableViewDataSource->tableViewSectionViewForHeaderInSection(this, sectionHeaderRect.size, i); |
| 577 | |
| 578 | if (sectionHeaderView) |
| 579 | { |
| 580 | sectionHeaderView->setFrame(sectionHeaderRect); |
| 581 | this->insertSubview(sectionHeaderView, 2); |
| 582 | m_pSectionHeaderViews[i] = sectionHeaderView; |
| 583 | } |
| 584 | y += m_nSectionHeaderHeights[i]; |
| 585 | |
| 586 | m_rTableCellRectss[i].resize(m_nRowHeightss[i].size()); |
| 587 | m_rLineRectss[i].resize(m_nRowHeightss[i].size()); |
| 588 | for (unsigned int j=0; j<m_rTableCellRectss[i].size(); j++) |
| 589 | { |
| 590 | m_rTableCellRectss[i][j] = DRect(0, y, width, m_nRowHeightss[i][j]); |
| 591 | y += m_nRowHeightss[i][j]; |
| 592 | |
| 593 | m_rLineRectss[i][j] = DRect(0, y, width, s_px_to_dip(m_nSeparatorViewHeight)); |
| 594 | y += s_px_to_dip(m_nSeparatorViewHeight); |
| 595 | } |
| 596 | |
| 597 | DRect sectionFooterRect = DRect(0, y, width, m_nSectionFooterHeights.at(i)); |
| 598 | |
| 599 | CAView* sectionFooterView = m_pTableViewDataSource->tableViewSectionViewForFooterInSection(this, sectionFooterRect.size, i); |
| 600 | |
| 601 | if (sectionFooterView) |
| 602 | { |
| 603 | sectionFooterView->setFrame(sectionFooterRect); |
| 604 | this->insertSubview(sectionFooterView, 2); |
| 605 | m_pSectionFooterViews[i] = sectionFooterView; |
| 606 | } |
| 607 | |
| 608 | DRect sectionRect = sectionHeaderRect; |
| 609 | sectionRect.size.height = sectionFooterRect.origin.y |
no test coverage detected