MCPcopy Create free account
hub / github.com/MITK/MITK / Iterate

Method Iterate

Modules/ImageStatisticsUI/src/QmitkStatisticsModelToStringConverter.cpp:70–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70QString 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;

Callers

nothing calls this directly

Calls 6

QStringClass · 0.50
toStringMethod · 0.45
dataMethod · 0.45
rowCountMethod · 0.45
indexMethod · 0.45
columnCountMethod · 0.45

Tested by

no test coverage detected