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

Method FindProperty

Modules/QtWidgets/src/QmitkPropertyItemModel.cpp:161–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161QModelIndex QmitkPropertyItemModel::FindProperty(const mitk::BaseProperty *property)
162{
163 if (property == nullptr)
164 return QModelIndex();
165
166 auto propertyList = m_PropertyList.Lock();
167
168 if (propertyList.IsNull())
169 return QModelIndex();
170
171 auto propertyMap = propertyList->GetMap();
172 auto it = std::find_if(propertyMap->begin(), propertyMap->end(), PropertyEqualTo(property));
173
174 if (it == propertyMap->end())
175 return QModelIndex();
176
177 QString name = QString::fromStdString(it->first);
178
179 if (!name.contains('.'))
180 {
181 QModelIndexList item = this->match(index(0, 0), Qt::DisplayRole, name, 1, Qt::MatchExactly);
182
183 if (!item.empty())
184 return item[0];
185 }
186 else
187 {
188 QStringList names = name.split('.');
189 QModelIndexList items =
190 this->match(index(0, 0), Qt::DisplayRole, names.last(), -1, Qt::MatchRecursive | Qt::MatchExactly);
191
192 for (auto item : std::as_const(items))
193 {
194 QModelIndex candidate = item;
195
196 for (int i = names.length() - 1; i != 0; --i)
197 {
198 QModelIndex parent = item.parent();
199
200 if (parent.parent() == QModelIndex())
201 {
202 if (parent.data() != names.first())
203 break;
204
205 return candidate;
206 }
207
208 if (parent.data() != names[i - 1])
209 break;
210
211 item = parent;
212 }
213 }
214 }
215
216 return QModelIndex();
217}
218

Callers 1

OnPropertyModifiedMethod · 0.95

Calls 11

containsMethod · 0.80
matchMethod · 0.80
PropertyEqualToClass · 0.70
QModelIndexClass · 0.50
LockMethod · 0.45
IsNullMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
parentMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected