/**
* @brief Item check callback.
* @param[in] Whether item is checked
+ * @return Whether item's state should be changed.
*/
- typedef std::function<void(bool)> CheckCallback;
+ typedef std::function<bool(bool)> CheckCallback;
GenlistCheckItem();
virtual void onSelected() override;
/**
- * @brief Called when item is checked or unchecked.
+ * @brief Called when item's "checked" state changes.
* @param[in] isChecked Whether item is checked
+ * @return Whether item's state should be changed.
*/
- virtual void onChecked(bool isChecked) { }
+ virtual bool onChecked(bool isChecked) { return true; }
private:
- void onChecked();
void onCheckChanged(Evas_Object *check, void *eventInfo);
+ bool notifyCheck(bool isChecked);
std::string m_CheckPart;
Eina_Bool m_IsChecked;
void GenlistCheckItem::onSelected()
{
- setChecked(!m_IsChecked);
- onChecked();
+ if (notifyCheck(!m_IsChecked)) {
+ setChecked(!m_IsChecked);
+ }
}
-void GenlistCheckItem::onChecked()
+void GenlistCheckItem::onCheckChanged(Evas_Object *check, void *eventInfo)
{
- onChecked(m_IsChecked);
-
- if (m_OnChecked) {
- m_OnChecked(m_IsChecked);
+ if (!notifyCheck(m_IsChecked)) {
+ elm_check_state_set(check, !m_IsChecked);
}
}
-void GenlistCheckItem::onCheckChanged(Evas_Object *check, void *eventInfo)
+bool GenlistCheckItem::notifyCheck(bool isChecked)
{
- onChecked();
+ if (!onChecked(isChecked)) {
+ return false;
+ }
+
+ if (m_OnChecked && !m_OnChecked(isChecked)) {
+ return false;
+ }
+
+ return true;
}
void destroyPageButtons();
void onItemSelected(SelectItem *item);
- void onItemChecked(SelectItem *item, bool isChecked);
- void onSelectAllChecked(bool isChecked);
+ bool onItemChecked(SelectItem *item, bool isChecked);
+ bool onSelectAllChecked(bool isChecked);
void onSelectAllDestroy();
void onDonePressed(Evas_Object *button, void *eventInfo);
}
}
-void SelectView::onItemChecked(SelectItem *item, bool isChecked)
+bool SelectView::onItemChecked(SelectItem *item, bool isChecked)
{
if (m_SelectLimit && m_SelectCount == m_SelectLimit && isChecked) {
- item->setChecked(false);
- } else {
- updateSelectCount(isChecked ? CountIncrement : CountDecrement);
+ return false;
}
+
+ updateSelectCount(isChecked ? CountIncrement : CountDecrement);
+ return true;
}
-void SelectView::onSelectAllChecked(bool isChecked)
+bool SelectView::onSelectAllChecked(bool isChecked)
{
for (auto &&item : m_Items) {
item->setChecked(isChecked);
m_SelectCount = isChecked ? m_Items.size() : 0;
updatePageTitle();
updateDoneButtonState();
+
+ return true;
}
void SelectView::onSelectAllDestroy()