Skip to content
Snippets Groups Projects
Commit 11162794 authored by Stepan Salenikovich's avatar Stepan Salenikovich
Browse files

roles: add a global LRC item data role

Many LRC models expose the same types of data, but do so using their
own item data roles. For example, Call::Role::Object exposes the item's
object pointer in some models, but in the PersonModel it is
Person::Role::Object. Since their enum values are not guaranteed to be
the same, and indeed they are not usually the same, this often requires
additional logic in the clients of LRC to determine which model is
being used.

This patch adds a Ring::Roles enum to be used by LRC models when
exposing the same types of data as other models.

Issue: #81198
Change-Id: I506c716c12f5b1bb0707e37c6dfa709b4fe03864
parent 49840093
No related branches found
No related tags found
No related merge requests found
...@@ -403,6 +403,7 @@ SET( libringclient_LIB_HDRS ...@@ -403,6 +403,7 @@ SET( libringclient_LIB_HDRS
src/profilepersisterdefault.h src/profilepersisterdefault.h
src/shortcutcreatordefault.h src/shortcutcreatordefault.h
src/dbuserrorhandlerdefault.h src/dbuserrorhandlerdefault.h
src/itemdataroles.h
) )
SET(libringclient_video_LIB_HDRS SET(libringclient_video_LIB_HDRS
......
/****************************************************************************
* Copyright (C) 2015 by Savoir-faire Linux *
* Author : Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>*
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
namespace Ring {
/**
* The purpose of this enum class is to mimic/extend the Qt::ItemDataRole in LRC so that the same
* value is used when using a common role in the ::data() method of any model in LRC,
* eg: the value of the Object role should not be different for the PersonModel and the CallModel.
*
* This is so that clients of LRC do need additional logic when trying to extract the same type of
* data from multiple types of LRC models.
*
* Thus any data role which is common to multiple models in LRC should be defined here. Data roles
* which are specific to the model can be defined within that model only and their value should
* start with UserRole + 1
*/
enum class Role
{
DisplayRole = Qt::DisplayRole ,
Object = Qt::UserRole + 1,
Name ,
Number ,
LastUsed ,
FormattedLastUsed ,
State ,
FormattedState ,
DropState ,
UserRole = Qt::UserRole + 100 // this should always be the last role in the list
};
} // namespace Ring
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment