summaryrefslogtreecommitdiff
path: root/lib/dialer/Search/ResultWidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dialer/Search/ResultWidget.cpp')
-rw-r--r--lib/dialer/Search/ResultWidget.cpp151
1 files changed, 0 insertions, 151 deletions
diff --git a/lib/dialer/Search/ResultWidget.cpp b/lib/dialer/Search/ResultWidget.cpp
deleted file mode 100644
index ab89fc2..0000000
--- a/lib/dialer/Search/ResultWidget.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2012-2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "Search/ResultWidget.h"
-
-#include "phone.h"
-#include "phone-common.h"
-
-namespace Phone
-{
- namespace Dialer
- {
- namespace Search
- {
- ResultWidget::ResultWidget()
- : m_Layout(NULL), m_Icon(NULL), m_Listener(NULL)
- {
- PH_TRACE;
- }
-
- ResultWidget::~ResultWidget()
- {
- PH_TRACE;
- if(m_Icon)
- {
- evas_object_del(m_Icon);
- m_Icon = NULL;
- }
- }
-
- bool ResultWidget::initialize(Evas_Object *layout)
- {
- PH_TRACE;
- if(!layout)
- {
- return false;
- }
-
- m_Icon = elm_icon_add(layout);
- if(!m_Icon)
- {
- return false;
- }
- elm_object_part_content_set(layout, "icon", m_Icon);
- edje_object_signal_callback_add(_EDJ(layout), "softkey_clicked", "*", onLayoutEvent, this);
-
- m_Layout = layout;
- return true;
- }
-
- void ResultWidget::setListener(ResultWidgetListener *listener)
- {
- m_Listener = listener;
- }
-
- void ResultWidget::setResult(const Result &result)
- {
- PH_TRACE;
-
- std::string number;
- result.formatMatch(number, "<mark>", "</mark>");
-
- elm_object_part_text_set(m_Layout, "textName", result.getContact()->getName().c_str());
- elm_object_part_text_set(m_Layout, "textNumber", number.c_str());
-
- const char *path = NULL;
- if(result.getContact()->getImagePath().empty())
- {
- path = IMG_DEFAULT;
- }
- else
- {
- path = result.getContact()->getImagePath().c_str();
- }
-
- elm_image_file_set(m_Icon, path, NULL);
- }
-
- void ResultWidget::setResultCount(unsigned count)
- {
- PH_TRACE;
- if(count == 0)
- {
- char buffer[PH_TEXT_MAX_LEN] = { 0 };
- sprintf(buffer, "+ %s", T_(PH_GET_TEXT_BASIC, PHTEXT_ADD_TO_CONTACTS));
- elm_object_part_text_set(m_Layout, "textAddToContacts", buffer);
- edje_object_signal_emit(_EDJ(m_Layout), "suggestion/showAddToContacts", "suggestion");
- }
- else if(count == 1)
- {
- edje_object_signal_emit(_EDJ(m_Layout), "suggestion/showSingleItemView", "suggestion");
- }
- else
- {
- char matchCount[16];
- sprintf(matchCount, "%d", count);
- elm_object_part_text_set(m_Layout, "textNumberOfMatches", matchCount);
- edje_object_signal_emit(_EDJ(m_Layout), "suggestion/showMultiItemView", "suggestion");
- }
- }
-
- void ResultWidget::hide()
- {
- PH_TRACE;
- edje_object_signal_emit(_EDJ(m_Layout), "suggestion/hide", "suggestion");
- }
-
- void ResultWidget::onLayoutEvent(void *data, Evas_Object *obj, const char *emission, const char *source)
- {
- PH_TRACE;
- if(!data || !source)
- {
- return;
- }
-
- ResultWidgetListener *listener = static_cast<ResultWidget*>(data)->m_Listener;
- if(!listener)
- {
- DBG("no listener");
- return;
- }
-
- if(strcmp(source, "suggestion") == 0)
- {
- listener->onAddToContacts();
- }
- else if(strcmp(source, "suggestionListTopItem") == 0)
- {
- listener->onTopResultSelect();
- }
- else if(strcmp(source, "suggestionListButton") == 0)
- {
- listener->onShowMoreResults();
- }
- }
- }
- }
-}