| 125 | } |
| 126 | |
| 127 | QVariant QmitkDataStorageTableModel::data(const QModelIndex &index, int role) const |
| 128 | { |
| 129 | QVariant data; |
| 130 | |
| 131 | if (index.isValid() && !m_NodeSet.empty()) |
| 132 | { |
| 133 | mitk::DataNode::Pointer node = m_NodeSet.at(index.row()); |
| 134 | |
| 135 | std::string nodeName = node->GetName(); |
| 136 | if (nodeName.empty()) |
| 137 | nodeName = "unnamed"; |
| 138 | |
| 139 | // get name |
| 140 | if (index.column() == 0) |
| 141 | { |
| 142 | // get name of node (may also be edited) |
| 143 | if (role == Qt::DisplayRole || role == Qt::EditRole) |
| 144 | { |
| 145 | data = QString::fromStdString(nodeName); |
| 146 | } |
| 147 | else if (role == QmitkDataNodeRole) |
| 148 | { |
| 149 | data = QVariant::fromValue(node); |
| 150 | } |
| 151 | } |
| 152 | else if (index.column() == 1) |
| 153 | { |
| 154 | QmitkNodeDescriptor *nodeDescriptor = QmitkNodeDescriptorManager::GetInstance()->GetDescriptor(node); |
| 155 | |
| 156 | // get type property of mitk::BaseData |
| 157 | if (role == Qt::DisplayRole) |
| 158 | { |
| 159 | data = nodeDescriptor->GetNameOfClass(); |
| 160 | } |
| 161 | // show some nice icons for datatype |
| 162 | else if (role == Qt::DecorationRole) |
| 163 | { |
| 164 | data = nodeDescriptor->GetIcon(node); |
| 165 | } |
| 166 | } |
| 167 | else if (index.column() == 2) |
| 168 | { |
| 169 | // get visible property of mitk::BaseData |
| 170 | bool visibility = false; |
| 171 | |
| 172 | if (node->GetVisibility(visibility, nullptr) && role == Qt::CheckStateRole) |
| 173 | { |
| 174 | data = (visibility ? Qt::Checked : Qt::Unchecked); |
| 175 | } // node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole |
| 176 | |
| 177 | } // index.column() == 2 |
| 178 | |
| 179 | } // index.isValid() && !m_NodeSet.empty() |
| 180 | return data; |
| 181 | } |
| 182 | |
| 183 | //# Public SETTERS |
| 184 | void QmitkDataStorageTableModel::SetPredicate(mitk::NodePredicateBase *_Predicate) |
nothing calls this directly
no test coverage detected