• Skip to content
  • Skip to link menu
  • KDE API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • KTp
  • Models
groups-tree-proxy-model.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 David Edmundson <kde@davidedmundson.co.uk>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "groups-tree-proxy-model.h"
20 
21 #include "types.h"
22 
23 #include <KLocalizedString>
24 
25 class KTp::GroupsTreeProxyModel::Private
26 {
27 public:
28  //nothing here yet, added anyway in case we need private members without breaking the ABI
29 };
30 
31 
32 KTp::GroupsTreeProxyModel::GroupsTreeProxyModel(QAbstractItemModel *sourceModel) :
33  AbstractGroupingProxyModel(sourceModel),
34  d(new KTp::GroupsTreeProxyModel::Private())
35 {
36 }
37 
38 KTp::GroupsTreeProxyModel::~GroupsTreeProxyModel()
39 {
40  delete d;
41 }
42 
43 QSet<QString> KTp::GroupsTreeProxyModel::groupsForIndex(const QModelIndex &sourceIndex) const
44 {
45  QStringList groups = sourceIndex.data(KTp::ContactGroupsRole).value<QStringList>();
46  if (groups.isEmpty()) {
47  groups.append(QLatin1String("_unsorted"));
48  }
49 
50  return groups.toSet();
51 }
52 
53 
54 QVariant KTp::GroupsTreeProxyModel::dataForGroup(const QString &group, int role) const
55 {
56  switch (role) {
57  case KTp::RowTypeRole:
58  return KTp::GroupRowType;
59  case Qt::DisplayRole:
60  if (group == QLatin1String("_unsorted")) {
61  return i18n("Unsorted");
62  } else {
63  return group;
64  }
65  case KTp::IdRole:
66  return group;
67  }
68  return QVariant();
69 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Fri Mar 22 2013 10:58:52 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktp-common-internals API Reference

Skip menu "ktp-common-internals API Reference"
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal