diff options
Diffstat (limited to 'logic/lists/InstanceList.cpp')
-rw-r--r-- | logic/lists/InstanceList.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp index 7081dc6f..72748b5f 100644 --- a/logic/lists/InstanceList.cpp +++ b/logic/lists/InstanceList.cpp @@ -362,8 +362,13 @@ int InstanceList::add(InstancePtr t) return count() - 1; } -InstancePtr InstanceList::getInstanceById(QString instId) +InstancePtr InstanceList::getInstanceById(QString instId) const { + if (m_instances.isEmpty()) + { + return InstancePtr(); + } + QListIterator<InstancePtr> iter(m_instances); InstancePtr inst; while (iter.hasNext()) @@ -378,7 +383,12 @@ InstancePtr InstanceList::getInstanceById(QString instId) return iter.peekPrevious(); } -int InstanceList::getInstIndex(BaseInstance *inst) +QModelIndex InstanceList::getInstanceIndexById(const QString &id) const +{ + return index(getInstIndex(getInstanceById(id).get())); +} + +int InstanceList::getInstIndex(BaseInstance *inst) const { for (int i = 0; i < m_instances.count(); i++) { |