--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef CONTACTS_SETTINGS_NAME_FORMAT_ITEM_H
+#define CONTACTS_SETTINGS_NAME_FORMAT_ITEM_H
+
+#include "Ui/GenlistItem.h"
+#include <contacts_setting.h>
+
+namespace Contacts
+{
+ namespace Settings
+ {
+ /**
+ * @brief Name format item
+ */
+ class NameFormatItem : public Ui::GenlistItem
+ {
+ public:
+ /**
+ * @brief Create name format item.
+ */
+ NameFormatItem();
+ virtual ~NameFormatItem() override;
+
+ private:
+ virtual void onSelected() override;
+ virtual char *getText(Evas_Object *parent, const char *part) override;
+ static void onItemStateChanged(int type);
+ static void onNameOrderChanged(contacts_name_display_order_e name_sorting_order, void *user_data);
+ };
+ }
+}
+
+#endif /* CONTACTS_SETTINGS_NAME_FORMAT_ITEM_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef CONTACTS_SETTINGS_RADIO_POPUP_H
+#define CONTACTS_SETTINGS_RADIO_POPUP_H
+
+#include "Ui/Popup.h"
+#include <string>
+
+namespace Contacts
+{
+ namespace Settings
+ {
+ /**
+ * @brief Radio popup
+ */
+ class RadioPopup : public Ui::Popup
+ {
+ public:
+
+ /**
+ * @brief Selected item callback
+ * @param[in] Selected item value
+ */
+ typedef std::function<void(int)> SelectedCallback;
+
+ /**
+ * @brief Create Popup
+ * @param[in] callback Selected callback
+ */
+ RadioPopup(SelectedCallback callback = nullptr);
+
+ virtual ~RadioPopup();
+
+ /**
+ * @brief Add new item
+ * @param[in] text Item name
+ * @param[in] value Item value
+ */
+ void addItem(std::string text, int value);
+
+ /**
+ * @brief Set selected item
+ * @param[in] value Selected item value
+ */
+ void setSelectedItem(int value);
+
+ private:
+
+ virtual void onCreated() override;
+ Evas_Object *createGenlist(Evas_Object *parent);
+ Elm_Genlist_Item_Class *createItemClass();
+
+ static void onSelect(void *data, Evas_Object *obj, void *event_info);
+ static char *getItemText(void *data, Evas_Object *obj, const char *part);
+ static Evas_Object *getItemContent(void *data, Evas_Object *obj, const char *part);
+ static void delItem(void *data, Evas_Object *obj);
+
+ SelectedCallback m_Callback;
+ Evas_Object *m_Genlist;
+ Elm_Genlist_Item_Class *m_ItemClass;
+ Evas_Object *m_RadioGroup;
+ };
+ }
+}
+#endif /* CONTACTS_SETTINGS_RADIO_POPUP_H */
private:
virtual char *getText(Evas_Object *parent, const char *part) override;
virtual void onSelected() override;
+ static void onItemStateChanged(int type);
static void onSortingOrderChanged(contacts_name_sorting_order_e name_sorting_order, void *user_data);
};
}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef CONTACTS_SETTINGS_SORT_BY_POPUP_H
-#define CONTACTS_SETTINGS_SORT_BY_POPUP_H
-
-#include "Ui/Popup.h"
-
-namespace Contacts
-{
- namespace Settings
- {
- /**
- * @brief SortBy popup
- */
- class SortByPopup : public Ui::Popup
- {
- public:
- /**
- * @brief Create sortby popup.
- */
- SortByPopup();
-
- private:
- virtual void onCreated() override;
- Evas_Object *createGenlist(Evas_Object *parent);
- static void onSelect(void *data, Evas_Object *obj, void *event_info);
- static char *getItemText(void *data, Evas_Object *obj, const char *part);
- Elm_Genlist_Item_Class *createItemClass();
- static Evas_Object *getItemContent(void *data, Evas_Object *obj, const char *part);
-
- Evas_Object *m_RadioGroup;
- };
- }
-}
-#endif /* CONTACTS_SETTINGS_SORT_BY_POPUP_H */
#include "Contacts/Settings/MainView.h"
#include "Contacts/Settings/SortByItem.h"
+#include "Contacts/Settings/NameFormatItem.h"
#include "Ui/Genlist.h"
using namespace Contacts::Settings;
m_Genlist = new Ui::Genlist();
m_Genlist->create(parent);
m_Genlist->insert(new SortByItem());
+ m_Genlist->insert(new NameFormatItem());
return m_Genlist->getEvasObject();
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Contacts/Settings/NameFormatItem.h"
+#include "Contacts/Settings/RadioPopup.h"
+#include <app_i18n.h>
+
+using namespace Contacts::Settings;
+
+NameFormatItem::NameFormatItem()
+{
+ contacts_setting_add_name_display_order_changed_cb(onNameOrderChanged, this);
+}
+
+NameFormatItem::~NameFormatItem()
+{
+ contacts_setting_remove_name_display_order_changed_cb(onNameOrderChanged, this);
+}
+
+char *NameFormatItem::getText(Evas_Object *parent, const char *part)
+{
+ if (strcmp(part, "elm.text") == 0) {
+ return strdup(_("IDS_PB_TMBODY_NAME_FORMAT"));
+ } else if (strcmp(part, "elm.text.sub") == 0) {
+ contacts_name_display_order_e type = CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST;
+ contacts_setting_get_name_display_order(&type);
+
+ if (CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST == type) {
+ return strdup(_("IDS_PB_OPT_FIRST_NAME_FIRST_ABB"));
+ } else if (CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST == type) {
+ return strdup(_("IDS_PB_OPT_LAST_NAME_FIRST_ABB"));
+ }
+ }
+
+ return nullptr;
+}
+
+void NameFormatItem::onNameOrderChanged(contacts_name_display_order_e name_sorting_order, void *user_data)
+{
+ NameFormatItem *item = (NameFormatItem *)user_data;
+ elm_genlist_item_update(item->getObjectItem());
+}
+
+void NameFormatItem::onItemStateChanged(int type)
+{
+ contacts_setting_set_name_display_order((contacts_name_display_order_e) type);
+}
+
+void NameFormatItem::onSelected()
+{
+ contacts_name_display_order_e type = CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST;
+ contacts_setting_get_name_display_order(&type);
+
+ RadioPopup *popup = new RadioPopup(onItemStateChanged);
+ popup->create(elm_object_item_widget_get(getObjectItem()));
+ popup->setTitle("IDS_PB_TMBODY_NAME_FORMAT");
+ popup->setSelectedItem(type);
+ popup->addItem(("IDS_PB_OPT_FIRST_NAME_FIRST_ABB"), CONTACTS_NAME_DISPLAY_ORDER_FIRSTLAST);
+ popup->addItem(("IDS_PB_OPT_LAST_NAME_FIRST_ABB"), CONTACTS_NAME_DISPLAY_ORDER_LASTFIRST);
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Contacts/Settings/RadioPopup.h"
+#include "Utils/Logger.h"
+#include <app_i18n.h>
+
+using namespace Contacts::Settings;
+
+struct RadioItemData
+{
+ std::string text;
+ int value;
+};
+
+RadioPopup::RadioPopup(SelectedCallback callback)
+ : m_Callback(std::move(callback)), m_Genlist(nullptr), m_ItemClass(nullptr), m_RadioGroup(nullptr)
+{
+}
+
+RadioPopup::~RadioPopup()
+{
+ elm_genlist_item_class_free(m_ItemClass);
+}
+
+void RadioPopup::addItem(std::string text, int value)
+{
+ RadioItemData *itemData = new RadioItemData{ std::move(text), value };
+
+ elm_genlist_item_append(m_Genlist, m_ItemClass, itemData, nullptr,
+ ELM_GENLIST_ITEM_NONE, onSelect, this);
+}
+
+void RadioPopup::setSelectedItem(int value)
+{
+ elm_radio_value_set(m_RadioGroup, value);
+}
+
+void RadioPopup::onCreated()
+{
+ elm_popup_orient_set(getEvasObject(), ELM_POPUP_ORIENT_CENTER);
+ setContent(createGenlist(getEvasObject()));
+}
+
+Evas_Object *RadioPopup::createGenlist(Evas_Object *parent)
+{
+ m_Genlist = elm_genlist_add(parent);
+ elm_genlist_homogeneous_set(m_Genlist, EINA_TRUE);
+ elm_genlist_mode_set(m_Genlist, ELM_LIST_COMPRESS);
+ elm_scroller_content_min_limit(m_Genlist, EINA_FALSE, EINA_TRUE);
+
+ m_ItemClass = createItemClass();
+
+ m_RadioGroup = elm_radio_add(m_Genlist);
+
+ elm_radio_state_value_set(m_RadioGroup, -1);
+ evas_object_smart_data_set(m_Genlist, this);
+
+ return m_Genlist;
+}
+
+Elm_Genlist_Item_Class *RadioPopup::createItemClass()
+{
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ RETVM_IF(!itc, nullptr, "elm_genlist_item_class_new() failed");
+ itc->item_style = "type1";
+ itc->func.text_get = getItemText;
+ itc->func.content_get = getItemContent;
+ itc->func.del = delItem;
+ return itc;
+}
+
+void RadioPopup::onSelect(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+ RadioPopup *popup = static_cast<RadioPopup *>(data);
+ RadioItemData *itemData = static_cast<RadioItemData *>(elm_object_item_data_get(item));
+
+ elm_radio_value_set(popup->m_RadioGroup, itemData->value);
+
+ if (popup->m_Callback) {
+ popup->m_Callback(itemData->value);
+ }
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ delete popup;
+}
+
+char *RadioPopup::getItemText(void *data, Evas_Object *obj, const char *part)
+{
+ RadioItemData *itemData = static_cast<RadioItemData *>(data);
+
+ if (strcmp(part, "elm.text") == 0) {
+ return strdup(_(itemData->text.c_str()));
+ }
+ return nullptr;
+}
+
+Evas_Object *RadioPopup::getItemContent(void *data, Evas_Object *obj, const char *part)
+{
+ RadioItemData *itemData = static_cast<RadioItemData *>(data);
+ RadioPopup *popup = static_cast<RadioPopup *>(evas_object_smart_data_get(obj));
+
+ if (strcmp(part, "elm.swallow.end") == 0) {
+ Evas_Object *radio = elm_radio_add(obj);
+
+ elm_radio_group_add(radio, popup->m_RadioGroup);
+ elm_radio_state_value_set(radio, itemData->value);
+ return radio;
+ }
+ return nullptr;
+}
+
+void RadioPopup::delItem(void *data, Evas_Object *obj)
+{
+ RadioItemData *itemData = static_cast<RadioItemData *>(data);
+ delete itemData;
+}
*/
#include "Contacts/Settings/SortByItem.h"
-#include "Contacts/Settings/SortByPopup.h"
+#include "Contacts/Settings/RadioPopup.h"
#include "Utils/Logger.h"
#include <app_i18n.h>
void SortByItem::onSelected()
{
- Ui::Popup *popup = new SortByPopup();
+ contacts_name_sorting_order_e type = CONTACTS_NAME_SORTING_ORDER_FIRSTLAST;
+ contacts_setting_get_name_sorting_order(&type);
+
+ RadioPopup *popup = new RadioPopup(onItemStateChanged);
popup->create(elm_object_item_widget_get(getObjectItem()));
+ popup->setTitle("IDS_PB_MBODY_SORT_BY");
+ popup->setSelectedItem(type);
+ popup->addItem(("IDS_PB_OPT_FIRST_NAME"), CONTACTS_NAME_SORTING_ORDER_FIRSTLAST);
+ popup->addItem(("IDS_PB_OPT_LAST_NAME"), CONTACTS_NAME_SORTING_ORDER_LASTFIRST);
+}
+
+void SortByItem::onItemStateChanged(int type)
+{
+ contacts_setting_set_name_sorting_order((contacts_name_sorting_order_e) type);
}
void SortByItem::onSortingOrderChanged(contacts_name_sorting_order_e name_sorting_order, void *user_data)
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "Contacts/Settings/SortByPopup.h"
-#include "Utils/Logger.h"
-#include <app_i18n.h>
-#include <contacts_setting.h>
-
-using namespace Contacts::Settings;
-
-SortByPopup::SortByPopup()
- : m_RadioGroup(nullptr)
-{
-}
-
-void SortByPopup::onCreated()
-{
- elm_popup_orient_set(getEvasObject(), ELM_POPUP_ORIENT_CENTER);
- setTitle("IDS_PB_MBODY_SORT_BY");
- setContent(createGenlist(getEvasObject()));
-}
-
-Evas_Object *SortByPopup::createGenlist(Evas_Object *parent)
-{
- Evas_Object *genlist = elm_genlist_add(parent);
- elm_genlist_homogeneous_set(genlist, EINA_TRUE);
- elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
- elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
-
- Elm_Genlist_Item_Class *itc = createItemClass();
-
- m_RadioGroup = elm_radio_add(genlist);
- contacts_name_sorting_order_e type = CONTACTS_NAME_SORTING_ORDER_FIRSTLAST;
- contacts_setting_get_name_sorting_order(&type);
- elm_radio_state_value_set(m_RadioGroup, type);
- evas_object_smart_data_set(genlist, this);
-
- elm_genlist_item_append(genlist, itc, (void *) CONTACTS_NAME_SORTING_ORDER_FIRSTLAST, NULL,
- ELM_GENLIST_ITEM_NONE, onSelect, this);
- elm_genlist_item_append(genlist, itc, (void *) CONTACTS_NAME_SORTING_ORDER_LASTFIRST, NULL,
- ELM_GENLIST_ITEM_NONE, onSelect, this);
-
- elm_genlist_item_class_free(itc);
- return genlist;
-}
-
-void SortByPopup::onSelect(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *item = (Elm_Object_Item *) event_info;
- int type = (int) elm_object_item_data_get(item);
- SortByPopup *popup = static_cast<SortByPopup *>(data);
- elm_radio_value_set(popup->m_RadioGroup, type);
-
- contacts_setting_set_name_sorting_order((contacts_name_sorting_order_e) type);
-
- elm_genlist_item_selected_set(item, EINA_FALSE);
- elm_genlist_item_update(item);
-}
-
-char *SortByPopup::getItemText(void *data, Evas_Object *obj, const char *part)
-{
- int type = (int) data;
- if (strcmp(part, "elm.text") == 0) {
- if (CONTACTS_NAME_SORTING_ORDER_FIRSTLAST == type) {
- return strdup(_("IDS_PB_OPT_FIRST_NAME"));
- } else if (CONTACTS_NAME_SORTING_ORDER_LASTFIRST == type) {
- return strdup(_("IDS_PB_OPT_LAST_NAME"));
- }
- }
- return nullptr;
-}
-
-Elm_Genlist_Item_Class *SortByPopup::createItemClass()
-{
- Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
- RETVM_IF(!itc, NULL, "elm_genlist_item_class_new() failed");
- itc->item_style = "type1";
- itc->func.text_get = getItemText;
- itc->func.content_get = getItemContent;
- return itc;
-}
-
-Evas_Object *SortByPopup::getItemContent(void *data, Evas_Object *obj, const char *part)
-{
- SortByPopup *popup = static_cast<SortByPopup *>(evas_object_smart_data_get(obj));
-
- if (strcmp(part, "elm.swallow.end") == 0) {
- int type = (int) data;
- Evas_Object *radio = elm_radio_add(obj);
-
- elm_radio_group_add(radio, popup->m_RadioGroup);
- elm_radio_state_value_set(radio, type);
-
- return radio;
- }
- return nullptr;
-}
}
/* FIXME: Added for 2.4 SDK build */
-extern "C" Eina_List *elm_layout_content_swallow_list_get(Evas_Object *obj);
+extern "C" Eina_List *elm_layout_content_swallow_list_get(const Evas_Object *obj);
SearchResultsControl::SearchResultsControl()
: m_Results(nullptr), m_State(ResultsNone),