~aleteoryx/muditaos

ref: 0823d82e5141f44812c54debf07245d0ca746124 muditaos/module-apps/application-notes/widgets/NotesItem.cpp -rw-r--r-- 2.2 KiB
0823d82e — Radoslaw Wicik [EGD-3743] Update copyrights in fies - add empty line after license 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * @file NotesItem.cpp
 * @author Robert Borzecki (robert.borzecki@mudita.com)
 * @date 12 sie 2019
 * @brief
 * @copyright Copyright (C) 2019 mudita.com
 * @details
 */
#include "NotesItem.hpp"
#include <Style.hpp>

namespace gui
{

    NotesItem::NotesItem(NotesModel *model, bool mode24H) : model{model}, mode24H{mode24H}
    {
        setMinimumSize(style::window::default_body_width, 146);
        setMaximumSize(style::window::default_body_width, 146);

        setRadius(8);

        setPenFocusWidth(3);
        setPenWidth(1);

        hour = new gui::Label(this, 0, 0, 0, 0);
        hour->setPenFocusWidth(0);
        hour->setPenWidth(0);
        hour->setFont(style::window::font::medium);
        hour->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Right, gui::Alignment::Vertical::Top});

        title = new gui::Label(this, 0, 0, 0, 0);
        title->setPenFocusWidth(0);
        title->setPenWidth(0);
        title->setFont(style::window::font::bigbold);
        title->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top});

        snippet = new gui::Label(this, 0, 0, 0, 0);
        snippet->setPenFocusWidth(0);
        snippet->setPenWidth(0);
        snippet->setFont(style::window::font::small);
        snippet->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
    }

    NotesItem::~NotesItem()
    {
        note = nullptr;
    }

    bool NotesItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
    {
        hour->setPosition(11, 0);
        hour->setSize(newDim.w - 22, 40);

        title->setPosition(11, 0);
        title->setSize(68, 40);

        snippet->setPosition(11, 40);
        snippet->setSize(newDim.w - 22, newDim.h - 40);
        return true;
    }

    // sets copy of alarm's
    void NotesItem::setNote(std::shared_ptr<NotesRecord> &note)
    {
        this->note = note;
        // set values of the labels
        title->setText(std::to_string(note->ID));
        snippet->setText(note->path);
    }

    bool NotesItem::onActivated(void *data)
    {
        LOG_INFO("ITEM WAS PRESSED");
        return true;
    }

} /* namespace gui */