1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, http://www.bibletime.info/.
6 *
7 * Copyright 1999-2016 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #include "roleitemmodel.h"
14 
15 /* Example usage:
16 
17 Enumerate the role ID's somewhere
18 ---------------------------------
19 
20 struct RedditEntry {
21 
22     enum RedditRoles {
23         UrlRole = Qt::UserRole + 1,
24         DescRole,
25         ...
26     };
27     ...
28 }
29 
30 Instantiate the class
31 ---------------------
32 
33     QHash<int, QByteArray> roleNames;
34     roleNames[RedditEntry::UrlRole] =  "url";
35     roleNames[RedditEntry::ScoreRole] = "score";
36     m_linksmodel = new RoleItemModel(roleNames);
37 
38 Populate with data:
39 -------------------
40 
41     QStandardItem* it = new QStandardItem();
42     it->setData(e.desc, RedditEntry::DescRole);
43     it->setData(e.score, RedditEntry::ScoreRole);
44 
45     m_linksmodel->appendRow(it);
46 
47 Expose to QML:
48 -------------
49 
50 QDeclarativeContext *ctx = ...
51 
52 ctx->setContextProperty("mdlLinks", m_linksmodel);
53 
54 */
55 
56 //RoleItemModel::RoleItemModel(const QHash<int, QByteArray> &roleNames)
57 //    : m_roleNames(roleNames) {
58 //}
59 
roleNames() const60 QHash<int, QByteArray> RoleItemModel::roleNames() const {
61     return m_roleNames;
62 }
63 
setRoleNames(const QHash<int,QByteArray> & roleNames)64 void RoleItemModel::setRoleNames(const QHash<int, QByteArray> &roleNames) {
65     m_roleNames = roleNames;
66 }
67