~aleteoryx/muditaos

ref: f66212e28aa1cd36331a3437a75080750c8ac2f9 muditaos/module-apps/application-calendar/models/DayEventsModel.cpp -rw-r--r-- 1.4 KiB
f66212e2 — Hubert Chrzaniuk [EGD-3468] Bump taglib repo 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "DayEventsModel.hpp"
#include "application-calendar/widgets/DayEventsItem.hpp"
#include <ListView.hpp>

DayEventsModel::DayEventsModel(app::Application *app) : DatabaseModel(app)
{
    application = app;
    assert(app != nullptr);
}

void DayEventsModel::requestRecords(const uint32_t offset, const uint32_t limit)
{
    list->onProviderDataUpdate();
}

unsigned int DayEventsModel::getMinimalItemHeight() const
{
    return style::window::calendar::item::dayEvents::height;
}

gui::ListItem *DayEventsModel::getItem(gui::Order order)
{
    auto item = new gui::DayEventsItem();

    auto record = getRecord(order);
    if (record != nullptr) {
        item->setEvent(record);
    }
    else {
        LOG_DEBUG("Empty record in EventsModel::GetItem");
        return nullptr;
    }
    LOG_DEBUG("Created new item in calendar day listView");
    item->activatedCallback = [=](gui::Item &item) {
        LOG_INFO("Switch to options/delete window");
        application->switchWindow(style::window::calendar::name::events_options);
        return true;
    };
    return item;
}

bool DayEventsModel::updateRecords(std::unique_ptr<std::vector<EventsRecord>> records)
{
    DatabaseModel::updateRecords(std::move(records));
    modelIndex = 0;
    list->onProviderDataUpdate();

    return true;
}

void DayEventsModel::setRecordsCount(const uint32_t &count)
{
    recordsCount = count;
}