MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / data

Method data

ElaWidgetToolsExample/ModelView/T_TreeViewModel.cpp:111–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111QVariant T_TreeViewModel::data(const QModelIndex& index, int role) const
112{
113 if (role == Qt::DisplayRole)
114 {
115 return static_cast<T_TreeItem*>(index.internalPointer())->getItemTitle();
116 }
117 else if (role == Qt::DecorationRole)
118 {
119 return QIcon(":/Resource/Image/Cirno.jpg");
120 }
121 else if (role == Qt::CheckStateRole)
122 {
123 T_TreeItem* item = static_cast<T_TreeItem*>(index.internalPointer());
124 if (item->getIsHasChild())
125 {
126 return item->getChildCheckState();
127 }
128 else
129 {
130 return item->getIsChecked() ? Qt::Checked : Qt::Unchecked;
131 }
132 return Qt::Unchecked;
133 }
134 return QVariant();
135}
136
137bool T_TreeViewModel::setData(const QModelIndex& index, const QVariant& value, int role)
138{

Callers

nothing calls this directly

Calls 3

getItemTitleMethod · 0.80
getChildCheckStateMethod · 0.80
getIsHasChildMethod · 0.45

Tested by

no test coverage detected