*/
void setUpdateCallback(UpdateCallback callback);
+ /**
+ * @brief Update section content manually
+ */
+ void update();
+
protected:
void onInserted(::Model::DataItem &person);
ContactItem *createItem(Model::Person &person);
{
public:
/**
+ * @brief Notifies that Mfc contacts were updated
+ */
+ typedef std::function<void()> MfcUpdateCallback;
+
+ /**
* @brief Creates new popup
* @param[in] navigator Current navigator. Is needed to move to the next view.
*/
ManageFavoritesPopup(Ui::Navigator *navigator);
+ /**
+ * @brief Set Mfc update callback
+ * @param[in] callback Mfc update callback
+ */
+ void setMfcUpdateCallback(MfcUpdateCallback callback);
+
protected:
/**
* @see Control::onCreated()
void onRemove();
Ui::Navigator *m_Navigator;
+ MfcUpdateCallback m_OnMfcUpdated;
};
}
}
#include "Contacts/List/ReorderItem.h"
#include "Contacts/List/Model/Person.h"
#include "Contacts/List/Model/PersonProvider.h"
-#include "Utils/Logger.h"
#include <app_i18n.h>
m_OnUpdated = std::move(callback);
}
+void ListSection::update()
+{
+ m_Provider->reload();
+}
+
char *ListSection::getText(Evas_Object *parent, const char *part)
{
if (strcmp(part, "elm.text") == 0) {
menu->addItem("IDS_PB_OPT_SHARE", std::bind(&ListView::onShareSelected, this));
menu->addItem("IDS_PB_OPT_MANAGE_FAVOURITES_ABB", [this] {
auto manageFavPopup = new ManageFavoritesPopup(getNavigator());
+ manageFavPopup->setMfcUpdateCallback([this] {
+
+ if (m_Sections[SectionMfc]) {
+ static_cast<ListSection *>(m_Sections[SectionMfc])->update();
+ } else {
+ createSection(SectionMfc);
+ }
+ });
+
manageFavPopup->create(getEvasObject());
});
}
{
}
+void ManageFavoritesPopup::setMfcUpdateCallback(MfcUpdateCallback callback)
+{
+ m_OnMfcUpdated = std::move(callback);
+}
+
void ManageFavoritesPopup::onCreated()
{
ListPopup::onCreated();
//todo Should be created ListView with Favorites and MFC sections only
ListView *view = new ListView();
view->setSelectMode(Ux::SelectMulti);
- view->setSelectCallback([](Ux::SelectResults results) {
+ //todo Implement separate controller to handle callback, because object is destroyed after popup close.
+ auto &onMfcUpdated = m_OnMfcUpdated;
+ view->setSelectCallback([onMfcUpdated](Ux::SelectResults results) {
+
+ bool isMfcUpdated = false;
contacts_list_h list = nullptr;
contacts_list_create(&list);
for (auto &&result : results) {
contacts_record_set_bool(record, _contacts_person.is_favorite, false);
contacts_list_add(list, record);
} else {
+ isMfcUpdated = true;
contacts_person_reset_usage(recordId, CONTACTS_USAGE_STAT_TYPE_OUTGOING_CALL);
contacts_person_reset_usage(recordId, CONTACTS_USAGE_STAT_TYPE_INCOMING_CALL);
contacts_record_destroy(record, true);
contacts_db_update_records(list);
contacts_list_destroy(list, true);
+ if (isMfcUpdated && onMfcUpdated) {
+ onMfcUpdated();
+ }
+
return true;
});
m_Navigator->navigateTo(view);