| 68 | } |
| 69 | |
| 70 | QString QmitkStatisticsModelToStringConverter::Iterate(const QModelIndex &index, |
| 71 | const QmitkImageStatisticsTreeModel *model, |
| 72 | QString label) const |
| 73 | { |
| 74 | QString content; |
| 75 | |
| 76 | if (model->hasChildren(index)) |
| 77 | { |
| 78 | if (index.isValid()) |
| 79 | { |
| 80 | label += index.data().toString() + QString(" >> "); |
| 81 | } |
| 82 | |
| 83 | auto rows = model->rowCount(index); |
| 84 | for (int r = 0; r < rows; ++r) |
| 85 | { |
| 86 | auto childIndex = model->index(r, 0, index); |
| 87 | |
| 88 | if (model->hasChildren(childIndex)) |
| 89 | { |
| 90 | content += Iterate(childIndex, model, label); |
| 91 | } |
| 92 | else |
| 93 | { |
| 94 | content += label; |
| 95 | |
| 96 | auto cols = model->columnCount(index); |
| 97 | for (int c = 0; c < cols; ++c) |
| 98 | { |
| 99 | if (c > 0) |
| 100 | { |
| 101 | content += m_columnDelimiter; |
| 102 | } |
| 103 | |
| 104 | auto columnChildIndex = model->index(r, c, index); |
| 105 | content += Iterate(columnChildIndex, model, label); |
| 106 | } |
| 107 | content += m_rowDelimiter; |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | else |
| 112 | { |
| 113 | if (index.isValid()) |
| 114 | { |
| 115 | auto data = index.data(); |
| 116 | if (data.typeId() == QMetaType::Double) |
| 117 | { |
| 118 | content = QString("%L1").arg(data.toDouble(), 0, 'f'); |
| 119 | } |
| 120 | else |
| 121 | { |
| 122 | content = data.toString(); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | return content; |