#ifndef CONTACTS_LIST_LIST_VIEW_H
#define CONTACTS_LIST_LIST_VIEW_H
-#include "Contacts/List/Model/PersonProvider.h"
+#include "Contacts/Common/ContactSelectTypes.h"
#include "Contacts/SelectView.h"
#include "Utils/UniString.h"
namespace Contacts
{
+ namespace Model
+ {
+ class ContactData;
+ class ContactDataProvider;
+ }
+
namespace List
{
class GroupItem;
* @param]in] filterType Defines how to filter person list
*/
ListView(int filterType = FilterNone);
+
+ /**
+ * @brief Create new vcard contact list view
+ * @param]in] vcardPath Path of the vcard file
+ */
+ explicit ListView(const char *vcardPath);
+
virtual ~ListView() override;
private:
void deletePersonGroupItem(PersonGroupItem *group);
PersonGroupItem *getNextPersonGroupItem(const Utils::UniString &indexLetter);
- PersonItem *createPersonItem(Model::Person &person);
+ PersonItem *createPersonItem(Contacts::Model::ContactData &person);
void insertPersonItem(PersonItem *item);
void updatePersonItem(PersonItem *item, int changes);
void deletePersonItem(PersonItem *item);
Ui::GenlistGroupItem *m_Sections[SectionMax];
std::map<Utils::UniString, PersonGroupItem *> m_PersonGroups;
- Model::PersonProvider m_Provider;
+ Contacts::Model::ContactDataProvider *m_Provider;
+
+ bool m_HasIndex;
};
}
}
#include "Contacts/List/ListView.h"
#include "Contacts/List/GroupItem.h"
#include "Contacts/List/Model/Person.h"
+#include "Contacts/List/Model/PersonProvider.h"
+#include "Contacts/List/Model/VcardProvider.h"
#include "Contacts/List/MyProfileItem.h"
#include "Contacts/List/PersonGroupItem.h"
#include "Contacts/List/PersonItem.h"
ListView::ListView(int filterType)
: m_Genlist(nullptr), m_Index(nullptr), m_AddButton(nullptr),
- m_Sections{ nullptr },
- m_Provider(filterType)
+ m_Sections{ nullptr }, m_HasIndex(true)
{
+ m_Provider = new PersonProvider(filterType);
+}
+
+ListView::ListView(const char *vcardPath)
+ : m_Genlist(nullptr), m_Index(nullptr), m_AddButton(nullptr),
+ m_Sections{ nullptr }, m_HasIndex(false)
+{
+ m_Provider = new VcardProvider(vcardPath);
}
ListView::~ListView()
{
- m_Provider.unsetInsertCallback();
+ m_Provider->unsetInsertCallback();
+ delete m_Provider;
contacts_db_remove_changed_cb(_contacts_my_profile._uri,
makeCallbackWithLastParam(&ListView::updateMyProfileItem), this);
}
elm_object_part_content_set(layout, "elm.swallow.content", m_Genlist->getEvasObject());
elm_object_part_content_set(layout, "elm.swallow.fastscroll", createIndex(layout));
+ const char *signal = m_HasIndex ? "elm,state,fastscroll,show" : "elm,state,fastscroll,hide";
+ elm_layout_signal_emit(layout, signal, "");
+
return layout;
}
{
updateSectionsMode();
- m_Provider.setInsertCallback(std::bind(&ListView::onPersonInserted, this, _1));
+ m_Provider->setInsertCallback(std::bind(&ListView::onPersonInserted, this, _1));
contacts_db_add_changed_cb(_contacts_my_profile._uri,
makeCallbackWithLastParam(&ListView::updateMyProfileItem), this);
}
menu->addItem("IDS_PB_OPT_SETTINGS", [this] {
getNavigator()->navigateTo(new Settings::MainView());
});
+
menu->show();
}
void ListView::fillPersonList()
{
if (m_PersonGroups.empty()) {
- ContactDataList list = m_Provider.getContactDataList();
+ ContactDataList list = m_Provider->getContactDataList();
PersonGroupItem *group = nullptr;
for (auto &&contactData : list) {
- auto person = static_cast<Person *>(contactData);
- const UniString &nextLetter = person->getIndexLetter();
-
- if (!group || group->getTitle() != nextLetter) {
- group = insertPersonGroupItem(nextLetter);
+ const UniString *nextLetter = contactData->getIndexLetter();
+ if (nextLetter) {
+ if (!group || group->getTitle() != *nextLetter) {
+ group = insertPersonGroupItem(*nextLetter);
+ }
}
- auto item = createPersonItem(*person);
+ auto item = createPersonItem(*contactData);
m_Genlist->insert(item, group);
onItemInserted(item);
}
return nullptr;
}
-PersonItem *ListView::createPersonItem(Person &person)
+PersonItem *ListView::createPersonItem(ContactData &person)
{
PersonItem *item = new PersonItem(person);
person.setUpdateCallback(std::bind(&ListView::onPersonUpdated, this, item, _1));
{
PersonGroupItem *group = nullptr;
PersonItem *nextItem = nullptr;
- const UniString &indexLetter = item->getPerson().getIndexLetter();
- auto it = m_PersonGroups.find(indexLetter);
- if (it != m_PersonGroups.end()) {
- group = it->second;
- nextItem = getNextPersonItem(it->second, item->getPerson());
- } else {
- PersonGroupItem *nextGroup = getNextPersonGroupItem(indexLetter);
- group = insertPersonGroupItem(indexLetter, nextGroup);
+ const UniString *indexLetter = item->getPerson().getIndexLetter();
+ if (indexLetter) {
+ auto it = m_PersonGroups.find(*indexLetter);
+ if (it != m_PersonGroups.end()) {
+ group = it->second;
+ nextItem = getNextPersonItem(it->second, static_cast<Person &>(item->getPerson()));
+ } else {
+ PersonGroupItem *nextGroup = getNextPersonGroupItem(*indexLetter);
+ group = insertPersonGroupItem(*indexLetter, nextGroup);
+ }
}
m_Genlist->insert(item, group, nextItem);
{
for (auto &&item : *group) {
PersonItem *personItem = static_cast<PersonItem *>(item);
- if (person < personItem->getPerson()) {
+ if (person < static_cast<Person &>(personItem->getPerson())) {
return personItem;
}
}
void ListView::onItemPressed(SelectItem *item)
{
PersonItem *personItem = static_cast<PersonItem *>(item);
- int id = personItem->getPerson().getDisplayContactId();
+ int id = static_cast<Person &>(personItem->getPerson()).getDisplayContactId();
getNavigator()->navigateTo(new Details::DetailsView(id));
}
void ListView::onPersonInserted(ContactData &person)
{
- auto item = createPersonItem(static_cast<Person &>(person));
+ auto item = createPersonItem(person);
insertPersonItem(item);
onItemInserted(item);
}
*
*/
+#include "Contacts/Model/ContactRecordData.h"
#include "Contacts/List/PersonItem.h"
#include "Contacts/Common/ContactSelectTypes.h"
-#include "Contacts/List/Model/Person.h"
#include "Ui/Thumbnail.h"
#include <app_i18n.h>
using namespace Contacts;
using namespace Contacts::List;
-using namespace Contacts::List::Model;
+using namespace Contacts::Model;
-PersonItem::PersonItem(Person &person)
+PersonItem::PersonItem(ContactData &person)
: m_Person(person)
-{ }
+{
+}
-Person &PersonItem::getPerson()
+ContactData &PersonItem::getPerson()
{
return m_Person;
}
SelectResult PersonItem::getDefaultResult() const
{
- return { ResultPerson, m_Person.getId() };
+ if (m_Person.getType() == ContactData::TypeContact) {
+ return { ResultPerson, (void *)static_cast<ContactRecordData &>(m_Person).getContactRecord() };
+ } else {
+ return { ResultPerson, m_Person.getId() };
+ }
}