| 109 | } |
| 110 | |
| 111 | QVariant 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 | |
| 137 | bool T_TreeViewModel::setData(const QModelIndex& index, const QVariant& value, int role) |
| 138 | { |
nothing calls this directly
no test coverage detected