~aleteoryx/muditaos

ref: 280c5930a3c2bb76faf1a353e26762bd761e0982 muditaos/module-apps/application-calllog/windows/CallLogOptionsWindow.cpp -rw-r--r-- 1.3 KiB
280c5930 — Marcin Smoczyński Merge branch 'master' into stable 5 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
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "CallLogOptionsWindow.hpp"
#include <i18n/i18n.hpp>
#include <module-services/service-db/service-db/DBServiceAPI.hpp>
#include <OptionContact.hpp>

/// below just for apps names...

std::list<gui::Option> calllogWindowOptions(app::ApplicationCallLog *app, const CalllogRecord &record)
{
    auto searchResults = DBServiceAPI::ContactGetByIDWithTemporary(app, record.getContactId());

    std::list<gui::Option> options;

    if (searchResults->empty() || !searchResults->front().isValid() || searchResults->front().isTemporary()) {
        // add option - add contact
        options.emplace_back(gui::Option{
            std::make_unique<gui::option::Contact>(app, gui::option::ContactOperation::Add, searchResults->front())});
    }
    else {
        // add option - contact details
        options.emplace_back(gui::Option{std::make_unique<gui::option::Contact>(
            app, gui::option::ContactOperation::Details, searchResults->front())});
    }

    // add option delete call option
    options.push_back(gui::Option(
        utils::localize.get("app_calllog_options_delete_call"),
        [=](gui::Item &item) { return app->removeCalllogEntry(record); },
        gui::option::Arrow::Disabled));

    return options;
};