void SyncMeasuresDialogCentralWidget::displayMeasures(int pageIdx) { std::vector<Component *> components = m_componentList->components(); for( std::vector<Component *>::iterator it = components.begin(); it != components.end(); ++it ) { delete *it; } int startPoint = pageIdx * NUM_COMPONENTS_DISPLAYED; int endPoint = (pageIdx + 1) * NUM_COMPONENTS_DISPLAYED - 1; if(endPoint >= static_cast<int>(m_measures.size())){ endPoint = m_measures.size() - 1; } for( int i = startPoint; i <= endPoint; ++i ) { Component * component = new Component(m_measures.at(i)); m_componentList->addComponent(component); } // make sure the header is expanded if(m_collapsibleComponentList->checkedCollapsibleComponent()){ m_collapsibleComponentList->checkedCollapsibleComponent()->setExpanded(true); } // select the first component if(m_componentList->firstComponent()){ m_componentList->firstComponent()->setChecked(true); } else{ emit noComponents(); } // check all the components for download upperPushButtonClicked(); }
// Note: don't call this directly if the "wait" screen is desired void BuildingComponentDialogCentralWidget::setTid(const std::string& filterType, int tid, int pageIdx, const QString & title, const QString & searchString) { if(m_tid != tid || m_searchString != searchString){ m_collapsibleComponentList->firstPage(); } m_filterType = filterType; m_tid = tid; m_searchString = searchString; //std::vector<Component *> components = m_collapsibleComponentList->components(); std::vector<Component *> components = m_componentList->components(); // TODO replace with code above for( auto & comp : components) { delete comp; } RemoteBCL remoteBCL; std::vector<BCLSearchResult> responses; if (filterType == "components") { responses = remoteBCL.searchComponentLibrary(searchString.toStdString(),tid,pageIdx); } else if (filterType == "measures") { responses = remoteBCL.searchMeasureLibrary(searchString.toStdString(),tid,pageIdx); } for( const auto & response : responses) { auto component = new Component(response); // TODO replace with a componentList owned by m_collapsibleComponentList m_componentList->addComponent(component); } // the parent taxonomy m_collapsibleComponentList->setText(title); // the total number of results int lastTotalResults = remoteBCL.lastTotalResults(); m_collapsibleComponentList->setNumResults(lastTotalResults); // the number of pages of results int numResultPages = remoteBCL.numResultPages(); m_collapsibleComponentList->setNumPages(numResultPages); // make sure the header is expanded if(m_collapsibleComponentList->checkedCollapsibleComponent()){ m_collapsibleComponentList->checkedCollapsibleComponent()->setExpanded(true); } // select the first component if(m_componentList->firstComponent()){ m_componentList->firstComponent()->setChecked(true); } else{ emit noComponents(); } emit componentsReady(); }