Refactored selection ResultType to suit App Control purposes.
Change-Id: Id4295292566b057da58cfb9910892618edae19bc
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
*/
enum FilterType
{
- FilterNone = -1, /**< All items are displayed */
+ FilterNone = -1, /**< All items are displayed */
FilterNumber = 1 << Model::FieldNumber, /**< Only items with number */
- FilterEmail = 1 << Model::FieldEmail /**< Only items with email */
+ FilterEmail = 1 << Model::FieldEmail /**< Only items with email */
};
/**
*/
enum ResultType
{
- ResultNone, /**< Selection is disabled */
- ResultItem, /**< Item itself is the result */
- ResultAction /**< Action associated with the item is the result */
- };
-
- /**
- * @brief Type of the selected item for #ResultItem result type.
- */
- enum ItemType
- {
- ItemPerson = Model::ObjectTypeContact, /**< Person ID is the result */
- ItemNumber = Model::ObjectTypeNumber, /**< Number ID is the result */
- ItemEmail = Model::ObjectTypeEmail /**< Email ID is the result */
- };
-
- /**
- * @brief Action associated with selected item for #ResultAction result type.
- */
- enum ActionType
- {
- ActionCall, /**< Number ID for telephony call is the result */
- ActionMessage, /**< Number ID for message is the result */
- ActionEmail /**< Email ID for recipient is the result */
+ ResultMyProfile = Model::ObjectTypeMyProfile, /**< My Profile ID is the result */
+ ResultPerson = Model::ObjectTypeContact, /**< Person ID is the result */
+ ResultNumber = Model::ObjectTypeNumber, /**< Number ID is the result */
+ ResultEmail = Model::ObjectTypeEmail /**< Email ID is the result */
};
/**
*/
struct SelectResult
{
- unsigned type; /**< @ref ItemType or @ref ActionType depending on @ref ResultType. */
+ unsigned type; /**< @ref ResultType. */
int itemId; /**< Item database ID (for _contacts_person, _contacts_number or _contacts_email). */
};
public:
enum ActionId
{
- ActionCall = Contacts::ActionCall, /**< Make a telephony call using value as a number */
- ActionMessage = Contacts::ActionMessage, /**< Compose an SMS using value as recipient */
- ActionEmail = Contacts::ActionEmail, /**< Compose an E-mail using value as an address */
- ActionUrl /**< Open webpage in browser using value as URL */
+ ActionCall, /**< Make a telephony call using value as a number */
+ ActionMessage, /**< Compose an SMS using value as recipient */
+ ActionEmail, /**< Compose an E-mail using value as an address */
+ ActionUrl /**< Open webpage in browser using value as URL */
};
/**
ActionFieldItem(Model::ContactObject &object, ActionId actionId);
protected:
- using FieldItem::onSelected;
-
/**
* @see GenlistItem::getContent()
*/
Evas_Object *createActionButton(Evas_Object *parent, ActionId actionId);
private:
- void showActionPopup();
void executeAction(ActionId actionId);
void onButtonPressed(Evas_Object *button, void *eventInfo);
/**
* @brief Set selection mode and result type.
* @param[in] mode Selection mode
- * @param[in] type Selection result type
*/
- void setSelectMode(SelectMode mode, ResultType type = ResultItem);
+ void setSelectMode(SelectMode mode);
private:
virtual Evas_Object *onCreate(Evas_Object *parent) override;
int m_FilterType;
SelectMode m_SelectMode;
- ResultType m_ResultType;
SelectCallback m_OnSelected;
Evas_Object *m_DoneButton;
/**
* @brief Set item selection mode and result type.
* @param[in] mode Selection mode
- * @param[in] type Selection result type
*/
- void setSelectMode(SelectMode mode, ResultType type);
+ void setSelectMode(SelectMode mode);
/**
* @brief Set selection callback.
*/
SelectMode getSelectMode() const;
- /**
- * @return Item selection result type.
- */
- ResultType getResultType() const;
-
protected:
friend class DetailsView;
*/
virtual void onSelected() override;
- /**
- * @brief Should be called to report selection result.
- * @param[in] resultType Selection result type
- */
- void onSelected(unsigned resultType);
-
/**
* @see ContactField::UpdatedCallback
*/
Model::ContactField &m_Field;
SelectMode m_SelectMode;
- ResultType m_ResultType;
-
SelectCallback m_OnSelected;
};
}
{
if (getSelectMode() == SelectNone) {
executeAction(m_ActionId);
- } else if (getSelectMode() == SelectSingle && getResultType() == ResultAction) {
- if (m_ActionId == ActionCall) {
- showActionPopup();
- } else {
- onSelected(m_ActionId);
- }
} else {
TypedFieldItem::onSelected();
}
}
-void ActionFieldItem::showActionPopup()
-{
- Ui::ListPopup *popup = new Ui::ListPopup();
- popup->create(getParent()->getEvasObject());
- popup->setTitle(getField().cast<ContactTextField>().getValue());
- popup->addItem("IDS_PB_OPT_VOICE_CALL", (void *) ActionCall);
- popup->addItem("IDS_PB_OPT_MESSAGE", (void *) ActionMessage);
- popup->setSelectedCallback([this](void *data) {
- onSelected((unsigned long) data);
- });
-}
-
Evas_Object *ActionFieldItem::createActionButton(Evas_Object *parent, ActionId actionId)
{
static const int imageSize = Ui::getScaledValue(BTN_WH);
DetailsView::DetailsView(int recordId, Type type, int filterType)
: m_RecordId(recordId), m_Contact(ContactObjectType(type)),
- m_FilterType(filterType), m_SelectMode(SelectNone), m_ResultType(ResultNone),
+ m_FilterType(filterType), m_SelectMode(SelectNone),
m_DoneButton(nullptr), m_CancelButton(nullptr),
m_Genlist(nullptr), m_BasicInfoItem(nullptr), m_Items{nullptr}, m_SelectCount(0)
{
m_OnSelected = std::move(callback);
}
-void DetailsView::setSelectMode(SelectMode mode, ResultType type)
+void DetailsView::setSelectMode(SelectMode mode)
{
m_SelectMode = mode;
- m_ResultType = type;
if (m_BasicInfoItem) {
m_BasicInfoItem->setSelectMode(mode);
auto item = m_BasicInfoItem->getNextItem();
for (; item; item = item->getNextItem()) {
FieldItem *fieldItem = static_cast<FieldItem *>(item);
- fieldItem->setSelectMode(mode, type);
+ fieldItem->setSelectMode(mode);
}
}
item = new FieldItem(field);
}
- item->setSelectMode(m_SelectMode, m_ResultType);
+ item->setSelectMode(m_SelectMode);
item->setSelectCallback(std::bind(&DetailsView::onSingleSelected, this, _1));
item->setCheckCallback(std::bind(&DetailsView::onItemChecked, this, _1));
FieldItem::FieldItem(ContactObject &object)
: m_Object(object), m_Field(*object.getField(0)),
- m_SelectMode(SelectNone), m_ResultType(ResultNone)
+ m_SelectMode(SelectNone)
{
}
-void FieldItem::setSelectMode(SelectMode mode, ResultType type)
+void FieldItem::setSelectMode(SelectMode mode)
{
m_SelectMode = mode;
- m_ResultType = type;
elm_genlist_item_fields_update(getObjectItem(), "*", ELM_GENLIST_ITEM_FIELD_CONTENT);
}
return m_SelectMode;
}
-ResultType FieldItem::getResultType() const
-{
- return m_ResultType;
-}
-
Elm_Genlist_Item_Class *FieldItem::getItemClass() const
{
static Elm_Genlist_Item_Class itc = createItemClass("type2");
void FieldItem::onSelected()
{
if (m_SelectMode == SelectSingle) {
- onSelected(getObject().getSubType());
+ if (m_OnSelected) {
+ m_OnSelected({ m_Object.getSubType(), m_Object.getRecordId()});
+ }
} else {
GenlistCheckItem::onSelected();
}
}
-void FieldItem::onSelected(unsigned resultType)
-{
- if (m_OnSelected) {
- m_OnSelected({ resultType, getObject().getRecordId()});
- }
-}
-
void FieldItem::onFieldUpdated(ContactField &field, contacts_changed_e change)
{
if (&field == &m_Field) {
for (auto &&item : *group.second) {
PersonItem *personItem = static_cast<PersonItem *>(item);
if (personItem->isChecked()) {
- results.push_back({ ItemPerson, personItem->getPerson().getId() });
+ results.push_back({ ResultPerson, personItem->getPerson().getId() });
}
}
}
void ListView::onPersonSelected(const Model::Person &person)
{
- SelectResult result = { ItemPerson, person.getId() };
+ SelectResult result = { ResultPerson, person.getId() };
if (m_OnSelected && m_OnSelected({ &result, 1 })) {
delete this;
}