File indexing completed on 2024-11-24 04:50:41
0001 // SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.1-or-later 0003 0004 #pragma once 0005 0006 #include <KContacts/Address> 0007 #include <QAbstractListModel> 0008 0009 class AddressModel : public QAbstractListModel 0010 { 0011 Q_OBJECT 0012 0013 public: 0014 enum Roles { 0015 CountryRole = Qt::UserRole + 1, 0016 ExtendedRole, 0017 FormattedAddressRole, 0018 HasGeoRole, 0019 LatitudeRole, 0020 LongitudeRole, 0021 IdRole, 0022 IsEmptyRole, 0023 LabelRole, 0024 PostalCodeRole, 0025 PostOfficeBoxRole, 0026 RegionRole, 0027 StreetRole, 0028 TypeRole, 0029 TypeLabelRole, 0030 }; 0031 Q_ENUM(Roles) 0032 AddressModel(QObject *parent = nullptr); 0033 0034 void setAddresses(const KContacts::Address::List &addresses); 0035 0036 int rowCount(const QModelIndex &parent = {}) const override; 0037 QVariant data(const QModelIndex &idx, int role) const override; 0038 QHash<int, QByteArray> roleNames() const override; 0039 0040 private: 0041 KContacts::Address::List m_addresses; 0042 };