Alexandre Lision | 3b0bd33 | 2015-03-15 18:43:07 -0400 | [diff] [blame] | 1 | /* |
Alexandre Lision | 9fe374b | 2016-01-06 10:17:31 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2016 Savoir-faire Linux Inc. |
Alexandre Lision | 3b0bd33 | 2015-03-15 18:43:07 -0400 | [diff] [blame] | 3 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Alexandre Lision | 3b0bd33 | 2015-03-15 18:43:07 -0400 | [diff] [blame] | 18 | */ |
Alexandre Lision | 3b0bd33 | 2015-03-15 18:43:07 -0400 | [diff] [blame] | 19 | |
| 20 | #include <collectioninterface.h> |
| 21 | #include <collectioneditor.h> |
| 22 | |
| 23 | class Person; |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 24 | @class ABPerson; |
| 25 | @class NSMutableArray; |
| 26 | @class NSNotification; |
Alexandre Lision | 3b0bd33 | 2015-03-15 18:43:07 -0400 | [diff] [blame] | 27 | |
| 28 | template<typename T> class CollectionMediator; |
| 29 | |
| 30 | class AddressBookBackend : public CollectionInterface |
| 31 | { |
| 32 | public: |
| 33 | explicit AddressBookBackend(CollectionMediator<Person>* mediator); |
| 34 | virtual ~AddressBookBackend(); |
| 35 | |
| 36 | virtual bool load() override; |
| 37 | virtual bool reload() override; |
| 38 | virtual bool clear() override; |
| 39 | virtual QString name () const override; |
| 40 | virtual QString category () const override; |
| 41 | virtual QVariant icon () const override; |
| 42 | virtual bool isEnabled() const override; |
| 43 | virtual QByteArray id () const override; |
Alexandre Lision | 3922463 | 2015-05-01 11:52:17 -0400 | [diff] [blame] | 44 | virtual FlagPack<SupportedFeatures> supportedFeatures() const override; |
Alexandre Lision | 3b0bd33 | 2015-03-15 18:43:07 -0400 | [diff] [blame] | 45 | |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 46 | bool addNewPerson(Person *item); |
| 47 | bool removePerson(NSString* uid); |
| 48 | |
Alexandre Lision | 3b0bd33 | 2015-03-15 18:43:07 -0400 | [diff] [blame] | 49 | private: |
| 50 | CollectionMediator<Person>* m_pMediator; |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 51 | NSMutableArray* observers; |
| 52 | |
| 53 | void handleNotification(NSNotification* ns); |
| 54 | Person* abPersonToPerson(ABPerson* ab); |
Alexandre Lision | 3b0bd33 | 2015-03-15 18:43:07 -0400 | [diff] [blame] | 55 | |
| 56 | void asyncLoad(int startingPoint); |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 57 | }; |