mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-11-01 02:40:06 +00:00
Refactoring generic tree model behavior
This commit is contained in:
parent
1ba60f0da1
commit
98f8bab79a
7 changed files with 348 additions and 236 deletions
45
scwx-qt/source/scwx/qt/model/tree_model.hpp
Normal file
45
scwx-qt/source/scwx/qt/model/tree_model.hpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/qt/model/tree_item.hpp>
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace model
|
||||
{
|
||||
|
||||
class TreeModelImpl;
|
||||
|
||||
class TreeModel : public QAbstractTableModel
|
||||
{
|
||||
public:
|
||||
explicit TreeModel(QObject* parent = nullptr);
|
||||
virtual ~TreeModel();
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
QVariant data(const QModelIndex& index,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant headerData(int section,
|
||||
Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
QModelIndex index(int row,
|
||||
int column,
|
||||
const QModelIndex& parent = QModelIndex()) const override;
|
||||
QModelIndex parent(const QModelIndex& index) const override;
|
||||
|
||||
protected:
|
||||
virtual const std::shared_ptr<TreeItem> root_item() const = 0;
|
||||
|
||||
private:
|
||||
std::unique_ptr<TreeModelImpl> p;
|
||||
};
|
||||
|
||||
} // namespace model
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
Loading…
Add table
Add a link
Reference in a new issue