#define CONTACTS_LIST_CONTACT_SEARCH_FIELD_H
#include "Ui/Editfield.h"
+#include <Ecore.h>
#include <functional>
#include <string>
class SearchField : public Ui::Editfield
{
public:
+ SearchField();
+ ~SearchField();
+
+ SearchField(const SearchField &) = delete;
+ SearchField(SearchField &&) = delete;
+ SearchField& operator=(const SearchField &) = delete;
+ SearchField& operator=(SearchField &&) = delete;
+
/**
* @brief Entry change callback.
*/
void updateGuideText();
void onDonePressed(Evas_Object *entry, void *eventInfo);
void onChanged(Evas_Object *entry, void *eventInfo);
+ Eina_Bool runOnChanged();
ChangeCallback m_OnChanged;
std::string m_Text;
+ Ecore_Timer *m_ChangedTimer;
};
}
}
using namespace Contacts::List;
+SearchField::SearchField()
+ : m_ChangedTimer(nullptr)
+{
+}
+
+SearchField::~SearchField()
+{
+ if (m_ChangedTimer) {
+ ecore_timer_del(m_ChangedTimer);
+ }
+}
+
const char *SearchField::getText() const
{
return m_Text.c_str();
m_Text = text ? text : "";
free(text);
+ if (m_ChangedTimer) {
+ ecore_timer_reset(m_ChangedTimer);
+ } else {
+ m_ChangedTimer = ecore_timer_add(0.3, makeCallback(&SearchField::runOnChanged), this);
+ }
+}
+
+Eina_Bool SearchField::runOnChanged()
+{
if (m_OnChanged) {
m_OnChanged(m_Text.c_str());
}
+
+ m_ChangedTimer = nullptr;
+ return ECORE_CALLBACK_CANCEL;
}