void ResourceScene::populate() { QVector< QVector > resources = m_pMatrix->getReservations(); QVector< int> timeline; int start; int length; if (m_reservationItems.count() > 0) { for (int i = 0; i < m_reservationItems.count(); i++) { this->removeItem(m_reservationItems[i]); delete(m_reservationItems[i]); } m_reservationItems.clear(); } for (int i = 0; i < resources.count(); i++) { timeline = resources.at(i); for (int j = 0; j < timeline.count(); j++) { if(timeline.at(j)) { start = j; length = 0; while (timeline.at(start + length)) { if ((start + ++length) > (timeline.count() - 1)) break; } m_reservationItems.append(this->addRect(m_resourceAnnotationWidth + (j * m_columnWidth) + 2, m_timeAnnotationHeight + (i * m_rowHeight) + 2, (length * m_columnWidth) - 4, m_rowHeight - 4, m_reservationPen, m_reservationBrush)); j = start + length; } } this->invalidate(this->sceneRect()); } }