1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 14:35:00 +00:00
serenity/Userland/Applications/Mail/MailboxTreeModel.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

37 lines
1.1 KiB
C++

/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Model.h>
#include <LibIMAP/Objects.h>
class AccountHolder;
class MailboxTreeModel final : public GUI::Model {
public:
static NonnullRefPtr<MailboxTreeModel> create(AccountHolder const& account_holder)
{
return adopt_ref(*new MailboxTreeModel(account_holder));
}
virtual ~MailboxTreeModel() override;
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual GUI::ModelIndex index(int row, int column, GUI::ModelIndex const& parent = GUI::ModelIndex()) const override;
virtual GUI::ModelIndex parent_index(GUI::ModelIndex const&) const override;
private:
explicit MailboxTreeModel(AccountHolder const&);
AccountHolder const& m_account_holder;
GUI::Icon m_mail_icon;
GUI::Icon m_folder_icon;
GUI::Icon m_account_icon;
};