summaryrefslogtreecommitdiff
path: root/contacts-widget-edit-app/src/WidgetEditView.cpp
diff options
context:
space:
mode:
authorSergei Kobec <s.kobec@samsung.com>2017-09-11 14:05:29 +0300
committerSergei Kobec <s.kobec@samsung.com>2017-09-12 12:09:00 +0300
commit9fa6c29e865c099e358385d0c02ca13c6e72ad74 (patch)
treeb48538ed49bfb57ce9708df79dce46a6d810cda2 /contacts-widget-edit-app/src/WidgetEditView.cpp
parent5314fc243e0fa9fafc1bd3bab0899a1dc3e0cca7 (diff)
downloadphone-contacts-9fa6c29e865c099e358385d0c02ca13c6e72ad74.tar.gz
phone-contacts-9fa6c29e865c099e358385d0c02ca13c6e72ad74.tar.bz2
phone-contacts-9fa6c29e865c099e358385d0c02ca13c6e72ad74.zip
Change WidgetItem creation logic in ContactWidgetItemsView
Optimized items creation count for different widget layout type. Change-Id: I38bb3075635c5cb7fbcbc7f9bc56f5f27db8c9ea Signed-off-by: Sergei Kobec <s.kobec@samsung.com>
Diffstat (limited to 'contacts-widget-edit-app/src/WidgetEditView.cpp')
-rw-r--r--contacts-widget-edit-app/src/WidgetEditView.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/contacts-widget-edit-app/src/WidgetEditView.cpp b/contacts-widget-edit-app/src/WidgetEditView.cpp
index 0de5477..9ea72cd 100644
--- a/contacts-widget-edit-app/src/WidgetEditView.cpp
+++ b/contacts-widget-edit-app/src/WidgetEditView.cpp
@@ -41,15 +41,14 @@ Evas_Object *WidgetEditView::onCreate(Evas_Object *parent)
return layout;
}
-void WidgetEditView::onCreated()
+WidgetItem *WidgetEditView::createItem(int id)
{
- ContactWidgetItemsView::onCreated();
+ auto item = ContactWidgetItemsView::createItem(id);
+ item->setItemGrabCallback(std::bind(&WidgetEditView::onItemGrabbed, this, item));
+ item->setItemReleaseCallback(std::bind(&WidgetEditView::onItemReleased, this));
+ item->setItemMoveCallback(std::bind(&WidgetEditView::onItemMove, this, _1));
- for (auto &&item : getWidgetItems()) {
- item->setItemGrabCallback(std::bind(&WidgetEditView::onItemGrabbed, this, item));
- item->setItemReleaseCallback(std::bind(&WidgetEditView::onItemReleased, this));
- item->setItemMoveCallback(std::bind(&WidgetEditView::onItemMove, this, _1));
- }
+ return item;
}
void WidgetEditView::move(WidgetItem *item)
@@ -94,7 +93,7 @@ void WidgetEditView::onItemMove(Evas_Point itemPos)
if (item == m_ReleasedItem) {
continue;
}
- if (item->hits(itemPos)) {
+ if (item && item->hits(itemPos)) {
move(item);
size_t newReleasedIndex = item->getIndex();
@@ -111,7 +110,8 @@ void WidgetEditView::onReorderingFinished()
{
ContactWidgetItems::ContactIds ids = { 0 };
for (auto &&item : getWidgetItems()) {
- if (auto contact = item->getContactData()) {
+ const ContactData *contact = nullptr;
+ if (item && (contact = item->getContactData())) {
ids[item->getIndex()] = contact->getId();
}
}