~aleteoryx/muditaos

ref: 80bdde9c9629b946454439871b77dee94d57ef75 muditaos/module-apps/application-calendar/windows/CalendarMainWindow.hpp -rw-r--r-- 1.8 KiB
80bdde9c — Marcin Smoczyński ADd changelog for v0.53.1 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
55
56
57
58
59
60
61
62
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "windows/AppWindow.hpp"
#include "Application.hpp"
#include "application-calendar/ApplicationCalendar.hpp"
#include "application-calendar/models/MonthModel.hpp"
#include "application-calendar/widgets/DayLabel.hpp"
#include "application-calendar/widgets/MonthBox.hpp"
#include <gui/widgets/GridLayout.hpp>
#include <map>
#include <vector>
#include <string>

namespace db
{
    class QueryResult;
}

namespace gui
{

    class CalendarMainWindow : public gui::AppWindow
    {
        bool isDayEmpty[31];
        uint32_t offsetFromTop = 0;
        uint32_t monthWidth    = 0;
        uint32_t monthHeight   = 0;
        uint32_t dayWidth      = 0;
        uint32_t dayHeight     = 0;

      protected:
        date::year_month_day actualDate;
        MonthBox *monthBox = nullptr;
        Label *dateLabel = nullptr;
        std::unique_ptr<MonthModel> monthModel;

      public:
        CalendarMainWindow(app::Application *app, const std::string &name);

        ~CalendarMainWindow() override = default;
        void rebuild() override;
        void refresh();
        void filterRequest();
        void buildMonth(std::unique_ptr<MonthModel> &model);
        void buildDateLabel(std::string actualDateTime);
        void buildInterface() override;
        void destroyInterface() override;
        bool onInput(const gui::InputEvent &inputEvent) override;
        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        auto handleQueryResponse(db::QueryResult *queryResult) -> bool;
        std::unique_ptr<MonthModel> getMonthModel()
        {
            return std::move(monthModel);
        }
        bool returnedFromWindow   = false;
        uint32_t dayFocusedBefore = 0;
    };

} // namespace gui