1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:57:44 +00:00

Ladybird: Add a ModelTranslator to translate a GUI::Model to a Qt model

This will be used to expose the DOMTreeModel from LibWebView :^)
This commit is contained in:
Andreas Kling 2022-09-25 12:08:42 +02:00 committed by Andrew Kaster
parent 2a021084e5
commit 98b6aea234
2 changed files with 117 additions and 0 deletions

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Model.h>
#include <QAbstractItemModel>
namespace Ladybird {
class ModelTranslator final : public QAbstractItemModel {
Q_OBJECT
public:
explicit ModelTranslator(NonnullRefPtr<GUI::Model>);
virtual ~ModelTranslator() override;
virtual int columnCount(QModelIndex const& parent) const override;
virtual int rowCount(QModelIndex const& parent) const override;
virtual QVariant data(QModelIndex const&, int role) const override;
virtual QModelIndex index(int row, int column, QModelIndex const& parent) const override;
virtual QModelIndex parent(QModelIndex const& index) const override;
QModelIndex to_qt(GUI::ModelIndex const&) const;
GUI::ModelIndex to_gui(QModelIndex const&) const;
private:
RefPtr<GUI::Model> m_model;
};
}