~aleteoryx/muditaos

ref: f4bcc5ce6f0d66f6ee55949f9978ad0c0399fddb muditaos/module-apps/apps-common/options/OptionsList.cpp -rw-r--r-- 1.7 KiB
f4bcc5ce — Dawid Wojtas [BH-1758] Fix information about next alarm ring 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "OptionsList.hpp"

namespace gui
{
    template <class ListType>
    OptionsList<ListType>::OptionsList(std::shared_ptr<OptionsModel> model, std::list<Option> options)
        : optionsModel{std::move(model)}, options(std::move(options))
    {}

    template <class ListType>
    void OptionsList<ListType>::createOptions()
    {
        optionsModel->createData(options);
    }

    template <class ListType>
    void OptionsList<ListType>::refreshOptions(std::list<Option> &&optionList)
    {
        options = std::move(optionList);
        optionsList->rebuildList(listview::RebuildType::InPlace);
    }

    template <class ListType>
    void OptionsList<ListType>::refreshOptions(std::list<Option> &&optionList, unsigned int pageIndex)
    {
        options = std::move(optionList);
        optionsList->rebuildList(listview::RebuildType::OnPageElement, pageIndex);
    }

    template <class ListType>
    void OptionsList<ListType>::addOptions(std::list<Option> &&optionList)
    {
        options = std::move(optionList);
        createOptions();

        optionsList->rebuildList();
    }

    template <class ListType>
    void OptionsList<ListType>::changeOptions(std::list<Option> &&optionList)
    {
        clearOptions();
        addOptions(std::move(optionList));
    }

    template <class ListType>
    void OptionsList<ListType>::recreateOptions()
    {
        clearOptions();
        createOptions();
    }

    template <class ListType>
    void OptionsList<ListType>::clearOptions()
    {
        optionsList->clear();
        optionsModel->clearData();
    }

} // namespace gui