This commit is contained in:
Misaki
2025-12-04 19:11:29 +08:00
commit bb600bbbc4
2741 changed files with 364700 additions and 0 deletions
@@ -0,0 +1,74 @@
#include "T_IconDelegate.h"
#include <QPainter>
#include "Def.h"
#include "ElaTheme.h"
T_IconDelegate::T_IconDelegate(QObject* parent)
: QStyledItemDelegate{parent}
{
connect(eTheme, &ElaTheme::themeModeChanged, this, [=](ElaThemeType::ThemeMode themeMode) { _themeMode = themeMode; });
}
T_IconDelegate::~T_IconDelegate()
{
}
void T_IconDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
QStyleOptionViewItem viewOption(option);
initStyleOption(&viewOption, index);
if (option.state.testFlag(QStyle::State_HasFocus))
{
viewOption.state &= ~QStyle::State_HasFocus;
}
QStyledItemDelegate::paint(painter, viewOption, index);
QStringList iconList = index.data(Qt::UserRole).toStringList();
if (iconList.count() != 2)
{
return;
}
QString iconName = iconList.at(0);
QString iconValue = iconList.at(1);
painter->save();
painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
painter->save();
QFont iconFont = QFont("ElaAwesome");
iconFont.setPixelSize(22);
painter->setFont(iconFont);
painter->setPen(ElaThemeColor(_themeMode, BasicText));
painter->drawText(option.rect.x() + option.rect.width() / 2 - 11, option.rect.y() + option.rect.height() / 2 - 11, iconValue);
painter->restore();
// 文字绘制
painter->setPen(ElaThemeColor(_themeMode, BasicText));
QFont titlefont = painter->font();
titlefont.setPixelSize(13);
painter->setFont(titlefont);
qreal rowTextWidth = option.rect.width() * 0.8;
int subTitleRow = painter->fontMetrics().horizontalAdvance(iconName) / rowTextWidth;
if (subTitleRow > 0)
{
QString subTitleText = iconName;
for (int i = 0; i < subTitleRow + 1; i++)
{
QString text = painter->fontMetrics().elidedText(subTitleText, Qt::ElideRight, rowTextWidth);
if (text.right(3).contains(""))
{
text = text.replace("", subTitleText.mid(text.length() - 1, 1));
}
subTitleText.remove(0, text.length());
painter->drawText(option.rect.x() + option.rect.width() / 2 - painter->fontMetrics().horizontalAdvance(text) / 2, option.rect.y() + option.rect.height() - 10 * (subTitleRow + 1 - i), text);
}
}
else
{
painter->drawText(option.rect.x() + option.rect.width() / 2 - painter->fontMetrics().horizontalAdvance(iconName) / 2, option.rect.y() + option.rect.height() - 20, iconName);
}
painter->restore();
}
QSize T_IconDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
{
return QSize(100, 100);
}
@@ -0,0 +1,22 @@
#ifndef T_ICONDELEGATE_H
#define T_ICONDELEGATE_H
#include <QStyledItemDelegate>
#include "Def.h"
class T_IconDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
explicit T_IconDelegate(QObject* parent = nullptr);
~T_IconDelegate();
protected:
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
private:
ElaThemeType::ThemeMode _themeMode{ElaThemeType::Light};
};
#endif // T_ICONDELEGATE_H
@@ -0,0 +1,86 @@
#include "T_IconModel.h"
#include "Def.h"
T_IconModel::T_IconModel(QObject* parent)
: QAbstractListModel{parent}
{
_metaEnum = QMetaEnum::fromType<ElaIconType::IconName>();
_rowCount = _metaEnum.keyCount() - 1;
_pIsSearchMode = false;
}
T_IconModel::~T_IconModel()
{
}
int T_IconModel::rowCount(const QModelIndex& parent) const
{
return _rowCount;
}
void T_IconModel::setSearchKeyList(QStringList list)
{
beginResetModel();
this->_searchKeyList = list;
if (_pIsSearchMode)
{
_rowCount = this->getSearchKeyList().count();
}
else
{
_rowCount = _metaEnum.keyCount() - 1;
}
endResetModel();
}
QStringList T_IconModel::getSearchKeyList()
{
return this->_searchKeyList;
}
QVariant T_IconModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::UserRole)
{
if (!_pIsSearchMode)
{
if (index.row() >= _metaEnum.keyCount() - 1)
{
return QVariant();
}
return QStringList{_metaEnum.key(index.row() + 1), QChar(_metaEnum.value(index.row() + 1))};
}
else
{
QStringList iconList;
if (index.row() >= _searchKeyList.count())
{
return QVariant();
}
iconList.append(_searchKeyList.at(index.row()));
iconList.append(QChar(_metaEnum.keyToValue(_searchKeyList.at(index.row()).toUtf8().constData())));
return iconList;
}
}
return QVariant();
}
QString T_IconModel::getIconNameFromModelIndex(const QModelIndex& index) const
{
QString iconName;
if (_pIsSearchMode)
{
if (index.row() < _searchKeyList.count())
{
iconName = QString("ElaIconType::") + _searchKeyList.at(index.row());
}
}
else
{
if (index.row() < _metaEnum.keyCount() - 1)
{
iconName = QString("ElaIconType::") + _metaEnum.key(index.row() + 1);
}
}
return iconName;
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef T_ICONMODEL_H
#define T_ICONMODEL_H
#include <QAbstractListModel>
#include <QMetaEnum>
#include "stdafx.h"
class T_IconModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY_CREATE(bool, IsSearchMode)
public:
explicit T_IconModel(QObject* parent = nullptr);
~T_IconModel();
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
void setSearchKeyList(QStringList list);
QStringList getSearchKeyList();
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QString getIconNameFromModelIndex(const QModelIndex& index) const;
private:
QMetaEnum _metaEnum;
QStringList _searchKeyList;
int _rowCount;
};
#endif // T_ICONMODEL_H
@@ -0,0 +1,63 @@
#include "T_ListViewModel.h"
T_ListViewModel::T_ListViewModel(QObject* parent)
: QAbstractListModel{parent}
{
_dataList.append("最轻一个灵魂 送出玫瑰星光");
_dataList.append("最轻一句提问 答案是生命的存亡");
_dataList.append("最轻一颗麦种 由云帆托起");
_dataList.append("流浪至黑暗的心脏");
_dataList.append("轻轻的一支航船");
_dataList.append("归来却被囚困旧港湾");
_dataList.append("轻轻的一些落叶");
_dataList.append("飘零在梦萦故乡彼岸");
_dataList.append("轻轻的虫 森林鸣唱");
_dataList.append("轻轻的鱼 渡向汪洋");
_dataList.append("我们是 轻轻轻轻摇曳的篝火");
_dataList.append("轻轻对天空哼一支歌");
_dataList.append("轻轻被谁听见了");
_dataList.append("轻轻的被随意熄灭了");
_dataList.append("可我要 重重将夜灼伤");
_dataList.append("可我要 重重将夜点燃");
_dataList.append("更明亮的 也曾尘埃一样");
_dataList.append("最轻一段目光 注视年岁漫长");
_dataList.append("最轻一根琴弦 沉默着致命的声浪");
_dataList.append("最轻一线悬丝 紧握住锋芒");
_dataList.append("牵系着存亡的衡量");
_dataList.append("轻轻的一枚棋子 阻挡在骑士前进路上");
_dataList.append("轻轻的一双手掌 爱抚的婴孩不再成长");
_dataList.append("轻轻的虫 童话里唱");
_dataList.append("轻轻的鱼 向宇宙望");
_dataList.append("我们是 轻轻轻轻摇曳的篝火");
_dataList.append("轻轻对天空哼一支歌");
_dataList.append("轻轻被谁听见了");
_dataList.append("轻轻的被随意熄灭了");
_dataList.append("可我要 重重将夜灼伤");
_dataList.append("可我要 重重将夜点燃");
_dataList.append("更明亮的 也曾尘埃一样");
_dataList.append("轻轻时间 重重浩荡纪年");
_dataList.append("轻轻的文明 重重书写");
_dataList.append("轻轻身躯 重重对峙黑夜");
_dataList.append("轻轻的人类 重重思想");
_dataList.append("向宇宙望 向宇宙望");
_dataList.append("向远航");
_dataList.append("最重一粒微光");
}
T_ListViewModel::~T_ListViewModel()
{
}
int T_ListViewModel::rowCount(const QModelIndex& parent) const
{
return this->_dataList.count();
}
QVariant T_ListViewModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole)
{
return _dataList[index.row()];
}
return QVariant();
}
@@ -0,0 +1,21 @@
#ifndef T_LISTVIEWMODEL_H
#define T_LISTVIEWMODEL_H
#include <QAbstractListModel>
class T_ListViewModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit T_ListViewModel(QObject* parent = nullptr);
~T_ListViewModel();
protected:
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role) const override;
private:
QStringList _dataList;
};
#endif // T_LISTVIEWMODEL_H
@@ -0,0 +1,43 @@
#include "T_LogModel.h"
T_LogModel::T_LogModel(QObject* parent)
: QAbstractListModel{parent}
{
}
T_LogModel::~T_LogModel()
{
}
int T_LogModel::rowCount(const QModelIndex& parent) const
{
return this->_logList.count();
}
QVariant T_LogModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole)
{
return _logList[index.row()];
}
return QVariant();
}
void T_LogModel::setLogList(QStringList list)
{
beginResetModel();
this->_logList = list;
endResetModel();
}
void T_LogModel::appendLogList(QString log)
{
beginResetModel();
this->_logList.append(log);
endResetModel();
}
QStringList T_LogModel::getLogList() const
{
return this->_logList;
}
+24
View File
@@ -0,0 +1,24 @@
#ifndef T_LOGMODEL_H
#define T_LOGMODEL_H
#include <QAbstractListModel>
class T_LogModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit T_LogModel(QObject* parent = nullptr);
~T_LogModel();
void setLogList(QStringList list);
void appendLogList(QString log);
QStringList getLogList() const;
protected:
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role) const override;
private:
QStringList _logList;
};
#endif // T_LOGMODEL_H
@@ -0,0 +1,120 @@
#include "T_TableViewModel.h"
#include <QIcon>
T_TableViewModel::T_TableViewModel(QObject* parent)
: QAbstractTableModel{parent}
{
_header << "预览"
<< "歌名"
<< "歌手"
<< "专辑"
<< "时长";
QStringList data0;
QStringList data1;
QStringList data2;
QStringList data3;
QStringList data4;
QStringList data5;
QStringList data6;
QStringList data7;
QStringList data8;
data0 << "夜航星(Night Voyager)"
<< "不才/三体宇宙"
<< "我的三体之章北海传"
<< "05:03";
data1 << "玫瑰少年"
<< "五月天"
<< "玫瑰少年"
<< "03:55";
data2 << "Collapsing World(Original Mix)"
<< "Lightscape"
<< "Collapsing World"
<< "03:10";
data3 << "RAIN MAN (雨人)"
<< "AKIHIDE (佐藤彰秀)"
<< "RAIN STORY"
<< "05:37";
data4 << "黑暗森林"
<< "雲翼星辰"
<< "黑暗森林"
<< "05:47";
data5 << "轻(我的三体第四季主题曲)"
<< "刘雪茗"
<< "我的三体第四季"
<< "01:59";
data6 << "STYX HELIX"
<< "MYTH & ROID"
<< "STYX HELIX"
<< "04:51";
data7 << "LAST STARDUST"
<< "Aimer"
<< "DAWN"
<< "05:18";
data8 << "Running In The Dark"
<< "MONKEY MAJIK/塞壬唱片"
<< "Running In The Dark"
<< "03:40";
_dataList.append(data0);
_dataList.append(data1);
_dataList.append(data2);
_dataList.append(data3);
_dataList.append(data4);
_dataList.append(data5);
_dataList.append(data6);
_dataList.append(data7);
_dataList.append(data8);
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/NaightNavigationStar.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/MaVieEnRose.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/CollapsingWorld.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/RainMan.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/DarkForest.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/Light.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/STYXHELIX.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/LASTSTARDUST.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
_iconList.append(QIcon(QPixmap(":/Resource/Image/Model/RunningInTheDark.jpg").scaled(38, 38, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
}
T_TableViewModel::~T_TableViewModel()
{
}
int T_TableViewModel::rowCount(const QModelIndex& parent) const
{
return 100;
}
int T_TableViewModel::columnCount(const QModelIndex& parent) const
{
return _header.count();
}
QVariant T_TableViewModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole && index.column() != 0)
{
return _dataList[index.row() % 9][index.column() - 1];
}
else if (role == Qt::DecorationRole && index.column() == 0)
{
return _iconList[index.row() % 9];
}
else if (role == Qt::DecorationPropertyRole)
{
return Qt::AlignCenter;
}
else if (role == Qt::TextAlignmentRole && index.column() == 4)
{
return Qt::AlignCenter;
}
return QVariant();
}
QVariant T_TableViewModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
return _header[section];
}
return QAbstractTableModel::headerData(section, orientation, role);
}
@@ -0,0 +1,24 @@
#ifndef T_TABLEVIEWMODEL_H
#define T_TABLEVIEWMODEL_H
#include <QAbstractTableModel>
class T_TableViewModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit T_TableViewModel(QObject* parent = nullptr);
~T_TableViewModel();
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
QVariant data(const QModelIndex& index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
private:
QStringList _header;
QList<QStringList> _dataList;
QList<QIcon> _iconList;
};
#endif // T_TABLEVIEWMODEL_H
+110
View File
@@ -0,0 +1,110 @@
#include "T_TreeItem.h"
#include <QUuid>
T_TreeItem::T_TreeItem(QString itemTitle, T_TreeItem* parent)
: QObject{parent}
{
_itemKey = QUuid::createUuid().toString().remove("{").remove("}").remove("-");
_itemTitle = itemTitle;
_pParentItem = parent;
_pIsChecked = false;
}
T_TreeItem::~T_TreeItem()
{
qDeleteAll(_pChildrenItems);
}
QString T_TreeItem::getItemKey() const
{
return _itemKey;
}
QString T_TreeItem::getItemTitle() const
{
return _itemTitle;
}
void T_TreeItem::setChildChecked(bool isChecked)
{
if (isChecked)
{
for (auto node : _pChildrenItems)
{
node->setIsChecked(isChecked);
node->setChildChecked(isChecked);
}
}
else
{
for (auto node : _pChildrenItems)
{
node->setChildChecked(isChecked);
node->setIsChecked(isChecked);
}
}
}
Qt::CheckState T_TreeItem::getChildCheckState()
{
bool isAllChecked = true;
bool isAnyChecked = false;
for (auto node : _pChildrenItems)
{
if (node->getIsChecked())
{
isAnyChecked = true;
}
else
{
isAllChecked = false;
}
Qt::CheckState childState = node->getChildCheckState();
if (childState == Qt::PartiallyChecked)
{
isAllChecked = false;
isAnyChecked = true;
break;
}
else if (childState == Qt::Unchecked)
{
isAllChecked = false;
}
}
if (_pChildrenItems.count() > 0)
{
if (isAllChecked)
{
return Qt::Checked;
}
if (isAnyChecked)
{
return Qt::PartiallyChecked;
}
return Qt::Unchecked;
}
return Qt::Checked;
}
void T_TreeItem::appendChildItem(T_TreeItem* childItem)
{
_pChildrenItems.append(childItem);
}
bool T_TreeItem::getIsHasChild() const
{
if (_pChildrenItems.count() > 0)
{
return true;
}
return false;
}
int T_TreeItem::getRow() const
{
if (_pParentItem)
{
return _pParentItem->getChildrenItems().indexOf(const_cast<T_TreeItem*>(this));
}
return 0;
}
+33
View File
@@ -0,0 +1,33 @@
#ifndef T_TREEITEM_H
#define T_TREEITEM_H
#include <QModelIndex>
#include <QObject>
#include "stdafx.h"
class T_TreeItem : public QObject
{
Q_OBJECT
Q_PROPERTY_CREATE(QList<T_TreeItem*>, ChildrenItems)
Q_PROPERTY_CREATE(bool, IsChecked)
Q_PRIVATE_CREATE(T_TreeItem*, ParentItem)
public:
explicit T_TreeItem(QString itemTitle, T_TreeItem* parent = nullptr);
~T_TreeItem();
QString getItemKey() const;
QString getItemTitle() const;
void setChildChecked(bool isChecked);
Qt::CheckState getChildCheckState();
void appendChildItem(T_TreeItem* childItem);
bool getIsHasChild() const;
int getRow() const;
private:
QString _itemKey = "";
QString _itemTitle = "";
bool _isExpanded{false};
};
#endif // T_TREEITEM_H
@@ -0,0 +1,169 @@
#include "T_TreeViewModel.h"
#include <QIcon>
#include "T_TreeItem.h"
T_TreeViewModel::T_TreeViewModel(QObject* parent)
: QAbstractItemModel{parent}
{
_rootItem = new T_TreeItem("root");
for (int i = 0; i < 20; i++)
{
T_TreeItem* level1Item = new T_TreeItem(QString("Lv1--TreeItem%1").arg(i + 1), _rootItem);
for (int j = 0; j < 6; j++)
{
T_TreeItem* level2Item = new T_TreeItem(QString("Lv2--TreeItem%1").arg(j + 1), level1Item);
for (int k = 0; k < 6; k++)
{
T_TreeItem* level3Item = new T_TreeItem(QString("Lv3--TreeItem%1").arg(k + 1), level2Item);
for (int l = 0; l < 6; l++)
{
T_TreeItem* level4Item = new T_TreeItem(QString("Lv4--TreeItem%1").arg(l + 1), level3Item);
level3Item->appendChildItem(level4Item);
_itemsMap.insert(level4Item->getItemKey(), level4Item);
}
level2Item->appendChildItem(level3Item);
_itemsMap.insert(level3Item->getItemKey(), level3Item);
}
level1Item->appendChildItem(level2Item);
_itemsMap.insert(level2Item->getItemKey(), level2Item);
}
_rootItem->appendChildItem(level1Item);
_itemsMap.insert(level1Item->getItemKey(), level1Item);
}
}
T_TreeViewModel::~T_TreeViewModel()
{
delete _rootItem;
}
QModelIndex T_TreeViewModel::parent(const QModelIndex& child) const
{
if (!child.isValid())
{
return QModelIndex();
}
T_TreeItem* childItem = static_cast<T_TreeItem*>(child.internalPointer());
T_TreeItem* parentItem = childItem->getParentItem();
if (parentItem == _rootItem)
{
return QModelIndex();
}
else if (parentItem == nullptr)
{
return QModelIndex();
}
return createIndex(parentItem->getRow(), 0, parentItem);
}
QModelIndex T_TreeViewModel::index(int row, int column, const QModelIndex& parent) const
{
if (!hasIndex(row, column, parent))
{
return QModelIndex();
}
T_TreeItem* parentItem;
if (!parent.isValid())
{
parentItem = _rootItem;
}
else
{
parentItem = static_cast<T_TreeItem*>(parent.internalPointer());
}
T_TreeItem* childItem = nullptr;
if (parentItem->getChildrenItems().count() > row)
{
childItem = parentItem->getChildrenItems().at(row);
}
if (childItem)
{
return createIndex(row, column, childItem);
}
return QModelIndex();
}
int T_TreeViewModel::rowCount(const QModelIndex& parent) const
{
T_TreeItem* parentItem;
if (parent.column() > 0)
{
return 0;
}
if (!parent.isValid())
{
parentItem = _rootItem;
}
else
{
parentItem = static_cast<T_TreeItem*>(parent.internalPointer());
}
return parentItem->getChildrenItems().count();
}
int T_TreeViewModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent)
return 1;
}
QVariant T_TreeViewModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole)
{
return static_cast<T_TreeItem*>(index.internalPointer())->getItemTitle();
}
else if (role == Qt::DecorationRole)
{
return QIcon(":/Resource/Image/Cirno.jpg");
}
else if (role == Qt::CheckStateRole)
{
T_TreeItem* item = static_cast<T_TreeItem*>(index.internalPointer());
if (item->getIsHasChild())
{
return item->getChildCheckState();
}
else
{
return item->getIsChecked() ? Qt::Checked : Qt::Unchecked;
}
return Qt::Unchecked;
}
return QVariant();
}
bool T_TreeViewModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
if (role == Qt::CheckStateRole)
{
T_TreeItem* item = static_cast<T_TreeItem*>(index.internalPointer());
item->setIsChecked(!item->getIsChecked());
item->setChildChecked(item->getIsChecked());
Q_EMIT dataChanged(QModelIndex(), QModelIndex(), {role});
return true;
}
return QAbstractItemModel::setData(index, value, role);
}
Qt::ItemFlags T_TreeViewModel::flags(const QModelIndex& index) const
{
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
flags |= Qt::ItemIsUserCheckable;
return flags;
}
QVariant T_TreeViewModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
return QString("ElaTreeView-Example-4Level");
}
return QAbstractItemModel::headerData(section, orientation, role);
}
int T_TreeViewModel::getItemCount() const
{
return this->_itemsMap.count();
}
@@ -0,0 +1,30 @@
#ifndef T_TREEVIEWMODEL_H
#define T_TREEVIEWMODEL_H
#include <QAbstractItemModel>
#include <QObject>
class T_TreeItem;
class T_TreeViewModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit T_TreeViewModel(QObject* parent = nullptr);
~T_TreeViewModel();
QModelIndex parent(const QModelIndex& child) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
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;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
int getItemCount() const;
private:
QMap<QString, T_TreeItem*> _itemsMap;
T_TreeItem* _rootItem{nullptr};
};
#endif // T_TREEVIEWMODEL_H