~aleteoryx/muditaos

ref: 78904a6b5d80ab55e1fbf2861ab3a905c96ae94d muditaos/module-apps/application-calendar/models/EventDetailModel.cpp -rw-r--r-- 1.2 KiB
78904a6b — Tomas Rogala [EGD-3307] Review changes 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 "EventDetailModel.hpp"
#include "application-calendar/widgets/EventDetailDescriptionItem.hpp"
#include "application-calendar/widgets/RepeatAndReminderItem.hpp"
#include <ListView.hpp>

EventDetailModel::EventDetailModel(app::Application *app) : application(app)
{}

auto EventDetailModel::requestRecordsCount() -> unsigned int
{
    return internalData.size();
}

unsigned int EventDetailModel::getMinimalItemHeight() const
{
    return style::window::calendar::item::eventDetail::height_max;
}

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

gui::ListItem *EventDetailModel::getItem(gui::Order order)
{
    return getRecord(order);
}

void EventDetailModel::createData()
{
    internalData.push_back(new gui::EventDetailDescriptionItem());
    internalData.push_back(new gui::RepeatAndReminderItem());

    for (auto &item : internalData) {
        item->deleteByList = false;
    }
}

void EventDetailModel::loadData()
{
    list->clear();
    eraseInternalData();

    createData();

    requestRecords(0, internalData.size());

    for (auto &item : internalData) {
        if (item->onLoadCallback) {
            item->onLoadCallback();
        }
    }
}