|
#include <algorithm>
|
|
|
|
#include "Catalog.h"
|
|
|
|
Catalog::Catalog()
|
|
{
|
|
// Temporarily fill the catalog with some test data
|
|
/*
|
|
{"Target", "baranovich@gmail.com\nF-B-3-7"},
|
|
{"United", "david.sorber@gmail.com\nF-B-3-7"},
|
|
{"Pepco", "david.sorber@gmail.com\nNZ-98-O"},
|
|
{"Washington Gas", "baranovich@gmail.com\nS-N-718"}
|
|
*/
|
|
m_catalog.push_back({"Target", "baranovich@gmail.com\nF-B-3-7"});
|
|
m_catalog.push_back({"United", "david.sorber@gmail.com\nF-B-3-7"});
|
|
m_catalog.push_back({"Pepco", "david.sorber@gmail.com\nNZ-98-O"});
|
|
m_catalog.push_back({"Washington Gas", "baranovich@gmail.com\nS-N-718"});
|
|
|
|
// Sort the catalog (A -> Z) for display purposes
|
|
std::sort(
|
|
m_catalog.begin(),
|
|
m_catalog.end(),
|
|
[](auto const& lhs, auto const& rhs)
|
|
{
|
|
return lhs.getLcKey() < rhs.getLcKey();
|
|
});
|
|
|
|
}
|
|
|
|
Catalog::~Catalog()
|
|
{
|
|
}
|
|
|
|
void Catalog::setAllVisible()
|
|
{
|
|
for (auto& item : m_catalog)
|
|
{
|
|
item.setVisibilty(true);
|
|
}
|
|
}
|
|
|
|
void Catalog::filter(const std::string& criteria)
|
|
{
|
|
// TODO: would be nice if there were a more efficient way to do this
|
|
for (auto& item : m_catalog)
|
|
{
|
|
if (item.match(criteria))
|
|
{
|
|
item.setVisibilty(true);
|
|
}
|
|
else
|
|
{
|
|
item.setVisibilty(false);
|
|
}
|
|
}
|
|
}
|