Nicolas Jager | bf406b2 | 2016-10-21 11:32:33 -0400 | [diff] [blame] | 1 | /***************************************************************************
|
| 2 | * Copyright (C) 2016 by Savoir-faire Linux *
|
| 3 | * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
|
| 4 | * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
|
| 5 | * *
|
| 6 | * This program is free software; you can redistribute it and/or modify *
|
| 7 | * it under the terms of the GNU General Public License as published by *
|
| 8 | * the Free Software Foundation; either version 3 of the License, or *
|
| 9 | * (at your option) any later version. *
|
| 10 | * *
|
| 11 | * This program is distributed in the hope that it will be useful, *
|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
| 14 | * GNU General Public License for more details. *
|
| 15 | * *
|
| 16 | * You should have received a copy of the GNU General Public License *
|
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
| 18 | **************************************************************************/
|
| 19 | #include "pch.h"
|
| 20 |
|
| 21 | #include "AccountListItemsViewModel.h"
|
| 22 |
|
| 23 | using namespace Windows::ApplicationModel::Core;
|
| 24 | using namespace Windows::Data::Json;
|
| 25 | using namespace Windows::Storage;
|
| 26 | using namespace Windows::Storage::Streams;
|
| 27 | using namespace Windows::UI::Core;
|
| 28 |
|
| 29 |
|
| 30 | using namespace RingClientUWP;
|
| 31 | using namespace ViewModel;
|
| 32 |
|
| 33 | AccountListItemsViewModel::AccountListItemsViewModel()
|
| 34 | {
|
| 35 | itemsList_ = ref new Vector<AccountListItem^>();
|
| 36 |
|
| 37 | /* connect to delegates */
|
| 38 | AccountsViewModel::instance->accountAdded += ref new RingClientUWP::AccountAdded(this, &RingClientUWP::ViewModel::AccountListItemsViewModel::OnaccountAdded);
|
| 39 | AccountsViewModel::instance->clearAccountsList += ref new RingClientUWP::ClearAccountsList(this, &RingClientUWP::ViewModel::AccountListItemsViewModel::OnclearAccountsList);
|
| 40 | }
|
| 41 |
|
| 42 | void RingClientUWP::ViewModel::AccountListItemsViewModel::OnaccountAdded(RingClientUWP::Account ^account)
|
| 43 | {
|
| 44 | auto item = ref new AccountListItem(account);
|
| 45 | itemsList_->Append(item);
|
| 46 | }
|
| 47 |
|
| 48 |
|
| 49 | void RingClientUWP::ViewModel::AccountListItemsViewModel::OnclearAccountsList()
|
| 50 | {
|
| 51 | itemsList_->Clear();
|
| 52 | }
|
Nicolas Jager | 6abfc0d | 2016-10-21 14:57:47 -0400 | [diff] [blame^] | 53 |
|
| 54 | AccountListItem^
|
| 55 | RingClientUWP::ViewModel::AccountListItemsViewModel::findItem(String^ accountId)
|
| 56 | {
|
| 57 | for each (AccountListItem^ item in itemsList_)
|
| 58 | if (item->_account->accountID_ == accountId)
|
| 59 | return item;
|
| 60 |
|
| 61 | return nullptr;
|
| 62 | }
|