blob: bdb240693cee4f129449a0d23780b48b65a77193 [file] [log] [blame]
atraczyk25608ed2016-09-15 11:12:16 -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 "SmartPanelItemsViewModel.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
33SmartPanelItemsViewModel::SmartPanelItemsViewModel()
34{
35 itemsList_ = ref new Vector<SmartPanelItem^>();
36}
37
38SmartPanelItem^
39SmartPanelItemsViewModel::findItem(Call^ call)
40{
41 for each (SmartPanelItem^ item in itemsList)
42 if (item->_call == call)
43 return item;
44
45 return nullptr;
46}
47
48SmartPanelItem^
49SmartPanelItemsViewModel::findItem(Contact^ contact)
50{
51 for each (SmartPanelItem^ item in itemsList)
52 if (item->_contact == contact)
53 return item;
54
55 return nullptr;
56}
57
58unsigned int
59SmartPanelItemsViewModel::getIndex(Call^ call)
60{
61 unsigned int i;
62 for (i = 0; i < itemsList_->Size; i++) {
63 if (itemsList_->GetAt(i)->_call == call)
64 break;
65 }
66 return i;
67}
68
69unsigned int
70SmartPanelItemsViewModel::getIndex(Contact^ contact)
71{
72 unsigned int i;
73 for (i = 0; i < itemsList_->Size; i++) {
74 if (itemsList_->GetAt(i)->_contact == contact)
75 break;
76 }
77 return i;
78}