Made SelectResult more generic.
Change-Id: I31939bf812911c651f827aac0613b7e68ff8fd22
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
#ifndef CONTACTS_SELECT_ITEM_H
#define CONTACTS_SELECT_ITEM_H
-#include "Contacts/Common/SelectMode.h"
+#include "Contacts/SelectTypes.h"
#include "Ui/GenlistCheckItem.h"
namespace Contacts
/**
* @brief Genlist item for SelectView that supports selection mode switching.
*/
- class SelectItem : public Ui::GenlistCheckItem
+ class EXPORT_API SelectItem : public Ui::GenlistCheckItem
{
public:
SelectItem();
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+#ifndef CONTACTS_SELECT_TYPES_H
+#define CONTACTS_SELECT_TYPES_H
+
+#include "Utils/Range.h"
+#include <functional>
+
+namespace Contacts
+{
+ /**
+ * @brief Determines how items can be selected.
+ */
+ enum SelectMode
+ {
+ SelectNone, /**< Selection is disabled */
+ SelectSingle, /**< Only one item can be selected */
+ SelectMulti /**< Multiple items can be selected */
+ };
+
+ /**
+ * @brief Selection result.
+ */
+ struct SelectResult
+ {
+ unsigned type; /**< Result type (depends on result source) */
+ union Value
+ {
+ Value(void *data) : data(data) { }
+ Value(int id) : id(id) { }
+ void *data; /**< Result data */
+ int id; /**< Result data ID */
+ } value; /**< Result value (depends on type) */
+ };
+
+ /**
+ * @brief Range of consecutive selection results.
+ */
+ typedef Utils::Range<const SelectResult *> SelectResults;
+
+ /**
+ * @brief Callback to be called when selection is done.
+ * @param[in] Selection results
+ * @return Whether the component that provided the selection should be destroyed.
+ */
+ typedef std::function<bool(SelectResults)> SelectCallback;
+}
+
+#endif /* CONTACTS_SELECT_TYPES_H */
#ifndef CONTACTS_SELECT_VIEW_H
#define CONTACTS_SELECT_VIEW_H
-#include "Contacts/Common/SelectAllItem.h"
-#include "Contacts/Common/SelectMode.h"
+#include "Contacts/SelectAllItem.h"
+#include "Contacts/SelectTypes.h"
#include "Ui/View.h"
#include <memory>
/**
* @brief Base class for a view that support single and multiple selection modes.
*/
- class SelectView : public Ui::View
+ class EXPORT_API SelectView : public Ui::View
{
public:
SelectView();
*
*/
-#include "Contacts/Common/SelectAllItem.h"
+#include "Contacts/SelectAllItem.h"
#include <app_i18n.h>
using namespace Contacts;
*
*/
-#include "Contacts/Common/SelectItem.h"
+#include "Contacts/SelectItem.h"
using namespace Contacts;
*
*/
-#include "Contacts/Common/SelectView.h"
-#include "Contacts/Common/SelectItem.h"
+#include "Contacts/SelectView.h"
+#include "Contacts/SelectItem.h"
#include "Ui/Genlist.h"
#include "Utils/Callback.h"
#ifndef CONTACTS_COMMON_CHOOSER_H
#define CONTACTS_COMMON_CHOOSER_H
-#include "Contacts/Common/SelectMode.h"
+#include "Contacts/Common/ContactSelectTypes.h"
#include "Ui/Naviframe.h"
namespace Contacts
*
*/
-#ifndef CONTACTS_COMMON_SELECT_MODE_H
-#define CONTACTS_COMMON_SELECT_MODE_H
+#ifndef CONTACTS_COMMON_CONTACT_SELECT_TYPES_H
+#define CONTACTS_COMMON_CONTACT_SELECT_TYPES_H
+#include "Contacts/SelectTypes.h"
#include "Contacts/Model/ContactField.h"
#include "Contacts/Model/ContactTypes.h"
-#include "Utils/Range.h"
-
-#include <functional>
namespace Contacts
{
/**
- * @brief Determines how items can be selected.
- */
- enum SelectMode
- {
- SelectNone, /**< Selection is disabled */
- SelectSingle, /**< Only one item can be selected */
- SelectMulti /**< Multiple items can be selected */
- };
-
- /**
* @brief Determines which items are displayed.
*/
enum FilterType
ResultNumber = Model::ObjectTypeNumber, /**< Number ID is the result */
ResultEmail = Model::ObjectTypeEmail /**< Email ID is the result */
};
-
- /**
- * @brief Selection result.
- */
- struct SelectResult
- {
- unsigned type; /**< @ref ResultType. */
- int itemId; /**< Item database ID (for _contacts_person, _contacts_number or _contacts_email). */
- };
-
- /**
- * @brief Range of consecutive selection results.
- */
- typedef Utils::Range<const SelectResult *> SelectResults;
-
- /**
- * @brief Callback to be called when selection is done.
- * @param[in] Selection results
- * @return Whether the component that provided the selection should be destroyed.
- */
- typedef std::function<bool(SelectResults)> SelectCallback;
}
-#endif /* CONTACTS_COMMON_SELECT_MODE_H */
+#endif /* CONTACTS_COMMON_CONTACT_SELECT_TYPES_H */
#ifndef CONTACTS_DETAILS_BASIC_INFO_ITEM_H
#define CONTACTS_DETAILS_BASIC_INFO_ITEM_H
-#include "Contacts/Common/SelectMode.h"
+#include "Contacts/SelectTypes.h"
#include "Ui/GenlistItem.h"
#include <contacts.h>
#define CONTACTS_DETAILS_DETAILS_VIEW_H
#include "App/AppControl.h"
-#include "Contacts/Common/SelectView.h"
+#include "Contacts/Common/ContactSelectTypes.h"
#include "Contacts/Model/Contact.h"
-#include "Ui/View.h"
+#include "Contacts/SelectView.h"
namespace Ui
{
#ifndef CONTACTS_DETAILS_FIELD_ITEM_H
#define CONTACTS_DETAILS_FIELD_ITEM_H
-#include "Contacts/Common/SelectItem.h"
+#include "Contacts/SelectItem.h"
#include <contacts.h>
namespace Contacts
#include "Contacts/List/Model/PersonProvider.h"
#include "Contacts/List/PersonItem.h"
-#include "Contacts/Common/SelectView.h"
+#include "Contacts/SelectView.h"
#include "Utils/UniString.h"
#ifndef CONTACTS_LIST_MODEL_PERSON_PROVIDER_H
#define CONTACTS_LIST_MODEL_PERSON_PROVIDER_H
-#include "Contacts/Common/SelectMode.h"
+#include "Contacts/Common/ContactSelectTypes.h"
#include "Contacts/DbChangeObserver.h"
#include "Contacts/List/Model/Person.h"
#ifndef CONTACTS_LIST_PERSON_ITEM_H
#define CONTACTS_LIST_PERSON_ITEM_H
-#include "Contacts/Common/SelectItem.h"
+#include "Contacts/SelectItem.h"
#include "Contacts/List/Model/Person.h"
#include <functional>
bool Chooser::onSinglePersonSelected(SelectResults personResults)
{
const SelectResult &person = *personResults.begin();
- int resultId = getSingleResultId(person.itemId, m_ResultType);
+ int resultId = getSingleResultId(person.value.id, m_ResultType);
if (resultId > 0) {
SelectResult result = { m_ResultType, resultId };
}
/* FIXME: Implement person support in DetailsView */
- DetailsView *view = new DetailsView(getContactId(person.itemId),
+ DetailsView *view = new DetailsView(getContactId(person.value.id),
DetailsView::Type(person.type), m_FilterType);
view->setSelectMode(m_SelectMode);
view->setSelectCallback(std::bind(&Chooser::onSelected, this, _1));
results.reserve(personResults.count());
for (auto &&result : personResults) {
- contacts_person_get_default_property(property, result.itemId, &id);
+ contacts_person_get_default_property(property, result.value.id, &id);
results.push_back({ m_ResultType, id });
}
view->setSelectCallback([](SelectResults results) {
std::vector<int> ids;
for (auto &&result : results) {
- ids.push_back(result.itemId);
+ ids.push_back(result.value.id);
}
contacts_db_delete_records(_contacts_person._uri, ids.data(), ids.size());
*/
#include "Contacts/List/PersonItem.h"
+#include "Contacts/Common/ContactSelectTypes.h"
#include "Ui/Thumbnail.h"
#include <app_i18n.h>
#define OPERATION_PICK_CONTROLLER_H
#include "OperationController.h"
-#include "Contacts/Common/SelectMode.h"
+#include "Contacts/Common/ContactSelectTypes.h"
#include <Evas.h>
std::vector<const char *> ids(count);
for (size_t i = 0; i < count; ++i) {
- snprintf(buffers[i], sizeof(buffers[i]), "%d", results[i].itemId);
+ snprintf(buffers[i], sizeof(buffers[i]), "%d", results[i].value.id);
ids[i] = buffers[i];
}