blob: 8147ff0d21f9402a7c3d9e62d3856d47597861ab [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^
Nicolas Jager083b3ae2016-10-04 08:46:19 -040039SmartPanelItemsViewModel::findItem(String^ callId)
atraczyk25608ed2016-09-15 11:12:16 -040040{
41 for each (SmartPanelItem^ item in itemsList)
Nicolas Jager083b3ae2016-10-04 08:46:19 -040042 if (item->_callId == callId)
atraczyk25608ed2016-09-15 11:12:16 -040043 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
Nicolas Jager083b3ae2016-10-04 08:46:19 -040059SmartPanelItemsViewModel::getIndex(String^ callId)
atraczyk25608ed2016-09-15 11:12:16 -040060{
61 unsigned int i;
62 for (i = 0; i < itemsList_->Size; i++) {
Nicolas Jager083b3ae2016-10-04 08:46:19 -040063 if (itemsList_->GetAt(i)->_callId == callId)
atraczyk25608ed2016-09-15 11:12:16 -040064 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;
Nicolas Jagere72856b2016-10-30 15:06:17 -040078}
79
80void RingClientUWP::ViewModel::SmartPanelItemsViewModel::removeItem(SmartPanelItem ^ item)
81{
82 unsigned int index;
83
84 if (itemsList->IndexOf(item, &index))
85 itemsList->RemoveAt(index);
86}