@@ -199,31 +199,25 @@ std::vector<openstudio::BCLSearchResult> BuildingComponentDialogCentralWidget::f
199
199
void BuildingComponentDialogCentralWidget::setTid (const std::string& filterType, int tid, int pageIdx, const QString& title,
200
200
const QString& searchString) {
201
201
202
- if (m_tid != tid || m_searchString != searchString) {
202
+ if (m_tid != tid || m_searchString != searchString || m_filterType != filterType ) {
203
203
m_collapsibleComponentList->firstPage ();
204
+ m_allResponses = fetchAndSortResponses (filterType, tid, searchString);
204
205
}
205
206
207
+ m_searchString = searchString;
206
208
m_filterType = filterType;
207
-
208
209
m_tid = tid;
209
210
210
- m_searchString = searchString;
211
-
212
- // std::vector<Component *> components = m_collapsibleComponentList->components();
211
+ // Clear existing components
213
212
std::vector<Component*> components = m_componentList->components (); // TODO replace with code above
214
-
215
213
for (auto & comp : components) {
216
214
delete comp;
217
215
}
218
216
219
- if (pageIdx == 0 || m_allResponses.empty ()) {
220
- m_allResponses = fetchAndSortResponses (filterType, tid, searchString);
221
- }
222
-
223
217
// Paginate responses
224
218
int itemsPerPage = 10 ; // Assuming 10 items per page
225
219
size_t startIdx = pageIdx * itemsPerPage;
226
- size_t endIdx = std::min (startIdx + itemsPerPage, static_cast < int >( m_allResponses.size () ));
220
+ size_t endIdx = std::min (startIdx + itemsPerPage, m_allResponses.size ());
227
221
std::vector<BCLSearchResult> paginatedResponses (m_allResponses.begin () + startIdx, m_allResponses.begin () + endIdx);
228
222
229
223
for (const auto & response : paginatedResponses) {
0 commit comments