1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 11:05:08 +00:00
serenity/Userland/Applications/Calendar/AddEventDialog.h
sin-ack ca2c81251a Everywhere: Replace Model::update() with Model::invalidate()
Most of the models were just calling did_update anyway, which is
pointless since it can be unified to the base Model class. Instead, code
calling update() will now call invalidate(), which functions identically
and is more obvious in what it does.

Additionally, a default implementation is provided, which removes the
need to add empty implementations of update() for each model subclass.

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-08-06 19:14:31 +02:00

48 lines
1.3 KiB
C++

/*
* Copyright (c) 2019-2020, Ryan Grieb <ryan.m.grieb@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Calendar.h>
#include <LibGUI/Dialog.h>
#include <LibGUI/Model.h>
#include <LibGUI/Window.h>
class AddEventDialog final : public GUI::Dialog {
C_OBJECT(AddEventDialog)
public:
virtual ~AddEventDialog() override;
static void show(Core::DateTime date_time, Window* parent_window = nullptr)
{
auto dialog = AddEventDialog::construct(date_time, parent_window);
dialog->exec();
}
private:
AddEventDialog(Core::DateTime date_time, Window* parent_window = nullptr);
class MonthListModel final : public GUI::Model {
public:
enum Column {
Month,
__Count,
};
static NonnullRefPtr<MonthListModel> create() { return adopt_ref(*new MonthListModel); }
virtual ~MonthListModel() override;
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
private:
MonthListModel();
};
Core::DateTime m_date_time;
};