bool Query::set(int index, const Search& search) { if (!isValidIndex(index)) return false; int subindex = m_searchMap.indexOf(index); if (subindex >= 0) { delete m_search.at(subindex); m_search.replace(subindex, search.clone()); return true; } else { subindex = m_operatorMap.indexOf(index); if (subindex >= 0) { // Here the given index is a operator, so we have to remove the operator, // and add a search at that position m_operatorMap.removeAt(m_operatorMap.at(subindex)); m_operator.removeAt(m_operator.at(subindex)); m_search.append(search.clone()); m_searchMap.append(index); m_elementType[index] = SearchElement; return true; } else { // The index could not be found in the operator or search lists return false; } } }
void Query::append(const Search& search) { m_search.append(search.clone()); m_searchMap.append(m_elementType.count()); m_elementType.append(SearchElement); }