File indexing completed on 2025-01-05 04:55:00
0001 /* 0002 Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net> 0003 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> 0004 0005 This library is free software; you can redistribute it and/or modify it 0006 under the terms of the GNU Library General Public License as published by 0007 the Free Software Foundation; either version 2 of the License, or (at your 0008 option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, but WITHOUT 0011 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0012 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0013 License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to the 0017 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0018 02110-1301, USA. 0019 */ 0020 0021 #pragma once 0022 0023 #include "kube_export.h" 0024 #include <QSortFilterProxyModel> 0025 #include <QSharedPointer> 0026 0027 namespace Sink { 0028 class Query; 0029 }; 0030 0031 /** 0032 * A model that mixes addressbooks, contact groups and contacts 0033 */ 0034 class KUBE_EXPORT PeopleModel : public QSortFilterProxyModel 0035 { 0036 Q_OBJECT 0037 Q_PROPERTY (QVariant addressbook READ addressbook WRITE setAddressbook) 0038 Q_PROPERTY (QString filter READ filter WRITE setFilter) 0039 0040 public: 0041 PeopleModel(QObject *parent = Q_NULLPTR); 0042 ~PeopleModel(); 0043 0044 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; 0045 0046 bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; 0047 0048 enum Roles { 0049 Name = Qt::UserRole + 1, 0050 Type, 0051 Emails, 0052 Addressbook, 0053 DomainObject, 0054 FirstName, 0055 LastName, 0056 ImageData 0057 }; 0058 0059 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; 0060 0061 void runQuery(const Sink::Query &query); 0062 0063 void setAddressbook(const QVariant &parentFolder); 0064 QVariant addressbook() const; 0065 0066 void setFilter(const QString &mail); 0067 QString filter() const; 0068 0069 private: 0070 QSharedPointer<QAbstractItemModel> mModel; 0071 };