class GroupsView : public Ux::SelectView
{
public:
- GroupsView();
+ /**
+ * @brief Create groups main view.
+ * @param[in] filterType Bitmask filter
+ * @see FilterType
+ */
+ GroupsView(int filterType = FilterNone);
/**
* @brief Set whether the view is used for assigning contacts to groups.
#include "Model2/DataItem.h"
+#include "Contacts/Common/ContactSelectTypes.h"
#include "Common/DataTypes.h"
#include "Utils/UniString.h"
/**
* @brief Create group object
- * @param[in] id _contacts_group id
+ * @param[in] id _contacts_group id
+ * @param[in] filterType Filter to use to count group's members
+ * @see FilterType
*/
- explicit Group(int id = 0);
+ explicit Group(int id = 0, int filterType = FilterNone);
/**
* @brief Create group object
- * @param[in] record _contacts_group record
+ * @param[in] record _contacts_group record
+ * @param[in] filterType Filter to use to count group's members
+ * @see FilterType
*/
- explicit Group(contacts_record_h record);
+ explicit Group(contacts_record_h record, int filterType = FilterNone);
/**
* @brief Create group object
Common::GroupType m_Type;
mutable Utils::UniString m_SortValue;
int m_MembersCount;
+ int m_FilterType;
};
}
}
#define CONTACTS_GROUPS_MODEL_GROUPS_PROVIDER_H
#include "Model2/DataProvider.h"
+#include "Contacts/Common/ContactSelectTypes.h"
#include <contacts.h>
class GroupsProvider : public ::Model2::DataProvider
{
public:
- GroupsProvider();
+ /**
+ * @brief Create groups provider.
+ * @param[in] filterType Bitmask filter
+ * @see FilterType
+ */
+ GroupsProvider(int filterType = FilterNone);
virtual ~GroupsProvider() override;
private:
int m_DbVersion;
int m_MembersDbVersion;
int m_UpdateType;
+ int m_FilterType;
};
}
}
#ifndef CONTACTS_GROUPS_MODEL_QUERIES_H
#define CONTACTS_GROUPS_MODEL_QUERIES_H
+#include "Contacts/Common/ContactSelectTypes.h"
+
#include <contacts.h>
namespace Contacts
* @brief Get query for group's members filtered by group name.
* @remark Return value MUST be destroyed with contacts_query_destroy by you
* @param[in] groupId _contacts_group ID.
+ * @param[in] filterType Filter type
* @return filtered query.
+ * @see FilterType
*/
- EXPORT_API contacts_query_h getMembersQuery(int groupId);
+ EXPORT_API contacts_query_h getMembersQuery(int groupId, int filterType = FilterNone);
/**
* @brief Get members count of specified group.
* @param[in] groupId _contacts_group ID.
+ * @param[in] filterType Filter type
* @return members count.
+ * @see FilterType
*/
- EXPORT_API int getMembersCount(int groupId);
+ EXPORT_API int getMembersCount(int groupId, int filterType = FilterNone);
}
}
}
SelectView *ChooserView::createGroupsView()
{
- auto view = new GroupsView();
+ auto view = new GroupsView(m_FilterType);
view->setSelectMode(SelectSingle);
view->setSelectCallback([this](SelectResults results) {
auto group = static_cast<Group *>(results.front().value.data);
using namespace Utils;
using namespace Ux;
-GroupsView::GroupsView()
+GroupsView::GroupsView(int filterType)
: m_Genlist(nullptr), m_GroupsItem(nullptr),
m_NotAssignedItem(nullptr), m_CreateItem(nullptr),
- m_IsAssignMode(false), m_NewGroupId(0)
+ m_IsAssignMode(false), m_NewGroupId(0), m_Provider(filterType)
{
auto strings = getSelectViewStrings();
strings.titleDefault = "IDS_PB_HEADER_GROUPS_ABB";
}
}
-Group::Group(int id)
- : Group(fetchGroupRecord(id))
+Group::Group(int id, int filterType)
+ : Group(fetchGroupRecord(id), filterType)
{
}
-Group::Group(contacts_record_h record)
- : m_Record(record), m_DbVersion(0)
+Group::Group(contacts_record_h record, int filterType)
+ : m_Record(record), m_DbVersion(0), m_FilterType(filterType)
{
m_Type = Common::getGroupType(getName());
- m_MembersCount = Model::getMembersCount(getId());
+ m_MembersCount = Model::getMembersCount(getId(), m_FilterType);
}
Group::Group(const Group &that)
: m_DbVersion(0), m_Type(that.m_Type), m_SortValue(that.m_SortValue),
- m_MembersCount(that.m_MembersCount)
+ m_MembersCount(that.m_MembersCount), m_FilterType(that.m_FilterType)
{
contacts_record_clone(that.m_Record, &m_Record);
}
void Group::updateMembersCount()
{
- m_MembersCount = Model::getMembersCount(getId());
+ m_MembersCount = Model::getMembersCount(getId(), m_FilterType);
setChanged(Model2::ChangeUpdate, ChangedMembersCount);
}
using namespace Common::Database;
using namespace Model2;
-GroupsProvider::GroupsProvider()
- : m_DbVersion(0), m_MembersDbVersion(0), m_UpdateType(UpdateNone)
+GroupsProvider::GroupsProvider(int filterType)
+ : m_DbVersion(0), m_MembersDbVersion(0), m_UpdateType(UpdateNone), m_FilterType(filterType)
{
}
DataList dataList;
for (auto &&record : makeRange(list)) {
- dataList.push_back(DataItemPtr(new Group(record)));
+ dataList.push_back(DataItemPtr(new Group(record, m_FilterType)));
}
contacts_list_destroy(list, false);
void GroupsProvider::insertGroup(int id)
{
- insertDataItem(DataItemPtr(new Group(id)));
+ insertDataItem(DataItemPtr(new Group(id, m_FilterType)));
}
void GroupsProvider::updateGroup(DataList::const_iterator groupIt)
using namespace Contacts::Groups;
-contacts_query_h Model::getMembersQuery(int groupId)
+contacts_query_h Model::getMembersQuery(int groupId, int filterType)
{
contacts_filter_h filter = nullptr;
contacts_filter_create(_contacts_person_group_assigned._uri, &filter);
contacts_filter_add_int(filter, _contacts_person_group_assigned.group_id,
CONTACTS_MATCH_EQUAL, groupId);
+ if (filterType != FilterNone) {
+ contacts_filter_h subFilter = nullptr;
+ contacts_filter_create(_contacts_person_group_assigned._uri, &subFilter);
+ if (filterType & FilterNumber) {
+ contacts_filter_add_bool(subFilter, _contacts_person_group_assigned.has_phonenumber, true);
+ contacts_filter_add_operator(subFilter, CONTACTS_FILTER_OPERATOR_OR);
+ }
+ if (filterType & FilterEmail) {
+ contacts_filter_add_bool(subFilter, _contacts_person_group_assigned.has_email, true);
+ }
+ contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
+ contacts_filter_add_filter(filter, subFilter);
+ contacts_filter_destroy(subFilter);
+ }
+
contacts_query_h query = nullptr;
contacts_query_create(_contacts_person_group_assigned._uri, &query);
contacts_query_set_filter(query, filter);
return query;
}
-int Model::getMembersCount(int groupId)
+int Model::getMembersCount(int groupId, int filterType)
{
if (!groupId) {
return 0;
}
- contacts_query_h query = getMembersQuery(groupId);
+ contacts_query_h query = getMembersQuery(groupId, filterType);
int count = 0;
contacts_db_get_count_with_query(query, &count);
contacts_query_destroy(query);