{
namespace Model
{
- class ContactData;
-
- typedef std::unique_ptr<ContactData> ContactDataPtr;
- typedef std::list<ContactData *> ContactDataList;
-
class EXPORT_API ContactData
{
public:
class EXPORT_API ContactDataProvider
{
public:
+ typedef std::list<ContactData *> DataList;
+
/**
* @brief Insert callback
* @param[in] Contact data
/**
* @return Contact data list
*/
- virtual const ContactDataList &getContactDataList() = 0;
+ virtual const DataList &getDataList() = 0;
/**
* @brief Clear contact data list
*/
- virtual void clearContactDataList() { }
+ virtual void clearDataList() { }
/**
* @brief Set insert callback
virtual ~ContactRecordProvider() override;
/**
- * @see ContactDataProvider::getContactDataList()
+ * @see ContactDataProvider::getDataList()
*/
- virtual const ContactDataList &getContactDataList() override;
+ virtual const DataList &getDataList() override;
/**
- * @see ContactDataProvider::clearContactDataList()
+ * @see ContactDataProvider::clearDataList()
*/
- virtual void clearContactDataList() override;
+ virtual void clearDataList() override;
protected:
using ContactDataProvider::onInserted;
/**
* @return contact list
*/
- const ContactDataList &getContactList();
+ const DataList &getContactList();
/**
* @brief Contact inserted callback
* @param[in] id Contact ID
* @param[in] changeType Contact change type (Updated/Deleted)
*/
- void onChanged(ContactDataList::iterator contactIt, int id, contacts_changed_e changeType);
+ void onChanged(DataList::iterator contactIt, int id, contacts_changed_e changeType);
private:
/**
*/
virtual bool shouldUpdateChangedCallback() { return false; }
- void updateChangedCallback(ContactDataList::iterator it);
+ void updateChangedCallback(DataList::iterator it);
DbChangeObserver::CallbackHandle m_Handle;
- ContactDataList m_ContactList;
+ DataList m_ContactList;
};
}
}
#ifndef PHONE_DIALER_SEARCH_ENGINE_H
#define PHONE_DIALER_SEARCH_ENGINE_H
-#include "Contacts/Model/ContactData.h"
+#include "Contacts/Model/ContactDataProvider.h"
#include <string>
#include <vector>
class SearchEngine
{
public:
+ typedef ContactDataProvider::DataList DataList;
+
explicit SearchEngine(SearchProvider &searchProvider);
/**
* @brief Retrieves result list
* @return Result list or nullptr on empty list
*/
- const ContactDataList *getSearchResult() const;
+ const DataList *getSearchResult() const;
/**
* @return true if there is no results, otherwise false
bool empty() const;
private:
- typedef std::vector<ContactDataList> SearchHistory;
+ typedef std::vector<DataList> SearchHistory;
void firstSearch(const std::string &query);
void chooseSearch(const std::string &query);
virtual ~SearchProvider() override;
/**
- * @see ContactDataProvider::getContactDataList()
+ * @see ContactDataProvider::getDataList()
*/
- virtual const ContactDataList &getContactDataList() override;
+ virtual const DataList &getDataList() override;
/**
* @brief Add @a provider to search provider
void addProvider(ContactDataProvider *provider);
private:
- typedef std::unordered_map<ContactDataProvider *, ContactDataList::const_iterator> SubProviders;
+ typedef std::unordered_map<ContactDataProvider *, DataList::const_iterator> SubProviders;
using ContactDataProvider::onInserted;
- ContactData &insertContact(ContactDataList::const_iterator position, ContactData &contact,
+ ContactData &insertContact(DataList::const_iterator position, ContactData &contact,
ContactDataProvider *provider);
void onInserted(ContactData &contactData, ContactDataProvider *provider);
void onUpdated(SearchData &searchData, int changes);
- void onDeleted(ContactDataList::iterator contactIt, ContactDataProvider *provider);
+ void onDeleted(DataList::iterator contactIt, ContactDataProvider *provider);
- ContactDataList m_ContactList;
+ DataList m_ContactList;
SubProviders m_SubProviders;
};
}
}
}
-const ContactDataList &ContactRecordProvider::getContactDataList()
+const ContactRecordProvider::DataList &ContactRecordProvider::getDataList()
{
if (!m_ContactList.empty()) {
return m_ContactList;
return m_ContactList;
}
-void ContactRecordProvider::clearContactDataList()
+void ContactRecordProvider::clearDataList()
{
for (auto &&contact : m_ContactList) {
delete contact;
return record;
}
-const ContactDataList &ContactRecordProvider::getContactList()
+const ContactRecordProvider::DataList &ContactRecordProvider::getContactList()
{
return m_ContactList;
}
}
}
-void ContactRecordProvider::onChanged(ContactDataList::iterator contactIt, int id, contacts_changed_e changeType)
+void ContactRecordProvider::onChanged(DataList::iterator contactIt, int id, contacts_changed_e changeType)
{
auto contact = static_cast<ContactRecordData *>(*contactIt);
delete contact;
}
-void ContactRecordProvider::updateChangedCallback(ContactDataList::iterator it)
+void ContactRecordProvider::updateChangedCallback(DataList::iterator it)
{
auto contactData = static_cast<ContactRecordData *>(*it);
m_Query = query;
}
-const ContactDataList *SearchEngine::getSearchResult() const
+const SearchEngine::DataList *SearchEngine::getSearchResult() const
{
if (!m_Cache.empty()) {
return &m_Cache.back();
{
clear();
- const ContactDataList searchList = m_SearchProvider.getContactDataList();
-
+ auto &searchList = m_SearchProvider.getDataList();
if (!searchList.empty()) {
m_Cache.resize(query.size());
m_Cache.front() = std::move(searchList);
bool SearchEngine::searchInCache(SearchHistory::iterator from, const std::string &query)
{
- ContactDataList searchRes;
+ DataList searchRes;
/* for (auto &&contactData : *from) { Todo: Compare
} */
}
}
-const ContactDataList &SearchProvider::getContactDataList()
+const SearchProvider::DataList &SearchProvider::getDataList()
{
return m_ContactList;//Todo: Return filtered list by search engine instead of all contacts
}
void SearchProvider::addProvider(ContactDataProvider *provider)
{
- const ContactDataList &list = provider->getContactDataList();
+ const DataList &list = provider->getDataList();
for (auto it = list.begin(); it != list.end(); ++it) {
insertContact(m_ContactList.end(), **it, provider);
}
});
}
-ContactData &SearchProvider::insertContact(ContactDataList::const_iterator position, ContactData &contact,
+ContactData &SearchProvider::insertContact(DataList::const_iterator position, ContactData &contact,
ContactDataProvider *provider)
{
auto searchData = new SearchData(contact);
auto newDataIt = m_ContactList.insert(position, searchData);
- ContactDataList::iterator contactIt = --m_ContactList.end();
+ DataList::iterator contactIt = --m_ContactList.end();
contact.setUpdateCallback(std::bind(&SearchProvider::onUpdated, this, std::ref(*searchData), _1));
contact.setDeleteCallback(std::bind(&SearchProvider::onDeleted, this, contactIt, provider));
searchData.onUpdated(changes);
}
-void SearchProvider::onDeleted(ContactDataList::iterator contactIt, ContactDataProvider *provider)
+void SearchProvider::onDeleted(DataList::iterator contactIt, ContactDataProvider *provider)
{
SearchData *searchData = static_cast<SearchData *>(*contactIt);
searchData->onDeleted();
delete searchData;
- ContactDataList::const_iterator newBound = m_ContactList.erase(contactIt);
+ DataList::const_iterator newBound = m_ContactList.erase(contactIt);
- ContactDataList::const_iterator &oldBound = m_SubProviders[provider];
+ DataList::const_iterator &oldBound = m_SubProviders[provider];
if (oldBound == contactIt) {
oldBound = Utils::advance(newBound, -1);
}
* @brief Get person list
* @return List of contact objects
*/
- virtual const Contacts::Model::ContactDataList &getContactDataList() override;
+ virtual const DataList &getDataList() override;
protected:
/**
VcardProvider &operator=(const VcardProvider &contact) = delete;
/**
- * @see ContactDataProvider::getContactDataList()
+ * @see ContactDataProvider::getDataList()
* @return Contact data list
*/
- virtual const Contacts::Model::ContactDataList &getContactDataList() override;
+ virtual const DataList &getDataList() override;
private:
- Contacts::Model::ContactDataList m_ContactsList;
+ DataList m_ContactsList;
};
}
}
delete personGroup.second;
}
view->m_PersonGroups.clear();
- view->m_Provider.clearContactDataList();
+ view->m_Provider.clearDataList();
elm_index_item_clear(view->m_Index);
elm_index_level_go(view->m_Index, 0);
if (m_PersonGroups.empty()) {
PersonGroupItem *group = nullptr;
- for (auto &&contactData : m_Provider.getContactDataList()) {
+ for (auto &&contactData : m_Provider.getDataList()) {
Person &person = static_cast<Person &>(*contactData);
const UniString &nextLetter = person.getIndexLetter();
void ListView::updateNoContentLayout()
{
- ContactDataList list = m_Provider.getContactDataList();
- list.size() > 0 ? hideNoContentLayout() : showNoContentLayout();
+ m_Provider.getDataList().size() > 0 ? hideNoContentLayout() : showNoContentLayout();
}
void ListView::setFavouriteItemsMode(SelectMode selectMode)
makeCallbackWithLastParam(&PersonProvider::onNameFormatChanged), this);
}
-const ContactDataList &PersonProvider::getContactDataList()
+const PersonProvider::DataList &PersonProvider::getDataList()
{
auto &contactList = getContactList();
if (!contactList.empty()) {
void PersonProvider::onNameFormatChanged(contacts_name_display_order_e order)
{
- for (auto &&contactData : getContactDataList()) {
+ for (auto &&contactData : getDataList()) {
Person *person = static_cast<Person *>(contactData);
person->update();
}
{
int err = contacts_vcard_parse_to_contact_foreach(vcardPath.c_str(), [](contacts_record_h record, void *data)->bool {
RETVM_IF(!record || !data, true, "invalid data");
- ContactDataList *list = (ContactDataList *)data;
+ DataList *list = (DataList *)data;
contacts_record_h recordClone;
contacts_record_clone(record, &recordClone);
}
}
-const ContactDataList &VcardProvider::getContactDataList()
+const VcardProvider::DataList &VcardProvider::getDataList()
{
return m_ContactsList;
}
m_Genlist = new Ui::Genlist();
m_Genlist->create(parent);
- for (auto &&contact : m_Provider.getContactDataList()) {
+ for (auto &&contact : m_Provider.getDataList()) {
ContactItem *item = new ContactItem(static_cast<ContactRecordData &>(*contact));
m_Genlist->insert(item);
onItemInserted(item);
/**
* @brief Log iterator.
*/
- typedef Contacts::Model::ContactDataList::iterator LogIterator;
+ typedef DataList::iterator LogIterator;
/**
* @brief Group iterator.
* @brief Get log group list
* @return List of log group objects
*/
- virtual const Contacts::Model::ContactDataList &getContactDataList() override;
+ virtual const DataList &getDataList() override;
/**
* @brief Reset log group list
int m_DbVersion;
LogGroupList m_Groups;
- Contacts::Model::ContactDataList m_Logs;
+ DataList m_Logs;
InsertCallback m_InsertCallback;
};
return m_Groups;
}
-const Contacts::Model::ContactDataList &LogProvider::getContactDataList()
+const LogProvider::DataList &LogProvider::getDataList()
{
if (m_Logs.empty()) {
fillList();