TizenRefApp-6980 "Groups amd members" delete option displayed when removing group... 99/87299/3
authorNataliia Sydorchuk <n.sydorchuk@samsung.com>
Wed, 7 Sep 2016 12:29:34 +0000 (15:29 +0300)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 8 Sep 2016 10:54:22 +0000 (03:54 -0700)
Change-Id: I81260e783232ee98ec8fc2557c2825e92ff2b5ae
Signed-off-by: Nataliia Sydorchuk <n.sydorchuk@samsung.com>
lib-contacts/inc/Contacts/Groups/GroupsView.h
lib-contacts/src/Contacts/Groups/GroupsView.cpp

index 1b6d0d0..c6901d1 100644 (file)
@@ -77,6 +77,7 @@ namespace Contacts
                        void deleteItem(GroupItem *item);
                        Ui::GenItem *getNextItem(Model::Group &group);
 
+                       void createDeletePopup(Ux::SelectResults results);
                        bool onDeleteFinished();
                        void onDeleteSelected(Ux::SelectResults results, void *data);
                        void deleteGroups(Ux::SelectResults results, bool shouldDeleteMembers);
index e57bf1f..3319afe 100644 (file)
@@ -115,16 +115,18 @@ void GroupsView::onMenuPressed()
 
                        setCancelCallback(std::bind(&GroupsView::onDeleteFinished, this));
                        setSelectCallback([this](SelectResults results) {
-                               ListPopup *popup = new ListPopup();
-                               popup->create(getEvasObject());
-                               popup->setTitle("IDS_PB_HEADER_DELETE_GROUPS_ABB");
-
-                               popup->addItem("IDS_PB_OPT_GROUPS_ONLY_ABB", (void *)false);
-                               popup->addItem("IDS_PB_OPT_GROUPS_AND_MEMBERS_ABB", (void *)true);
-                               popup->setSelectCallback(std::bind(&GroupsView::onDeleteSelected,
-                                               this, std::move(results), _1));
-                               popup->show();
-
+                               bool hasMembers = false;
+                               for (auto &&result : results) {
+                                       if (static_cast<Group *>(result.value.data)->getMembersCount()) {
+                                               hasMembers = true;
+                                               break;
+                                       }
+                               }
+                               if (hasMembers) {
+                                       createDeletePopup(std::move(results));
+                               } else {
+                                       onDeleteSelected(std::move(results), (void *)false);
+                               }
                                return false;
                        });
                });
@@ -281,6 +283,19 @@ GenItem *GroupsView::getNextItem(Group &group)
        return m_CreateItem;
 }
 
+void GroupsView::createDeletePopup(SelectResults results)
+{
+       ListPopup *popup = new ListPopup();
+       popup->create(getEvasObject());
+       popup->setTitle("IDS_PB_HEADER_DELETE_GROUPS_ABB");
+
+       popup->addItem("IDS_PB_OPT_GROUPS_ONLY_ABB", (void *)false);
+       popup->addItem("IDS_PB_OPT_GROUPS_AND_MEMBERS_ABB", (void *)true);
+       popup->setSelectCallback(std::bind(&GroupsView::onDeleteSelected,
+                       this, std::move(results), _1));
+       popup->show();
+}
+
 bool GroupsView::onDeleteFinished()
 {
        setSelectMode(SelectNone);