blob: ce72035f9603dcb01b81cddba50b650cd712573d [file] [log] [blame]
Nicolas Jagerbf406b22016-10-21 11:32:33 -04001/***************************************************************************
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
23using namespace Windows::ApplicationModel::Core;
24using namespace Windows::Data::Json;
25using namespace Windows::Storage;
26using namespace Windows::Storage::Streams;
27using namespace Windows::UI::Core;
28
29
30using namespace RingClientUWP;
31using namespace ViewModel;
32
33AccountListItemsViewModel::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
42void RingClientUWP::ViewModel::AccountListItemsViewModel::OnaccountAdded(RingClientUWP::Account ^account)
43{
44 auto item = ref new AccountListItem(account);
45 itemsList_->Append(item);
46}
47
48
49void RingClientUWP::ViewModel::AccountListItemsViewModel::OnclearAccountsList()
50{
51 itemsList_->Clear();
52}
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040053
54AccountListItem^
55RingClientUWP::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}