mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-18 12:04:03 -04:00
-Create application->switchManyWindowsBack() method -Create equivalent to empty window enum class -Remove stored prevWindows variables -Add bottom bar to empty window (equivalent to allEvents) -Repair going back to previous windows functionality -Repair switching window (with empty events DB) -Add EventShift value to event records time
113 lines
4.4 KiB
C++
113 lines
4.4 KiB
C++
#include "AllEventsWindow.hpp"
|
|
#include "InputEvent.hpp"
|
|
#include "module-apps/application-calendar/ApplicationCalendar.hpp"
|
|
#include "module-apps/application-calendar/data/CalendarData.hpp"
|
|
#include <gui/widgets/BottomBar.hpp>
|
|
#include <gui/widgets/TopBar.hpp>
|
|
#include <gui/widgets/Window.hpp>
|
|
#include <service-appmgr/ApplicationManager.hpp>
|
|
|
|
#include <module-services/service-db/messages/QueryMessage.hpp>
|
|
#include <module-db/queries/calendar/QueryEventsGetAllLimited.hpp>
|
|
#include <module-services/service-db/api/DBServiceAPI.hpp>
|
|
#include <time/time_conversion.hpp>
|
|
#include <module-services/service-db/messages/DBNotificationMessage.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
|
|
AllEventsWindow::AllEventsWindow(app::Application *app, std::string name)
|
|
: AppWindow(app, style::window::calendar::name::all_events_window),
|
|
allEventsModel{std::make_shared<AllEventsModel>(this->application)}
|
|
{
|
|
buildInterface();
|
|
}
|
|
|
|
void AllEventsWindow::rebuild()
|
|
{
|
|
buildInterface();
|
|
}
|
|
|
|
void AllEventsWindow::buildInterface()
|
|
{
|
|
AppWindow::buildInterface();
|
|
|
|
topBar->setActive(gui::TopBar::Elements::TIME, true);
|
|
bottomBar->setActive(gui::BottomBar::Side::RIGHT, true);
|
|
bottomBar->setText(gui::BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));
|
|
bottomBar->setText(gui::BottomBar::Side::CENTER, utils::localize.get(style::strings::common::open));
|
|
bottomBar->setText(gui::BottomBar::Side::LEFT, utils::localize.get("app_calendar_bar_month"));
|
|
|
|
setTitle(utils::localize.get("app_calendar_title_main"));
|
|
leftArrowImage = new gui::Image(
|
|
this, style::window::calendar::arrow_x, style::window::calendar::arrow_y, 0, 0, "arrow_left");
|
|
newDayEventImage =
|
|
new gui::Image(this, style::window::calendar::cross_x, style::window::calendar::cross_y, 0, 0, "cross");
|
|
|
|
allEventsList = new gui::CalendarListView(this,
|
|
style::window::calendar::listView_x,
|
|
style::window::calendar::listView_y,
|
|
style::window::calendar::listView_w,
|
|
style::window::calendar::listView_h,
|
|
allEventsModel);
|
|
setFocusItem(allEventsList);
|
|
}
|
|
|
|
void AllEventsWindow::onBeforeShow(gui::ShowMode mode, gui::SwitchData *data)
|
|
{
|
|
allEventsList->rebuildList();
|
|
}
|
|
|
|
bool AllEventsWindow::onInput(const gui::InputEvent &inputEvent)
|
|
{
|
|
if (inputEvent.keyCode == gui::KeyCode::KEY_RF &&
|
|
inputEvent.state == gui::InputEvent::State::keyReleasedShort) {
|
|
LOG_DEBUG("Switch to desktop");
|
|
sapm::ApplicationManager::messageSwitchPreviousApplication(application);
|
|
}
|
|
|
|
if (AppWindow::onInput(inputEvent)) {
|
|
return true;
|
|
}
|
|
|
|
if (!inputEvent.isShortPress()) {
|
|
return false;
|
|
}
|
|
|
|
if (inputEvent.keyCode == gui::KeyCode::KEY_LEFT) {
|
|
LOG_DEBUG("Switch to new event window");
|
|
std::unique_ptr<EventRecordData> data = std::make_unique<EventRecordData>();
|
|
data->setDescription(style::window::calendar::new_event);
|
|
auto event = std::make_shared<EventsRecord>();
|
|
event->date_from = TimePointNow();
|
|
event->date_till = TimePointNow();
|
|
data->setData(event);
|
|
application->switchWindow(
|
|
style::window::calendar::name::new_edit_event, gui::ShowMode::GUI_SHOW_INIT, std::move(data));
|
|
return true;
|
|
}
|
|
|
|
if (inputEvent.keyCode == gui::KeyCode::KEY_LF) {
|
|
application->switchWindow(gui::name::window::main_window);
|
|
LOG_DEBUG("Switch to month view - main window");
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool AllEventsWindow::onDatabaseMessage(sys::Message *msgl)
|
|
{
|
|
auto *msgNotification = dynamic_cast<db::NotificationMessage *>(msgl);
|
|
if (msgNotification != nullptr) {
|
|
if (msgNotification->interface == db::Interface::Name::Events) {
|
|
if (msgNotification->dataModified()) {
|
|
allEventsList->rebuildList(style::listview::RebuildType::InPlace);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
} /* namespace gui */
|